Skip to content

Commit 9ce26bc

Browse files
committed
Remove all device_state related code
Will be handled via binary_sensors
1 parent b9a7ebd commit 9ce26bc

File tree

3 files changed

+2
-60
lines changed

3 files changed

+2
-60
lines changed

plugwise/helper.py

Lines changed: 0 additions & 37 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.

plugwise/smile.py

Lines changed: 2 additions & 13 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().
@@ -455,7 +445,6 @@ async def async_update(self):
455445
update_helper(
456446
data, self.gw_devices, dev_dict, dev_id, "sensors", key
457447
)
458-
device_state_updater(data, self.gw_devices, dev_id, dev_dict)
459448
if "switches" in dev_dict:
460449
for key, value in list(data.items()):
461450
update_helper(

tests/test_smile.py

Lines changed: 0 additions & 10 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": {
@@ -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)