From 39f6ecd488a7bcbe09db79d158833dc0467eff7d Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Sun, 21 Dec 2025 18:02:44 +0100 Subject: [PATCH 1/4] Improve detection of data missing This should happen after a reboot of the gateway --- plugwise/helper.py | 3 +++ plugwise/smile.py | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugwise/helper.py b/plugwise/helper.py index 371dd1613..4c09467df 100644 --- a/plugwise/helper.py +++ b/plugwise/helper.py @@ -205,6 +205,9 @@ def _get_locations(self) -> None: counter = 0 loc = Munch() locations = self._domain_objects.findall("./location") + if not locations: + raise KeyError("No location data present!") + for location in locations: loc.loc_id = location.get("id") loc.name = location.find("name").text diff --git a/plugwise/smile.py b/plugwise/smile.py index 61a042964..d6c10f826 100644 --- a/plugwise/smile.py +++ b/plugwise/smile.py @@ -137,8 +137,6 @@ async def async_update(self) -> dict[str, GwEntityData]: self._cooling_enabled = heat_cooler["binary_sensors"][ "cooling_enabled" ] - else: # cover failed data-retrieval for P1 - _ = self.gw_entities[self.gateway_id]["location"] except KeyError as err: raise DataMissingError("No Plugwise actual data received") from err From 85cc747d01a364fdc03fcd2f0125d2afa99aa5d2 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Mon, 22 Dec 2025 09:39:28 +0100 Subject: [PATCH 2/4] Legacy _all_... -> _get_... line up --- plugwise/legacy/helper.py | 6 +++--- plugwise/legacy/smile.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugwise/legacy/helper.py b/plugwise/legacy/helper.py index 3ec6d0632..18ef841a7 100644 --- a/plugwise/legacy/helper.py +++ b/plugwise/legacy/helper.py @@ -83,10 +83,10 @@ def item_count(self) -> int: """Return the item-count.""" return self._count - def _all_appliances(self) -> None: + def _get_appliances(self) -> None: """Collect all appliances with relevant info.""" self._count = 0 - self._all_locations() + self._get_locations() self._create_legacy_gateway() # For legacy P1 collect the connected SmartMeter info @@ -137,7 +137,7 @@ def _all_appliances(self) -> None: self._create_gw_entities(appl) self._reorder_devices() - def _all_locations(self) -> None: + def _get_locations(self) -> None: """Collect all locations.""" loc = Munch() diff --git a/plugwise/legacy/smile.py b/plugwise/legacy/smile.py index a841a1d1c..9b97f2501 100644 --- a/plugwise/legacy/smile.py +++ b/plugwise/legacy/smile.py @@ -81,7 +81,7 @@ def get_all_gateway_entities(self) -> None: Collect and add switching- and/or pump-group entities. Finally, collect the data and states for each entity. """ - self._all_appliances() + self._get_appliances() self._get_groups() self._all_entity_data() From 9ee6cc41f563cb3b701cc03c9e64267b7148804b Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Mon, 22 Dec 2025 09:47:22 +0100 Subject: [PATCH 3/4] Sort appl --- plugwise/helper.py | 8 ++++---- plugwise/legacy/helper.py | 25 +++++++++++++------------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/plugwise/helper.py b/plugwise/helper.py index 4c09467df..2bd16bf42 100644 --- a/plugwise/helper.py +++ b/plugwise/helper.py @@ -118,14 +118,14 @@ def _get_appliances(self) -> None: appl = Munch() appl.available = None appl.entity_id = appliance.get("id") + appl.firmware = None + appl.hardware = None appl.location = None - appl.name = appliance.find("name").text + appl.mac = None appl.model = None appl.model_id = None appl.module_id = None - appl.firmware = None - appl.hardware = None - appl.mac = None + appl.name = appliance.find("name").text appl.pwclass = appliance.find("type").text appl.zigbee_mac = None appl.vendor_name = None diff --git a/plugwise/legacy/helper.py b/plugwise/legacy/helper.py index 18ef841a7..4f3c806c3 100644 --- a/plugwise/legacy/helper.py +++ b/plugwise/legacy/helper.py @@ -99,6 +99,19 @@ def _get_appliances(self) -> None: for appliance in self._appliances.findall("./appliance"): appl = Munch() appl.pwclass = appliance.find("type").text + + appl.available = None + appl.entity_id = appliance.get("id") + appl.firmware = None + appl.hardware = None + appl.location = self._home_loc_id + appl.mac = None + appl.model = appl.pwclass.replace("_", " ").title() + appl.model_id = None + appl.name = appliance.find("name").text + appl.vendor_name = None + appl.zigbee_mac = None + # Skip thermostats that have this key, should be an orphaned device (Core #81712) if ( appl.pwclass == "thermostat" @@ -106,9 +119,6 @@ def _get_appliances(self) -> None: ): continue # pragma: no cover - appl.location = self._home_loc_id - appl.entity_id = appliance.get("id") - appl.name = appliance.find("name").text # Extend device_class name when a Circle/Stealth is type heater_central -- Pw-Beta Issue #739 if ( appl.pwclass == "heater_central" @@ -116,15 +126,6 @@ def _get_appliances(self) -> None: ): appl.pwclass = "heater_central_plug" - appl.model = appl.pwclass.replace("_", " ").title() - appl.available = None - appl.model_id = None - appl.firmware = None - appl.hardware = None - appl.mac = None - appl.zigbee_mac = None - appl.vendor_name = None - # Determine class for this appliance # Skip on heater_central when no active device present or on orphaned stretch devices if not (appl := self._appliance_info_finder(appliance, appl)): From 1a9ed04ab92b16826679edbd12772797332092ba Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Mon, 22 Dec 2025 09:55:23 +0100 Subject: [PATCH 4/4] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14e6bbfec..8f0031e6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Ongoing -- Code optimizations via PR [#837](https://github.com/plugwise/python-plugwise/pull/837), [#838](https://github.com/plugwise/python-plugwise/pull/838), [#839](https://github.com/plugwise/python-plugwise/pull/839) +- Code optimizations via PR [#837](https://github.com/plugwise/python-plugwise/pull/837), [#838](https://github.com/plugwise/python-plugwise/pull/838), [#839](https://github.com/plugwise/python-plugwise/pull/839), [#840](https://github.com/plugwise/python-plugwise/pull/840) ## v1.11.0