|
25 | 25 | BINARY_SENSORS, |
26 | 26 | DATA, |
27 | 27 | DAYS, |
| 28 | + DEFAULT_PW_MAX, |
| 29 | + DEFAULT_PW_MIN, |
28 | 30 | DEVICE_MEASUREMENTS, |
29 | 31 | ENERGY_KILO_WATT_HOUR, |
30 | 32 | ENERGY_WATT_HOUR, |
@@ -794,16 +796,21 @@ def _presets(self, loc_id: str) -> dict[str, list[float]]: |
794 | 796 |
|
795 | 797 | for directive in directives: |
796 | 798 | preset = directive.find("then").attrib |
797 | | - keys, dummy = zip(*preset.items()) |
798 | | - if str(keys[0]) == "setpoint": |
799 | | - presets[directive.attrib["preset"]] = [ |
800 | | - float(preset.get("setpoint")), |
801 | | - 0, |
802 | | - ] |
| 799 | + if "setpoint" in preset: |
| 800 | + if not self._cooling_present or self._cooling_enabled: |
| 801 | + presets[directive.attrib["preset"]] = [ |
| 802 | + float(preset["setpoint"]), |
| 803 | + DEFAULT_PW_MIN, |
| 804 | + ] |
| 805 | + else: |
| 806 | + presets[directive.attrib["preset"]] = [ # pragma: no cover |
| 807 | + float(preset["setpoint"]), |
| 808 | + DEFAULT_PW_MAX, |
| 809 | + ] |
803 | 810 | else: |
804 | 811 | presets[directive.attrib["preset"]] = [ |
805 | | - float(preset.get("heating_setpoint")), |
806 | | - float(preset.get("cooling_setpoint")), |
| 812 | + float(preset["heating_setpoint"]), |
| 813 | + float(preset["cooling_setpoint"]), |
807 | 814 | ] |
808 | 815 |
|
809 | 816 | return presets |
@@ -1241,14 +1248,24 @@ def _schedules( |
1241 | 1248 | for rule_id, loc_id in rule_ids.items(): |
1242 | 1249 | name = self._domain_objects.find(f'./rule[@id="{rule_id}"]/name').text |
1243 | 1250 | schedule: dict[str, list[float]] = {} |
1244 | | - # Only process the active schedule in detail for Anna with cooling |
| 1251 | + # Only process the active schedule in detail for Adam or Anna with cooling |
1245 | 1252 | if self._cooling_present and loc_id != NONE: |
1246 | 1253 | locator = f'./rule[@id="{rule_id}"]/directives' |
1247 | 1254 | directives = self._domain_objects.find(locator) |
1248 | 1255 | for directive in directives: |
1249 | 1256 | entry = directive.find("then").attrib |
1250 | | - keys, dummy = zip(*entry.items()) |
1251 | | - if str(keys[0]) == "preset": |
| 1257 | + if "setpoint" in entry: |
| 1258 | + if not self._cooling_present or self._cooling_enabled: |
| 1259 | + schedule[directive.attrib["time"]] = [ |
| 1260 | + float(entry["setpoint"]), |
| 1261 | + DEFAULT_PW_MIN, |
| 1262 | + ] |
| 1263 | + else: |
| 1264 | + schedule[directive.attrib["time"]] = [ |
| 1265 | + float(entry["setpoint"]), |
| 1266 | + DEFAULT_PW_MAX, |
| 1267 | + ] |
| 1268 | + elif "preset" in entry: |
1252 | 1269 | schedule[directive.attrib["time"]] = [ |
1253 | 1270 | float(self._presets(loc_id)[entry["preset"]][0]), |
1254 | 1271 | float(self._presets(loc_id)[entry["preset"]][1]), |
|
0 commit comments