1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701
|
from contextlib import suppress
from typing import Any, List, Optional
from PyViCare.PyViCareDevice import Device
from PyViCare.PyViCareHeatCurveCalculation import (
heat_curve_formular_variant1, heat_curve_formular_variant2)
from PyViCare.PyViCareUtils import (VICARE_DAYS,
PyViCareNotSupportedFeatureError,
ViCareTimer, handleAPICommandErrors,
handleNotSupported, parse_time_as_delta,
time_as_delta)
VICARE_DHW_TEMP2 = "temp-2"
def all_set(_list: List[Any]) -> bool:
return all(v is not None for v in _list)
def get_available_burners(service):
# workaround starting from 25.01.2022
# see: https://github.com/somm15/PyViCare/issues/243
available_burners = []
for burner in ['0', '1', '2', '3', '4', '5']:
with suppress(PyViCareNotSupportedFeatureError):
if service.getProperty(f"heating.burners.{burner}") is not None:
available_burners.append(burner)
return available_burners
class HeatingDevice(Device):
"""This is the base class for all heating devices.
This class connects to the Viessmann ViCare API.
The authentication is done through OAuth2.
Note that currently, a new token is generated for each run.
"""
@property
def circuits(self) -> List[Any]:
return list([self.getCircuit(x) for x in self.getAvailableCircuits()])
def getCircuit(self, circuit):
return HeatingCircuit(self, circuit)
def get_heat_curve_formular(self):
if self.service.hasRoles(["type:heatpump", "type:E3"]):
return heat_curve_formular_variant1
if self.service.hasRoles(["type:heatpump"]) and len(self.getAvailableCircuits()) == 1:
return heat_curve_formular_variant2
return heat_curve_formular_variant1
@property
def burners(self) -> List[Any]:
return []
@property
def compressors(self) -> List[Any]:
return []
@handleNotSupported
def getOutsideTemperature(self):
return self.getProperty("heating.sensors.temperature.outside")["properties"]["value"]["value"]
@handleNotSupported
def getDomesticHotWaterConfiguredTemperature(self):
return self.getProperty("heating.dhw.temperature.main")["properties"]["value"]["value"]
@handleNotSupported
def getDomesticHotWaterStorageTemperature(self):
return self.getProperty("heating.dhw.sensors.temperature.dhwCylinder")["properties"]["value"][
"value"]
@handleNotSupported
def getHotWaterStorageTemperatureTop(self):
return self.getProperty("heating.dhw.sensors.temperature.dhwCylinder.top")["properties"]["value"][
"value"]
@handleNotSupported
def getDomesticHotWaterStorageTemperatureMiddle(self):
return self.getProperty("heating.dhw.sensors.temperature.dhwCylinder.middle")["properties"]["value"][
"value"]
@handleNotSupported
def getDomesticHotWaterStorageTemperatureMidBottom(self):
return self.getProperty("heating.dhw.sensors.temperature.dhwCylinder.midBottom")["properties"]["value"][
"value"]
@handleNotSupported
def getHotWaterStorageTemperatureBottom(self):
return self.getProperty("heating.dhw.sensors.temperature.dhwCylinder.bottom")["properties"]["value"][
"value"]
@handleNotSupported
def getDomesticHotWaterConfiguredTemperature2(self):
return self.getProperty("heating.dhw.temperature.temp2")["properties"]["value"]["value"]
def getDomesticHotWaterActiveMode(self):
schedule = self.getDomesticHotWaterSchedule()
if schedule == "error" or schedule["active"] is not True:
return None
currentDateTime = ViCareTimer().now()
currentTime = time_as_delta(currentDateTime)
current_day = VICARE_DAYS[currentDateTime.weekday()]
if current_day not in schedule:
return None
mode = None
for s in schedule[current_day]:
startTime = parse_time_as_delta(s["start"])
endTime = parse_time_as_delta(s["end"])
if startTime <= currentTime and currentTime <= endTime:
if s["mode"] == VICARE_DHW_TEMP2: # temp-2 overrides all other modes
return VICARE_DHW_TEMP2
mode = s["mode"]
return mode
def getDomesticHotWaterDesiredTemperature(self):
mode = self.getDomesticHotWaterActiveMode()
if mode is not None:
if mode == VICARE_DHW_TEMP2:
return self.getDomesticHotWaterConfiguredTemperature2()
return self.getDomesticHotWaterConfiguredTemperature()
return None
@handleNotSupported
def getDomesticHotWaterOutletTemperature(self):
return self.getProperty("heating.dhw.sensors.temperature.outlet")["properties"]["value"]["value"]
@handleNotSupported
def getDomesticHotWaterPumpActive(self):
status = self.getProperty("heating.dhw.pumps.primary")[
"properties"]["status"]["value"]
return status == 'on'
@handleNotSupported
def getDomesticHotWaterCirculationPumpActive(self):
status = self.getProperty("heating.dhw.pumps.circulation")[
"properties"]["status"]["value"]
return status == 'on'
@handleNotSupported
def getDomesticHotWaterActive(self):
status = self.getProperty("heating.dhw")["properties"]["status"]["value"]
return status == 'on'
@handleNotSupported
def getDomesticHotWaterMaxTemperature(self):
return self.getProperty("heating.dhw.temperature.main")["commands"]["setTargetTemperature"]["params"][
"temperature"]["constraints"]["max"]
@handleNotSupported
def getDomesticHotWaterMinTemperature(self):
return self.getProperty("heating.dhw.temperature.main")["commands"]["setTargetTemperature"]["params"][
"temperature"]["constraints"]["min"]
@handleNotSupported
def getDomesticHotWaterChargingActive(self):
return self.getProperty("heating.dhw.charging")["properties"]["active"]["value"]
@handleAPICommandErrors
def setDomesticHotWaterTemperature(self, temperature):
""" Set the target temperature for domestic host water
Parameters
----------
temperature : int
Target temperature
Returns
-------
result: json
json representation of the answer
"""
return self.setProperty("heating.dhw.temperature.main", "setTargetTemperature",
{'temperature': int(temperature)})
@handleAPICommandErrors
def setDomesticHotWaterTemperature2(self, temperature):
""" Set the target temperature 2 for domestic host water
Parameters
----------
temperature : int
Target temperature
Returns
-------
result: json
json representation of the answer
"""
return self.setProperty("heating.dhw.temperature.temp2", "setTargetTemperature",
{"temperature": int(temperature)})
@handleAPICommandErrors
def setDomesticHotWaterOperatingMode(self, mode):
return self.setProperty("heating.dhw.operating.modes.active", "setMode",
{'mode': mode})
@handleNotSupported
def getDomesticHotWaterSchedule(self):
properties = self.getProperty(
"heating.dhw.schedule")["properties"]
return {
"active": properties["active"]["value"],
"mon": properties["entries"]["value"]["mon"],
"tue": properties["entries"]["value"]["tue"],
"wed": properties["entries"]["value"]["wed"],
"thu": properties["entries"]["value"]["thu"],
"fri": properties["entries"]["value"]["fri"],
"sat": properties["entries"]["value"]["sat"],
"sun": properties["entries"]["value"]["sun"]
}
@handleNotSupported
def getSolarCollectorTemperature(self):
return self.getProperty("heating.solar.sensors.temperature.collector")["properties"]["value"]["value"]
@handleNotSupported
def getSolarStorageTemperature(self):
return self.getProperty("heating.solar.sensors.temperature.dhw")["properties"]["value"]["value"]
@handleNotSupported
def getSolarPowerProduction(self):
return self.getSolarPowerProductionDays()
@handleNotSupported
def getSolarPowerProductionUnit(self):
return self.getProperty("heating.solar.power.production")["properties"]["day"]["unit"]
@handleNotSupported
def getSolarPowerProductionDays(self):
return self.getProperty("heating.solar.power.production")["properties"]["day"]["value"]
@handleNotSupported
def getSolarPowerProductionToday(self):
return self.getProperty("heating.solar.power.production")["properties"]["day"]["value"][0]
@handleNotSupported
def getSolarPowerProductionWeeks(self):
return self.getProperty("heating.solar.power.production")["properties"]["week"]["value"]
@handleNotSupported
def getSolarPowerProductionThisWeek(self):
return self.getProperty("heating.solar.power.production")["properties"]["week"]["value"][0]
@handleNotSupported
def getSolarPowerProductionMonths(self):
return self.getProperty("heating.solar.power.production")["properties"]["month"]["value"]
@handleNotSupported
def getSolarPowerProductionThisMonth(self):
return self.getProperty("heating.solar.power.production")["properties"]["month"]["value"][0]
@handleNotSupported
def getSolarPowerProductionYears(self):
return self.getProperty("heating.solar.power.production")["properties"]["year"]["value"]
@handleNotSupported
def getSolarPowerProductionThisYear(self):
return self.getProperty("heating.solar.power.production")["properties"]["year"]["value"][0]
@handleNotSupported
def getSolarPumpActive(self):
status = self.getProperty("heating.solar.pumps.circuit")[
"properties"]["status"]["value"]
return status == 'on'
@handleNotSupported
def getOneTimeCharge(self):
return self.getProperty("heating.dhw.oneTimeCharge")["properties"]["active"]["value"]
@handleAPICommandErrors
def deactivateOneTimeCharge(self):
return self.setProperty("heating.dhw.oneTimeCharge", "deactivate", {})
@handleAPICommandErrors
def activateOneTimeCharge(self):
return self.setProperty("heating.dhw.oneTimeCharge", "activate", {})
@handleAPICommandErrors
def setDomesticHotWaterCirculationSchedule(self, schedule):
return self.setProperty("heating.dhw.pumps.circulation.schedule", "setSchedule",
{'newSchedule': schedule})
@handleNotSupported
def getDomesticHotWaterCirculationScheduleModes(self):
return self.getProperty("heating.dhw.pumps.circulation.schedule")["commands"]["setSchedule"]["params"][
"newSchedule"]["constraints"]["modes"]
@handleNotSupported
def getDomesticHotWaterCirculationSchedule(self):
schedule = self.getProperty(
"heating.dhw.pumps.circulation.schedule")
properties = schedule["properties"]
command = schedule["commands"]
return {
"active": properties["active"]["value"],
"default_mode": command["setSchedule"]["params"]["newSchedule"]["constraints"]["defaultMode"],
"mon": properties["entries"]["value"]["mon"],
"tue": properties["entries"]["value"]["tue"],
"wed": properties["entries"]["value"]["wed"],
"thu": properties["entries"]["value"]["thu"],
"fri": properties["entries"]["value"]["fri"],
"sat": properties["entries"]["value"]["sat"],
"sun": properties["entries"]["value"]["sun"]
}
def getDomesticHotWaterCirculationMode(self):
schedule = self.getDomesticHotWaterCirculationSchedule()
if schedule == "error" or schedule["active"] is not True:
return None
currentDateTime = ViCareTimer().now()
currentTime = time_as_delta(currentDateTime)
current_day = VICARE_DAYS[currentDateTime.weekday()]
if current_day not in schedule:
return None # no schedule for day configured
for s in schedule[current_day]:
startTime = parse_time_as_delta(s["start"])
endTime = parse_time_as_delta(s["end"])
if startTime <= currentTime and currentTime <= endTime:
return s["mode"]
return schedule['default_mode']
@handleNotSupported
def getAvailableCircuits(self):
return self.getProperty("heating.circuits")["properties"]["enabled"]["value"]
@handleNotSupported
def getControllerSerial(self):
return self.getProperty("heating.controller.serial")["properties"]["value"]["value"]
@handleNotSupported
def getBoilerSerial(self):
return self.getProperty("heating.boiler.serial")["properties"]["value"]["value"]
@handleNotSupported
def getReturnTemperature(self):
return self.getProperty("heating.sensors.temperature.return")["properties"]["value"]["value"]
@handleNotSupported
def getSupplyTemperaturePrimaryCircuit(self):
return self.getProperty("heating.primaryCircuit.sensors.temperature.supply")["properties"]["value"][
"value"]
@handleNotSupported
def getReturnTemperaturePrimaryCircuit(self):
return self.getProperty("heating.primaryCircuit.sensors.temperature.return")["properties"]["value"][
"value"]
@handleNotSupported
def getSupplyTemperatureSecondaryCircuit(self):
return self.getProperty("heating.secondaryCircuit.sensors.temperature.supply")["properties"]["value"][
"value"]
@handleNotSupported
def getReturnTemperatureSecondaryCircuit(self):
return self.getProperty("heating.secondaryCircuit.sensors.temperature.return")["properties"]["value"][
"value"]
@handleNotSupported
def getBoilerCommonSupplyTemperature(self):
return self.getProperty("heating.boiler.sensors.temperature.commonSupply")["properties"]["value"]["value"]
class HeatingDeviceWithComponent:
"""This is the base class for all heating components"""
def __init__(self, device: HeatingDevice, component: str) -> None:
self.service = device.service
self.component = component
self.device = device
@property
def id(self) -> str:
return self.component
def getProperty(self, property_name: str) -> Any:
return self.device.getProperty(property_name)
class HeatingCircuit(HeatingDeviceWithComponent):
@property
def circuit(self) -> str:
return self.component
def setMode(self, mode):
""" Set the active mode
Parameters
----------
mode : str
Valid mode can be obtained using getModes()
Returns
-------
result: json
json representation of the answer
"""
r = self.device.setProperty(
f"heating.circuits.{self.circuit}.operating.modes.active", "setMode", {'mode': mode})
return r
def setProgramTemperature(self, program: str, temperature: float):
# Works for normal, reduced, comfort
# active has no action
# external, standby no action
# holiday, scheduled and unscheduled
# activate, decativate comfort, eco
""" Set the target temperature for the target program
Parameters
----------
program : str
Can be normal, reduced or comfort
temperature: int
target temperature
Returns
-------
result: json
json representation of the answer
"""
return self.device.setProperty(f"heating.circuits.{self.circuit}.operating.programs.{program}",
"setTemperature", {'targetTemperature': float(temperature)})
def setReducedTemperature(self, temperature):
return self.setProgramTemperature("reduced", temperature)
def setComfortTemperature(self, temperature):
return self.setProgramTemperature("comfort", temperature)
def setNormalTemperature(self, temperature):
return self.setProgramTemperature("normal", temperature)
@handleNotSupported
def getActive(self):
return self.getProperty(f"heating.circuits.{self.circuit}")["properties"]["active"]["value"]
@handleNotSupported
def getName(self):
return self.getProperty(f"heating.circuits.{self.circuit}")["properties"]["name"]["value"]
@handleNotSupported
def getType(self):
return self.getProperty(f"heating.circuits.{self.circuit}")["properties"]["type"]["value"]
@handleNotSupported
def getActiveProgramMinTemperature(self):
active_program = self.getActiveProgram()
return self.getProgramMinTemperature(active_program)
@handleNotSupported
def getActiveProgramMaxTemperature(self):
active_program = self.getActiveProgram()
return self.getProgramMaxTemperature(active_program)
@handleNotSupported
def getActiveProgramStepping(self):
active_program = self.getActiveProgram()
return self.getProgramStepping(active_program)
@handleNotSupported
def getProgramMinTemperature(self, program: str):
if program in ['standby']:
return None
return self.getProperty(f"heating.circuits.{self.circuit}.operating.programs.{program}")[
"commands"]["setTemperature"]["params"]["targetTemperature"]["constraints"]["min"]
@handleNotSupported
def getProgramMaxTemperature(self, program: str):
if program in ['standby']:
return None
return self.getProperty(f"heating.circuits.{self.circuit}.operating.programs.{program}")[
"commands"]["setTemperature"]["params"]["targetTemperature"]["constraints"]["max"]
@handleNotSupported
def getProgramStepping(self, program: str):
if program in ['standby']:
return None
return self.getProperty(f"heating.circuits.{self.circuit}.operating.programs.{program}")[
"commands"]["setTemperature"]["params"]["targetTemperature"]["constraints"]["stepping"]
def activateProgram(self, program):
""" Activate a program
NOTE
DEVICE_COMMUNICATION_ERROR can just mean that the program is already on
Parameters
----------
program : str
Appears to work only for comfort
Returns
-------
result: json
json representation of the answer
"""
# optional temperature parameter could be passed (but not done)
return self.device.setProperty(f"heating.circuits.{self.circuit}.operating.programs.{program}", "activate",
{})
def activateComfort(self):
return self.activateProgram("comfort")
def deactivateProgram(self, program):
""" Deactivate a program
Parameters
----------
program : str
Appears to work only for comfort and eco (coming from normal, can be reached only by deactivating another state)
Returns
-------
result: json
json representation of the answer
"""
return self.device.setProperty(f"heating.circuits.{self.circuit}.operating.programs.{program}",
"deactivate", {})
def deactivateComfort(self):
return self.deactivateProgram("comfort")
@handleNotSupported
def getSupplyTemperature(self):
return \
self.getProperty(f"heating.circuits.{self.circuit}.sensors.temperature.supply")["properties"][
"value"]["value"]
@handleNotSupported
def getRoomTemperature(self):
return self.getProperty(f"heating.circuits.{self.circuit}.sensors.temperature.room")["properties"][
"value"]["value"]
@handleNotSupported
def getModes(self):
return \
self.getProperty(f"heating.circuits.{self.circuit}.operating.modes.active")["commands"]["setMode"][
"params"]["mode"]["constraints"]["enum"]
@handleNotSupported
def getActiveMode(self):
return \
self.getProperty(f"heating.circuits.{self.circuit}.operating.modes.active")["properties"]["value"][
"value"]
@handleNotSupported
def getHeatingCurveShift(self):
return self.getProperty(f"heating.circuits.{self.circuit}.heating.curve")["properties"]["shift"][
"value"]
@handleNotSupported
def getHeatingCurveShiftMin(self):
return self.getProperty(f"heating.circuits.{self.circuit}.heating.curve")["commands"]["setCurve"]["params"][
"shift"]["constraints"]["min"]
@handleNotSupported
def getHeatingCurveShiftMax(self):
return self.getProperty(f"heating.circuits.{self.circuit}.heating.curve")["commands"]["setCurve"]["params"][
"shift"]["constraints"]["max"]
@handleNotSupported
def getHeatingCurveShiftStepping(self):
return self.getProperty(f"heating.circuits.{self.circuit}.heating.curve")["commands"]["setCurve"]["params"][
"shift"]["constraints"]["stepping"]
@handleNotSupported
def getHeatingCurveSlope(self):
return self.getProperty(f"heating.circuits.{self.circuit}.heating.curve")["properties"]["slope"][
"value"]
@handleNotSupported
def getHeatingCurveSlopeMin(self):
return self.getProperty(f"heating.circuits.{self.circuit}.heating.curve")["commands"]["setCurve"]["params"][
"slope"]["constraints"]["min"]
@handleNotSupported
def getHeatingCurveSlopeMax(self):
return self.getProperty(f"heating.circuits.{self.circuit}.heating.curve")["commands"]["setCurve"]["params"][
"slope"]["constraints"]["max"]
@handleNotSupported
def getHeatingCurveSlopeStepping(self):
return self.getProperty(f"heating.circuits.{self.circuit}.heating.curve")["commands"]["setCurve"]["params"][
"slope"]["constraints"]["stepping"]
@handleAPICommandErrors
def setHeatingCurve(self, shift, slope):
return self.device.setProperty(f"heating.circuits.{self.circuit}.heating.curve", "setCurve",
{'shift': int(shift), 'slope': round(float(slope), 1)})
@handleNotSupported
def getActiveProgram(self):
return self.getProperty(f"heating.circuits.{self.circuit}.operating.programs.active")["properties"][
"value"]["value"]
@handleNotSupported
def getPrograms(self):
available_programs = []
for program in ['comfort', 'comfortCooling', 'comfortCoolingEnergySaving', 'comfortEnergySaving',
'comfortHeating', 'dhwPrecedence', 'eco', 'external', 'fixed', 'forcedLastFromSchedule',
'frostprotection', 'holiday', 'holidayAtHome', 'manual', 'normal', 'normalCooling',
'normalCoolingEnergySaving', 'normalEnergySaving', 'normalHeating', 'reduced', 'reducedCooling',
'reducedCoolingEnergySaving', 'reducedEnergySaving', 'reducedHeating', 'standby']:
with suppress(PyViCareNotSupportedFeatureError):
if self.getProperty(
f"heating.circuits.{self.circuit}.operating.programs.{program}") is not None:
available_programs.append(program)
return available_programs
@handleNotSupported
def getDesiredTemperatureForProgram(self, program):
return \
self.getProperty(f"heating.circuits.{self.circuit}.operating.programs.{program}")["properties"][
"temperature"]["value"]
@handleNotSupported
def getCurrentDesiredTemperature(self):
active_program = self.getActiveProgram()
if active_program in ['standby']:
return None
return self.getProperty(f"heating.circuits.{self.circuit}.operating.programs.{active_program}")[
"properties"]["temperature"]["value"]
@handleNotSupported
def getFrostProtectionActive(self):
status = self.getProperty(f"heating.circuits.{self.circuit}.frostprotection")[
"properties"]["status"]["value"]
return status == 'on'
@handleNotSupported
def getCirculationPumpActive(self):
status = self.getProperty(f"heating.circuits.{self.circuit}.circulation.pump")[
"properties"]["status"]["value"]
return status == 'on'
@handleNotSupported
def getTemperatureLevelsMin(self):
return self.getProperty(f"heating.circuits.{self.circuit}.temperature.levels")["properties"]["min"][
"value"]
@handleNotSupported
def getTemperatureLevelsMax(self):
return self.getProperty(f"heating.circuits.{self.circuit}.temperature.levels")["properties"]["max"][
"value"]
@handleNotSupported
def getHeatingSchedule(self):
properties = self.getProperty(
f"heating.circuits.{self.circuit}.heating.schedule")["properties"]
return {
"active": properties["active"]["value"],
"mon": properties["entries"]["value"]["mon"],
"tue": properties["entries"]["value"]["tue"],
"wed": properties["entries"]["value"]["wed"],
"thu": properties["entries"]["value"]["thu"],
"fri": properties["entries"]["value"]["fri"],
"sat": properties["entries"]["value"]["sat"],
"sun": properties["entries"]["value"]["sun"]
}
# Calculates target supply temperature based on data from Viessmann
# See: https://www.viessmann-community.com/t5/Gas/Mathematische-Formel-fuer-Vorlauftemperatur-aus-den-vier/m-p/68890#M27556
def getTargetSupplyTemperature(self) -> Optional[float]:
inside = None
outside = None
shift = None
slope = None
with suppress(PyViCareNotSupportedFeatureError):
inside = self.getCurrentDesiredTemperature()
outside = self.device.getOutsideTemperature()
shift = self.getHeatingCurveShift()
slope = self.getHeatingCurveSlope()
if not all_set([inside, outside, shift, slope]):
return None
max_value = None
min_value = None
with suppress(PyViCareNotSupportedFeatureError):
max_value = self.getTemperatureLevelsMax()
min_value = self.getTemperatureLevelsMin()
if outside is None or inside is None:
return None
delta_outside_inside = outside - inside
target_supply = self.device.get_heat_curve_formular()(delta_outside_inside, inside, shift, slope)
if all_set([min_value, max_value]):
target_supply = max(min_value, min(target_supply, max_value))
return float(round(target_supply, 1))
|