Skip to content

Commit dd3f45d

Browse files
authored
Merge pull request #324 from plugwise/loria
Loria-related fixes (as recently mentioned in plugwise-beta issue #301)
2 parents d4122b0 + 084490f commit dd3f45d

File tree

10 files changed

+424
-398
lines changed

10 files changed

+424
-398
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## v0.31.5: Cooling-related fix/improvements
4+
5+
- Fix cooling-related bug in set_temperature(), raise an error when the user tries to change the not-active setpoint
6+
- Change setpoint_low/_high generation, show the active setpoint and the related min/max values, don't show related setpoints in the active schedule
7+
- Update related test-assert / fixtures
8+
- Improve dhw_setpoint related code
9+
310
## v0.31.4: Improvements
411

512
- Improve fixture generation and manual fixtures, exposing (prettier-ed) fixtures

fixtures/adam_heatpump_cooling/all_data.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -418,14 +418,14 @@
418418
"selected_schedule": "Werkdag schema",
419419
"sensors": {
420420
"setpoint_high": 21.5,
421-
"setpoint_low": 18.0,
421+
"setpoint_low": 4.0,
422422
"temperature": 22.5
423423
},
424424
"thermostat": {
425425
"lower_bound": 1.0,
426426
"resolution": 0.01,
427427
"setpoint_high": 21.5,
428-
"setpoint_low": 18.0,
428+
"setpoint_low": 4.0,
429429
"upper_bound": 35.0
430430
},
431431
"vendor": "Plugwise"
@@ -478,14 +478,14 @@
478478
"sensors": {
479479
"battery": 53,
480480
"setpoint_high": 21.5,
481-
"setpoint_low": 18.0,
481+
"setpoint_low": 4.0,
482482
"temperature": 22.5
483483
},
484484
"thermostat": {
485485
"lower_bound": 0.0,
486486
"resolution": 0.01,
487487
"setpoint_high": 21.5,
488-
"setpoint_low": 18.0,
488+
"setpoint_low": 4.0,
489489
"upper_bound": 99.9
490490
},
491491
"vendor": "Plugwise",
@@ -508,14 +508,14 @@
508508
"selected_schedule": "Werkdag schema",
509509
"sensors": {
510510
"setpoint_high": 20.5,
511-
"setpoint_low": 18.0,
511+
"setpoint_low": 4.0,
512512
"temperature": 21.5
513513
},
514514
"thermostat": {
515515
"lower_bound": 0.0,
516516
"resolution": 0.01,
517517
"setpoint_high": 20.5,
518-
"setpoint_low": 18.0,
518+
"setpoint_low": 4.0,
519519
"upper_bound": 99.9
520520
},
521521
"vendor": "Plugwise",
@@ -538,14 +538,14 @@
538538
"selected_schedule": "Werkdag schema",
539539
"sensors": {
540540
"setpoint_high": 20.5,
541-
"setpoint_low": 18.0,
541+
"setpoint_low": 4.0,
542542
"temperature": 21.9
543543
},
544544
"thermostat": {
545545
"lower_bound": 0.0,
546546
"resolution": 0.01,
547547
"setpoint_high": 20.5,
548-
"setpoint_low": 18.0,
548+
"setpoint_low": 4.0,
549549
"upper_bound": 99.9
550550
},
551551
"vendor": "Plugwise",

fixtures/adam_onoff_cooling_fake_firmware/all_data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@
7575
"selected_schedule": "Werkdag schema",
7676
"sensors": {
7777
"setpoint_high": 21.5,
78-
"setpoint_low": 18.0,
78+
"setpoint_low": 4.0,
7979
"temperature": 22.5
8080
},
8181
"thermostat": {
8282
"lower_bound": 1.0,
8383
"resolution": 0.01,
8484
"setpoint_high": 21.5,
85-
"setpoint_low": 18.0,
85+
"setpoint_low": 4.0,
8686
"upper_bound": 35.0
8787
},
8888
"vendor": "Plugwise"

fixtures/anna_elga_2_cooling/all_data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@
5353
"cooling_deactivation_threshold": 3.0,
5454
"illuminance": 0.5,
5555
"setpoint_high": 23.0,
56-
"setpoint_low": 19.0,
56+
"setpoint_low": 4.0,
5757
"temperature": 24.9
5858
},
5959
"thermostat": {
6060
"lower_bound": 4.0,
6161
"resolution": 0.1,
6262
"setpoint_high": 23.0,
63-
"setpoint_low": 19.0,
63+
"setpoint_low": 4.0,
6464
"upper_bound": 30.0
6565
},
6666
"vendor": "Plugwise"

fixtures/anna_loria_cooling_active/all_data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
"sensors": {
1717
"illuminance": 45.0,
1818
"setpoint_high": 23.5,
19-
"setpoint_low": 19.5,
19+
"setpoint_low": 4.0,
2020
"temperature": 24.1
2121
},
2222
"thermostat": {
2323
"lower_bound": 4.0,
2424
"resolution": 0.1,
2525
"setpoint_high": 23.5,
26-
"setpoint_low": 19.5,
26+
"setpoint_low": 4.0,
2727
"upper_bound": 30.0
2828
},
2929
"vendor": "Plugwise"

