Skip to content

Commit c251838

Browse files
authored
Merge pull request #134 from plugwise/pre_16_3
Implement feedback from Core devs
2 parents 96f2963 + e44cb28 commit c251838

File tree

4 files changed

+10
-74
lines changed

4 files changed

+10
-74
lines changed

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.16.2"
3+
__version__ = "0.16.3"
44

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

plugwise/helper.py

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -59,43 +59,6 @@
5959
}
6060

6161

62-
def device_state_updater(data, devs, d_id, d_dict):
63-
"""Helper-function for async_update().
64-
Update the Device_State sensor state.
65-
"""
66-
for item in d_dict["sensors"]:
67-
if item == "device_state":
68-
result = update_device_state(data, d_dict)
69-
devs[d_id]["sensors"][item] = result
70-
71-
72-
def update_device_state(data, d_dict):
73-
"""Helper-function for _device_state_updater()."""
74-
_cooling_state = False
75-
_dhw_state = False
76-
_heating_state = False
77-
result = "idle"
78-
79-
if "binary_sensors" in d_dict:
80-
for item, state in d_dict["binary_sensors"].items():
81-
if item == "dhw_state" and state:
82-
result = "dhw-heating"
83-
_dhw_state = True
84-
85-
if "heating_state" in data and data["heating_state"]:
86-
result = "heating"
87-
_heating_state = True
88-
if _heating_state and _dhw_state:
89-
result = "dhw and heating"
90-
if "cooling_state" in data and data["cooling_state"]:
91-
result = "cooling"
92-
_cooling_state = True
93-
if _cooling_state and _dhw_state:
94-
result = "dhw and cooling"
95-
96-
return result
97-
98-
9962
def pw_notification_updater(devs, d_id, d_dict, notifs):
10063
"""Helper-function for async_update().
10164
Update the PW_Notification binary_sensor state.
@@ -1168,7 +1131,7 @@ def _schemas(self, location):
11681131
self._last_active[location] = selected
11691132
schedules[name] = schedule
11701133
else:
1171-
_LOGGER.error(
1134+
_LOGGER.debug(
11721135
"Schedule %s has no preset switching moments, ignoring.", name
11731136
)
11741137

plugwise/smile.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
DEFAULT_PORT,
1717
DEFAULT_TIMEOUT,
1818
DEFAULT_USERNAME,
19-
DEVICE_STATE,
2019
DOMAIN_OBJECTS,
2120
LOCATIONS,
2221
MODULES,
@@ -30,13 +29,7 @@
3029
THERMOSTAT_CLASSES,
3130
)
3231
from .exceptions import ConnectionFailedError, InvalidXMLError, UnsupportedDeviceError
33-
from .helper import (
34-
SmileComm,
35-
SmileHelper,
36-
device_state_updater,
37-
pw_notification_updater,
38-
update_helper,
39-
)
32+
from .helper import SmileComm, SmileHelper, pw_notification_updater, update_helper
4033

4134
_LOGGER = logging.getLogger(__name__)
4235

@@ -46,14 +39,11 @@ class SmileData(SmileHelper):
4639

4740
def _append_special(self, data, d_id, bs_dict, s_dict):
4841
"""Helper-function for smile.py: _all_device_data().
49-
When conditions are met, the plugwise_notification binary_sensor
50-
and/or the device_state sensor are appended.
42+
When conditions are met, the plugwise_notification binary_sensor is appended.
5143
"""
5244
if d_id == self.gateway_id:
5345
if self._sm_thermostat is not None:
5446
bs_dict.update(PW_NOTIFICATION)
55-
if d_id == self._heater_id and self._sm_thermostat is not None:
56-
s_dict.update(DEVICE_STATE)
5747

5848
def _all_device_data(self):
5949
"""Helper-function for get_all_devices().
@@ -171,20 +161,16 @@ def _device_data_climate(self, details, device_data):
171161
else:
172162
device_data["last_used"] = last_active
173163

174-
# Operation mode: auto, heat, cool, off
164+
# Operation mode: auto, heat, cool
175165
device_data["mode"] = "auto"
176166
schedule_status = False
177167
if sel_schema != "None":
178168
schedule_status = True
179169
if not schedule_status:
180-
# Mimic HomeKit behavior
181-
if self._preset(loc_id) == "away":
182-
device_data["mode"] = "off" # pragma: no cover
183-
else:
184-
device_data["mode"] = "heat"
185-
if self._heater_id is not None:
186-
if self.cooling_active:
187-
device_data["mode"] = "cool"
170+
device_data["mode"] = "heat"
171+
if self._heater_id is not None:
172+
if self.cooling_active:
173+
device_data["mode"] = "cool"
188174

