Skip to content

Commit d477cf7

Browse files
authored
Merge pull request #238 from plugwise/adam-non-cool
Two small fixes
2 parents ed4acdb + a4a8883 commit d477cf7

File tree

5 files changed

+17
-10
lines changed

5 files changed

+17
-10
lines changed

CHANGELOG.md

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

3+
# v0.26.9: Hide cooling-related switch, binary_sensors when there is no cooling present
4+
- This fixes the unexpected appearance of new entities after the Adam 3.7.1 firmware-update
5+
- Properly handle an empty schedule, should fix #313
6+
37
# v0.25.8: Make collection of toggle-data future-proof
48

59
# v0.25.7: Correct faulty logic in the v0.25.6 release

plugwise/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Plugwise module."""
22

3-
__version__ = "0.25.8a0"
3+
__version__ = "0.25.9"
44

55
from plugwise.smile import Smile
66
from plugwise.stick import Stick

plugwise/helper.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,6 @@ def _presets(self, loc_id: str) -> dict[str, list[float]]:
792792
directives: etree = self._domain_objects.find(
793793
f'rule[@id="{rule_id}"]/directives'
794794
)
795-
796795
for directive in directives:
797796
preset = directive.find("then").attrib
798797
if "setpoint" in preset:
@@ -981,9 +980,11 @@ def _get_appliance_data(self, d_id: str) -> DeviceData:
981980
if all(item in data for item in ("cooling_ena_switch", "cooling_enabled")):
982981
data.pop("cooling_enabled")
983982

984-
# Don't show cooling_state when no cooling present
985-
if not self._cooling_present and "cooling_state" in data:
986-
data.pop("cooling_state")
983+
# Don't show cooling-related when no cooling present
984+
if not self._cooling_present:
985+
for item in ("cooling_state", "cooling_ena_switch", "cooling_enabled"):
986+
if item in data:
987+
data.pop(item)
987988

988989
return cast(DeviceData, data)
989990

@@ -1254,10 +1255,13 @@ def _schedules(
12541255
for rule_id, loc_id in rule_ids.items():
12551256
name = self._domain_objects.find(f'./rule[@id="{rule_id}"]/name').text
12561257
schedule: dict[str, list[float]] = {}
1258+
locator = f'./rule[@id="{rule_id}"]/directives'
1259+
# Show an empty schedule as no schedule found
1260+
if not (directives := self._domain_objects.find(locator)):
1261+
continue
1262+
12571263
# Only process the active schedule in detail for Adam or Anna with cooling
12581264
if self._cooling_present and loc_id != NONE:
1259-
locator = f'./rule[@id="{rule_id}"]/directives'
1260-
directives = self._domain_objects.find(locator)
12611265
for directive in directives:
12621266
entry = directive.find("then").attrib
12631267
if "setpoint" in entry:

tests/test_smile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ async def test_connect_anna_without_boiler_fw4(self):
13221322
"available": True,
13231323
"preset_modes": ["vacation", "no_frost", "asleep", "away", "home"],
13241324
"active_preset": "home",
1325-
"available_schedules": ["Test", "Normal"],
1325+
"available_schedules": ["Normal"],
13261326
"selected_schedule": "Normal",
13271327
"last_used": "Normal",
13281328
"mode": "auto",
@@ -1354,7 +1354,7 @@ async def test_connect_anna_without_boiler_fw4(self):
13541354
assert not self.notifications
13551355

13561356
result = await self.tinker_thermostat(
1357-
smile, "c34c6864216446528e95d88985e714cc", good_schedules=["Test", "Normal"]
1357+
smile, "c34c6864216446528e95d88985e714cc", good_schedules=["Normal"]
13581358
)
13591359
assert result
13601360
await smile.close_connection()

userdata/anna_without_boiler_fw4/core.domain_objects.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@
159159
<modified_date>2020-03-12T14:20:45.656+01:00</modified_date>
160160
<deleted_date></deleted_date>
161161
<directives>
162-
<when time="[mo 02:00,mo 02:00)"><then preset="home"/></when>
163162
</directives>
164163
<contexts>
165164
<context>

0 commit comments

Comments
 (0)