From cc6b6235af1270219f0b543bdde6f9797839e6d9 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Tue, 4 Jan 2022 19:39:14 +0100 Subject: [PATCH 001/193] Change active_device detection Distinguish between an OpenTherm and an On-Off-device --- plugwise/helper.py | 29 +++++++++++++++++++---------- plugwise/smile.py | 14 +++++++------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/plugwise/helper.py b/plugwise/helper.py index 781e9ca2c..fa963b442 100644 --- a/plugwise/helper.py +++ b/plugwise/helper.py @@ -468,7 +468,14 @@ def _appliance_info_finder(self, appliance, appl): if appl.pwclass == "heater_central": # Remove heater_central when no active device present - if not self._active_device_present: + if self._on_off_device: + appl.name = "On_Off" + appl.v_name = None + appl.model = "Unknown" + + return appl + + if not self._ot_device and not self._on_off_device: return None self._heater_id = appliance.attrib["id"] @@ -483,7 +490,9 @@ def _appliance_info_finder(self, appliance, appl): appl.model = check_model(module_data[1], appl.v_name) if appl.model is None: appl.model = ( - "Generic heater/cooler" if self._cp_state else "Generic heater" + "Generic heater/cooler" + if self._cooling_present + else "Generic heater" ) return appl @@ -566,14 +575,14 @@ def _all_appliances(self): } # The presence of either indicates a local active device, e.g. heat-pump or gas-fired heater - self._cp_state = self._appliances.find( - ".//logs/point_log[type='compressor_state']" + ch_state = self._appliances.find( + ".//logs/point_log[type='central_heating_state']" ) - fl_state = self._appliances.find(".//logs/point_log[type='flame_state']") - bl_state = self._appliances.find(".//services/boiler_state") - self._active_device_present = ( - self._cp_state is not None or fl_state is not None or bl_state is not None + ot_fault_code = self._appliances.find( + ".//logs/point_log[type='open_therm_oem_fault_code']" ) + self._ot_device = ch_state is not None and ot_fault_code is not None + self._on_off_device = ch_state is not None and ot_fault_code is None for appliance in self._appliances.findall("./appliance"): appl = Munch() @@ -760,7 +769,7 @@ def _get_appliance_data(self, d_id): appliance = self._appliances.find(f'.//appliance[@id="{d_id}"]') measurements = DEVICE_MEASUREMENTS.items() - if self._active_device_present: + if self._ot_device: measurements = { **DEVICE_MEASUREMENTS, **HEATER_CENTRAL_MEASUREMENTS, @@ -1183,7 +1192,7 @@ def _create_dicts_from_data(self, data, bs_dict, s_dict, sw_dict): for item in BINARY_SENSORS: if list(item.keys())[0] == key: data.pop(key) - if self._active_device_present: + if self._ot_device: bs_dict[key] = value for item in SENSORS: if list(item.keys())[0] == key: diff --git a/plugwise/smile.py b/plugwise/smile.py index a0b200ae4..9854a0922 100644 --- a/plugwise/smile.py +++ b/plugwise/smile.py @@ -54,7 +54,9 @@ def _append_special(self, data, d_id, bs_dict, s_dict): if d_id == self.gateway_id: if self._sm_thermostat is not None: bs_dict.update(PW_NOTIFICATION) - if not self._active_device_present and "heating_state" in data: + if ( + not self._ot_device and not self._on_off_device + ) and "heating_state" in data: s_dict.update(DEVICE_STATE) if d_id == self._heater_id and self._sm_thermostat is not None: s_dict.update(DEVICE_STATE) @@ -83,7 +85,7 @@ def _all_device_data(self): self.gw_devices[dev_id] = dev_and_data - self.gw_data["active_device"] = self._active_device_present + self.gw_data["active_device"] = self._ot_device or self._on_off_device self.gw_data["cooling_present"] = self._cooling_present self.gw_data["gateway_id"] = self.gateway_id self.gw_data["heater_id"] = self._heater_id @@ -142,10 +144,7 @@ def _device_data_adam(self, details, device_data): if self.smile_name == "Adam": # Indicate heating_state based on valves being open in case of city-provided heating if details["class"] == "gateway": - if ( - not self._active_device_present - and self._heating_valves() is not None - ): + if self._on_off_device and self._heating_valves() is not None: device_data["heating_state"] = True if self._heating_valves() == 0: device_data["heating_state"] = False @@ -258,7 +257,8 @@ def __init__( websession, ) - self._active_device_present = False + self._on_off_device = False + self._ot_device = False self._appliances = None self._appl_data = None self._cooling_present = False From 1a65e8ed37c694b4987617e6579ae4f26eed6f22 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Tue, 4 Jan 2022 19:47:13 +0100 Subject: [PATCH 002/193] Fix two active_device asserts --- tests/test_smile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_smile.py b/tests/test_smile.py index 34f72f5a0..66f3819be 100644 --- a/tests/test_smile.py +++ b/tests/test_smile.py @@ -916,7 +916,7 @@ async def test_connect_anna_without_boiler_fw3(self): await self.device_test(smile, testdata) _LOGGER.info(" # Assert master thermostat") assert smile._sm_thermostat - assert not self.active_device_present + assert self.active_device_present assert not self.notifications await self.tinker_thermostat( @@ -974,7 +974,7 @@ async def test_connect_anna_without_boiler_fw4(self): await self.device_test(smile, testdata) _LOGGER.info(" # Assert master thermostat") assert smile._sm_thermostat - assert not self.active_device_present + assert self.active_device_present assert not self.notifications await self.tinker_thermostat( From 4426e5d2d46c4edc8d0cdd697f9b579934bc1584 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Tue, 4 Jan 2022 19:54:12 +0100 Subject: [PATCH 003/193] Try increase scope --- plugwise/helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugwise/helper.py b/plugwise/helper.py index fa963b442..8a0c64738 100644 --- a/plugwise/helper.py +++ b/plugwise/helper.py @@ -769,7 +769,7 @@ def _get_appliance_data(self, d_id): appliance = self._appliances.find(f'.//appliance[@id="{d_id}"]') measurements = DEVICE_MEASUREMENTS.items() - if self._ot_device: + if self._ot_device or self._on_off_device: measurements = { **DEVICE_MEASUREMENTS, **HEATER_CENTRAL_MEASUREMENTS, @@ -1192,7 +1192,7 @@ def _create_dicts_from_data(self, data, bs_dict, s_dict, sw_dict): for item in BINARY_SENSORS: if list(item.keys())[0] == key: data.pop(key) - if self._ot_device: + if self._ot_device or self._on_off_device: bs_dict[key] = value for item in SENSORS: if list(item.keys())[0] == key: From dd1f694458b684b86f5bfd1f0ffc0595752d4946 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Tue, 4 Jan 2022 19:57:22 +0100 Subject: [PATCH 004/193] Fix ident and comments --- plugwise/helper.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugwise/helper.py b/plugwise/helper.py index 8a0c64738..f423047b6 100644 --- a/plugwise/helper.py +++ b/plugwise/helper.py @@ -467,14 +467,15 @@ def _appliance_info_finder(self, appliance, appl): return appl if appl.pwclass == "heater_central": - # Remove heater_central when no active device present + # Provide info for On-Off device if self._on_off_device: appl.name = "On_Off" appl.v_name = None appl.model = "Unknown" - return appl + return appl + # Remove heater_central when no active device present if not self._ot_device and not self._on_off_device: return None From 6698e7bc80206ca627bf4d6633c3ef35d2752fa9 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Tue, 4 Jan 2022 19:58:45 +0100 Subject: [PATCH 005/193] Fix two more active_device asserts --- tests/test_smile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_smile.py b/tests/test_smile.py index 66f3819be..ce1e9b3ea 100644 --- a/tests/test_smile.py +++ b/tests/test_smile.py @@ -1253,7 +1253,7 @@ async def test_connect_adam_zone_per_device(self): await self.device_test(smile, testdata) _LOGGER.info(" # Assert master thermostat") assert not smile._sm_thermostat - assert not self.active_device_present + assert self.active_device_present assert "af82e4ccf9c548528166d38e560662a4" in self.notifications await smile.delete_notification() @@ -1357,7 +1357,7 @@ async def test_connect_adam_multiple_devices_per_zone(self): await self.device_test(smile, testdata) _LOGGER.info(" # Assert master thermostat") assert not smile._sm_thermostat - assert not self.active_device_present + assert self.active_device_present assert "af82e4ccf9c548528166d38e560662a4" in self.notifications From 979b27b9a0c3212154dbe7b7959b04068388c300 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Tue, 4 Jan 2022 20:05:01 +0100 Subject: [PATCH 006/193] Bump to v0.16.1a0 --- plugwise/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugwise/__init__.py b/plugwise/__init__.py index 3b2e0f2cc..69fefc785 100644 --- a/plugwise/__init__.py +++ b/plugwise/__init__.py @@ -1,6 +1,6 @@ """Plugwise module.""" -__version__ = "0.16.0" +__version__ = "0.16.1a0" from plugwise.smile import Smile from plugwise.stick import Stick From bc9d1b53a0d8471610c3545f46dbc9416e1da305 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Tue, 4 Jan 2022 20:52:21 +0100 Subject: [PATCH 007/193] Add missing _heater_id for on-off device --- plugwise/helper.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugwise/helper.py b/plugwise/helper.py index f423047b6..f095dbebc 100644 --- a/plugwise/helper.py +++ b/plugwise/helper.py @@ -469,6 +469,7 @@ def _appliance_info_finder(self, appliance, appl): if appl.pwclass == "heater_central": # Provide info for On-Off device if self._on_off_device: + self._heater_id = appliance.attrib["id"] appl.name = "On_Off" appl.v_name = None appl.model = "Unknown" From 8c49ba5b277f51ab7a79603f3a844f795ad5c916 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Tue, 4 Jan 2022 20:53:47 +0100 Subject: [PATCH 008/193] Bump to a1 --- plugwise/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugwise/__init__.py b/plugwise/__init__.py index 69fefc785..29a7ec438 100644 --- a/plugwise/__init__.py +++ b/plugwise/__init__.py @@ -1,6 +1,6 @@ """Plugwise module.""" -__version__ = "0.16.1a0" +__version__ = "0.16.1a1" from plugwise.smile import Smile from plugwise.stick import Stick From 681fcff31734c2b00b9437e0a24bee73a59efde4 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Sun, 2 Jan 2022 19:26:37 +0100 Subject: [PATCH 009/193] Selected should always be a string --- plugwise/helper.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugwise/helper.py b/plugwise/helper.py index f095dbebc..ce5e53d25 100644 --- a/plugwise/helper.py +++ b/plugwise/helper.py @@ -1061,7 +1061,7 @@ def _schemas_legacy(self): name = None schedule_temperature = None schemas = {} - selected = None + selected = "None" for schema in self._domain_objects.findall(".//rule"): if rule_name := schema.find("name").text: @@ -1088,7 +1088,7 @@ def _schemas(self, loc_id): rule_ids = {} schemas = {} schedule_temperature = None - selected = None + selected = "None" # Legacy schemas if self._smile_legacy: # Only one schedule allowed From e90d23a18aaba5588e3be14fc8cf4484a9ef2ea9 Mon Sep 17 00:00:00 2001 From: Bouwe Date: Sun, 2 Jan 2022 19:43:20 +0100 Subject: [PATCH 010/193] Update userdata to match the assert to add --- userdata/legacy_anna_2/core.domain_objects.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/userdata/legacy_anna_2/core.domain_objects.xml b/userdata/legacy_anna_2/core.domain_objects.xml index 16f2bcb40..ccfbf0fcd 100644 --- a/userdata/legacy_anna_2/core.domain_objects.xml +++ b/userdata/legacy_anna_2/core.domain_objects.xml @@ -138,7 +138,7 @@ 2020-04-09T10:58:36.690+02:00 - on + off @@ -1020,7 +1020,7 @@ Thermostat schedule Provides a week schedule for a Thermostat.