fixtures/anna_loria_heating_idle/all_data.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
"selected_schedule": "Winter",
1616
"sensors": {
1717
"illuminance": 45.0,
18-
"setpoint_high": 25.5,
18+
"setpoint_high": 30.0,
1919
"setpoint_low": 20.5,
2020
"temperature": 22.1
2121
},
2222
"thermostat": {
2323
"lower_bound": 4.0,
2424
"resolution": 0.1,
25-
"setpoint_high": 25.5,
25+
"setpoint_high": 30.0,
2626
"setpoint_low": 20.5,
2727
"upper_bound": 30.0
2828
},

plugwise/__init__.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,13 @@ def update_for_cooling(self, device: DeviceData) -> DeviceData:
5858
if self._cooling_present:
5959
thermostat = device["thermostat"]
6060
sensors = device["sensors"]
61-
max_setpoint = MAX_SETPOINT
62-
min_setpoint = MIN_SETPOINT
63-
if device["selected_schedule"] != "None":
64-
max_setpoint = self._sched_setpoints[1]
65-
min_setpoint = self._sched_setpoints[0]
66-
6761
temp_dict: ActuatorData = {
6862
"setpoint_low": thermostat["setpoint"],
69-
"setpoint_high": max_setpoint,
63+
"setpoint_high": MAX_SETPOINT,
7064
}
7165
if self._cooling_enabled:
7266
temp_dict = {
73-
"setpoint_low": min_setpoint,
67+
"setpoint_low": MIN_SETPOINT,
7468
"setpoint_high": thermostat["setpoint"],
7569
}
7670
thermostat.pop("setpoint")
@@ -683,14 +677,26 @@ async def set_preset(self, loc_id: str, preset: str) -> None:
683677
async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
684678
"""Set the given Temperature on the relevant Thermostat."""
685679
setpoint: float | None = None
680+
686681
if "setpoint" in items:
687682
setpoint = items["setpoint"]
683+
688684
if self._cooling_present:
689-
if "setpoint_low" in items:
690-
setpoint = items["setpoint_low"]
691-
if self._cooling_active:
692-
if "setpoint_high" in items:
693-
setpoint = items["setpoint_high"]
685+
if "setpoint_high" in items:
686+
tmp_setpoint_high = items["setpoint_high"]
687+
tmp_setpoint_low = items["setpoint_low"]
688+
if self._cooling_enabled: # in cooling mode
689+
setpoint = tmp_setpoint_high
690+
if tmp_setpoint_low != MIN_SETPOINT:
691+
raise PlugwiseError(
692+
"Plugwise: heating setpoint cannot be changed when in cooling mode!"
693+
)
694+
else: # in heating mode
695+
setpoint = tmp_setpoint_low
696+
if tmp_setpoint_high != MAX_SETPOINT:
697+
raise PlugwiseError(
698+
"Plugwise: cooling setpoint cannot be changed when in heating mode!"
699+
)
694700

695701
if setpoint is None:
696702
raise PlugwiseError(

plugwise/helper.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,16 +1020,14 @@ def _get_appliance_data(self, d_id: str) -> DeviceData:
10201020
if d_id == self._heater_id and self.smile_name == "Smile Anna":
10211021
# Anna+Elga: base cooling_state on the elga-status-code
10221022
if "elga_status_code" in data:
1023-
data["cooling_state"] = self._cooling_active = (
1024-
data["elga_status_code"] == 8
1025-
)
1026-
data.pop("elga_status_code", None)
1027-
10281023
# Determine _cooling_present and _cooling_enabled
10291024
if "cooling_enabled" in data and data["cooling_enabled"]:
10301025
self._cooling_present = self._cooling_enabled = True
10311026
data["model"] = "Generic heater/cooler"
1032-
1027+
data["cooling_state"] = self._cooling_active = (
1028+
data["elga_status_code"] == 8
1029+
)
1030+
data.pop("elga_status_code", None)
10331031
# Elga has no cooling-switch
10341032
if "cooling_ena_switch" in data:
10351033
data.pop("cooling_ena_switch")
@@ -1040,6 +1038,10 @@ def _get_appliance_data(self, d_id: str) -> DeviceData:
10401038
if self._cooling_present and "cooling_state" in data:
10411039
self._cooling_enabled = data["cooling_state"]
10421040
self._cooling_active = data["modulation_level"] == 100
1041+
# For Loria the above does not work (pw-beta issue #301)
1042+
if "cooling_ena_switch" in data:
1043+
self._cooling_enabled = data["cooling_ena_switch"]
1044+
self._cooling_active = data["cooling_state"]
10431045

10441046
self._cleanup_data(data)
10451047

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "plugwise"
7-
version = "0.31.4"
7+
version = "0.31.5"
88
license = {file = "LICENSE"}
99
description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3."
1010
readme = "README.md"

0 commit comments

Comments
 (0)