189175
# Control_state
190176
if ctrl_state := self._control_state(loc_id):
@@ -459,7 +445,6 @@ async def async_update(self):
459445
update_helper(
460446
data, self.gw_devices, dev_dict, dev_id, "sensors", key
461447
)
462-
device_state_updater(data, self.gw_devices, dev_id, dev_dict)
463448
if "switches" in dev_dict:
464449
for key, value in list(data.items()):
465450
update_helper(
@@ -622,8 +607,6 @@ async def set_switch_state(self, appl_id, members, model, state):
622607
# Don't bother switching a relay when the corresponding lock-state is true
623608
if lock_state == "true":
624609
return False
625-
await self._request(uri, method="put", data=data)
626-
return True
627610

628611
await self._request(uri, method="put", data=data)
629612
return True

tests/test_smile.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ async def test_connect_legacy_anna(self):
615615
"modulation_level": 0.0,
616616
"return_temperature": 21.7,
617617
"water_pressure": 1.2,
618-
"device_state": "heating",
619618
},
620619
},
621620
# Gateway
@@ -715,7 +714,6 @@ async def test_connect_legacy_anna_2(self):
715714
"modulation_level": 0.0,
716715
"return_temperature": 0.0,
717716
"water_pressure": 1.7,
718-
"device_state": "idle",
719717
},
720718
},
721719
# Gateway
@@ -906,7 +904,6 @@ async def test_connect_anna_v4(self):
906904
"modulation_level": 0.0,
907905
"return_temperature": 42.0,
908906
"water_pressure": 2.1,
909-
"device_state": "heating",
910907
},
911908
"switches": {"dhw_cm_switch": False},
912909
},
@@ -1116,7 +1113,6 @@ async def test_connect_anna_without_boiler_fw42(self):
11161113
"vendor": None,
11171114
"heating_state": True,
11181115
"cooling_active": False,
1119-
"sensors": {"device_state": "heating"},
11201116
},
11211117
# Anna
11221118
"7ffbb3ab4b6c4ab2915d7510f7bf8fe9": {
@@ -1395,7 +1391,6 @@ async def test_connect_adam_plus_anna_new(self):
13951391
"sensors": {
13961392
"water_temperature": 37.0,
13971393
"intended_boiler_temperature": 38.1,
1398-
"device_state": "heating",
13991394
},
14001395
"switches": {"dhw_cm_switch": False},
14011396
},
@@ -1460,7 +1455,6 @@ async def test_connect_adam_plus_anna_new_copy_dhw_and_heating(self):
14601455
"2743216f626f43948deec1f7ab3b3d70": {
14611456
"binary_sensors": {"dhw_state": True},
14621457
"heating_state": True,
1463-
"sensors": {"device_state": "dhw and heating"},
14641458
},
14651459
# Lisa Badkamer
14661460
"453e510de7cb47af8ec5b44fbf40cbe5": {
@@ -1483,7 +1477,6 @@ async def test_connect_adam_plus_anna_new_copy_cooling(self):
14831477
# Central
14841478
"2743216f626f43948deec1f7ab3b3d70": {
14851479
"cooling_state": True,
1486-
"sensors": {"device_state": "cooling"},
14871480
},
14881481
}
14891482

@@ -1503,7 +1496,6 @@ async def test_connect_adam_plus_anna_new_copy_dhw_and_cooling(self):
15031496
"2743216f626f43948deec1f7ab3b3d70": {
15041497
"binary_sensors": {"dhw_state": True},
15051498
"cooling_state": True,
1506-
"sensors": {"device_state": "dhw and cooling"},
15071499
}
15081500
}
15091501

@@ -1521,7 +1513,6 @@ async def test_connect_adam_zone_per_device(self):
15211513
testdata = {
15221514
"90986d591dcd426cae3ec3e8111ff730": {
15231515
"heating_state": False,
1524-
"sensors": {"device_state": "idle"},
15251516
},
15261517
# Lisa WK
15271518
"b59bcebaf94b499ea7d46e4a66fb62d8": {
@@ -1652,7 +1643,7 @@ async def test_connect_adam_multiple_devices_per_zone(self):
16521643
"selected_schedule": "None",
16531644
"schedule_temperature": 15.0,
16541645
"last_used": "Badkamer Schema",
1655-
"mode": "off",
1646+
"mode": "heat",
16561647
"sensors": {"temperature": 16.5, "setpoint": 13.0, "battery": 67},
16571648
},
16581649
"b310b72a0e354bfab43089919b9a88bf": {
@@ -1781,7 +1772,6 @@ async def test_connect_adam_multiple_devices_per_zone(self):
17811772
"water_temperature": 70.0,
17821773
"intended_boiler_temperature": 70.0,
17831774
"modulation_level": 1,
1784-
"device_state": "heating",
17851775
},
17861776
},
17871777
"cd0ddb54ef694e11ac18ed1cbce5dbbd": {

0 commit comments

Comments
 (0)