From b14f9e44d541eb7783bfd90679efb3bbb32dc13d Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Mon, 25 May 2026 12:39:43 +0200 Subject: [PATCH 1/7] Change P1 detection for Anna --- plugwise/__init__.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/plugwise/__init__.py b/plugwise/__init__.py index 9c4cd84dd..f45f6149c 100644 --- a/plugwise/__init__.py +++ b/plugwise/__init__.py @@ -198,15 +198,13 @@ async def _smile_detect( return # pragma: no cover model = vendor_model.text - elec_measurement = gateway.find( - "gateway_environment/electricity_consumption_tariff_structure" + elec_point_meters = result.findall( + "./location/logs/point_log/electricity_point_meter" ) - if ( - elec_measurement is not None - and elec_measurement.text - and model == "smile_thermo" - ): - self.smile.anna_p1 = True + for meter in elec_point_meters: + if meter.get("id") is not None and model == "smile_thermo": + self.smile.anna_p1 = True + break else: model = await self._smile_detect_legacy(result, dsmrmain, model) From 5e90a9b58871ef6e839b9f039ac666b9456216f8 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Mon, 25 May 2026 13:27:44 +0200 Subject: [PATCH 2/7] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d162271b2..cc12cd2cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Ongoing +- Correct Anna P1 detection via PR (#879)[https://github.com/plugwise/python-plugwise/pull/879] - Create an extra test-fixture for increased test coverage in the Integration via PR [#878](https://github.com/plugwise/python-plugwise/pull/878) - Add missing Emma firmware via PR [#863](https://github.com/plugwise/python-plugwise/pull/863) - Improve test function added in #860 via PR [#862](https://github.com/plugwise/python-plugwise/pull/862) From db0a61497792d68dcbb4fd6db680b27b60d19670 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Mon, 25 May 2026 13:31:44 +0200 Subject: [PATCH 3/7] Set to v1.11.4 release-version --- CHANGELOG.md | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc12cd2cf..03e87b1d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Ongoing +## v1.11.4 - Correct Anna P1 detection via PR (#879)[https://github.com/plugwise/python-plugwise/pull/879] - Create an extra test-fixture for increased test coverage in the Integration via PR [#878](https://github.com/plugwise/python-plugwise/pull/878) diff --git a/pyproject.toml b/pyproject.toml index a66c400a2..3333fa6f4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "plugwise" -version = "1.11.3" +version = "1.11.4" license = "MIT" description = "Plugwise Smile (Adam/Anna/P1) and Stretch module for Python 3." readme = "README.md" From 1074fc2aba2f10276464d926be70caa14b4b4785 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Mon, 25 May 2026 13:37:21 +0200 Subject: [PATCH 4/7] Correct typos --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03e87b1d8..a6746c458 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## v1.11.4 -- Correct Anna P1 detection via PR (#879)[https://github.com/plugwise/python-plugwise/pull/879] +- Correct Anna P1 detection via PR [#879](https://github.com/plugwise/python-plugwise/pull/879) - Create an extra test-fixture for increased test coverage in the Integration via PR [#878](https://github.com/plugwise/python-plugwise/pull/878) - Add missing Emma firmware via PR [#863](https://github.com/plugwise/python-plugwise/pull/863) - Improve test function added in #860 via PR [#862](https://github.com/plugwise/python-plugwise/pull/862) From ad900b012fb88a49b82aaef2fe63abdb1c7e674a Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Mon, 25 May 2026 16:50:31 +0200 Subject: [PATCH 5/7] Reduce complexity --- plugwise/__init__.py | 60 ++++++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/plugwise/__init__.py b/plugwise/__init__.py index f45f6149c..830cf08f6 100644 --- a/plugwise/__init__.py +++ b/plugwise/__init__.py @@ -187,7 +187,14 @@ async def _smile_detect( """Helper-function for connect(). Detect which type of Plugwise Gateway is being connected. + Store the collected data, also collect some specific thermostat devices. """ + model = await self._collect_smile_data(dsmrmain, result) + self._store_smile_data(model) + self._process_for_thermostat(result) + + async def _collect_smile_data(self, dsmrmain: etree.Element, result: etree.Element) -> str: + """Collect smile/gateway data.""" model: str = "Unknown" if (gateway := result.find("./gateway")) is not None: self.smile.version = parse(gateway.find("firmware_version").text) @@ -218,6 +225,35 @@ async def _smile_detect( ) raise UnsupportedDeviceError + return model + + def _process_for_thermostat(self, result: etree.Element) -> None: + """Extra processing for thermostats.""" + if self.smile.type != "thermostat": + return + + self._is_thermostat = True + # For Adam, Anna, determine the system capabilities: + # Find the connected heating/cooling device (heater_central), + # e.g. heat-pump or gas-fired heater + onoff_boiler = result.find("./module/protocols/onoff_boiler") + open_therm_boiler = result.find("./module/protocols/open_therm_boiler") + self._on_off_device = onoff_boiler is not None + self._opentherm_device = open_therm_boiler is not None + + # Determine the presence of special features + locator_1 = "./gateway/features/cooling" + locator_2 = "./gateway/features/elga_support" + if result.find(locator_1) is not None: + self._cooling_present = True + if result.find(locator_2) is not None: + self._elga = True + + def _store_smile_data(self, model: str) -> None: + """Store the collected the smile/gateway data. + + Perform some checks, and set a shorter timeout for non-legacy Gateways. + """ version_major = str(self.smile.version.major) self._target_smile = f"{model}_v{version_major}" LOGGER.debug("Plugwise identified as %s", self._target_smile) @@ -249,30 +285,6 @@ async def _smile_detect( if self.smile.type == "stretch": self._stretch_v2 = int(version_major) == 2 - self._process_for_thermostat(result) - - def _process_for_thermostat(self, result: etree.Element) -> None: - """Extra processing for thermostats.""" - if self.smile.type != "thermostat": - return - - self._is_thermostat = True - # For Adam, Anna, determine the system capabilities: - # Find the connected heating/cooling device (heater_central), - # e.g. heat-pump or gas-fired heater - onoff_boiler = result.find("./module/protocols/onoff_boiler") - open_therm_boiler = result.find("./module/protocols/open_therm_boiler") - self._on_off_device = onoff_boiler is not None - self._opentherm_device = open_therm_boiler is not None - - # Determine the presence of special features - locator_1 = "./gateway/features/cooling" - locator_2 = "./gateway/features/elga_support" - if result.find(locator_1) is not None: - self._cooling_present = True - if result.find(locator_2) is not None: - self._elga = True - async def _smile_detect_legacy( self, result: etree.Element, dsmrmain: etree.Element, model: str ) -> str: From f3992bf98228c68cf5f9173cd9c8a4be754d1044 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Mon, 25 May 2026 17:38:32 +0200 Subject: [PATCH 6/7] Correct function return --- plugwise/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugwise/__init__.py b/plugwise/__init__.py index 830cf08f6..64fa4c36e 100644 --- a/plugwise/__init__.py +++ b/plugwise/__init__.py @@ -193,7 +193,9 @@ async def _smile_detect( self._store_smile_data(model) self._process_for_thermostat(result) - async def _collect_smile_data(self, dsmrmain: etree.Element, result: etree.Element) -> str: + async def _collect_smile_data( + self, dsmrmain: etree.Element, result: etree.Element + ) -> str: """Collect smile/gateway data.""" model: str = "Unknown" if (gateway := result.find("./gateway")) is not None: @@ -201,10 +203,10 @@ async def _collect_smile_data(self, dsmrmain: etree.Element, result: etree.Eleme self.smile.hw_version = gateway.find("hardware_version").text self.smile.hostname = gateway.find("hostname").text self.smile.mac_address = gateway.find("mac_address").text - if (vendor_model := gateway.find("vendor_model")) is None: - return # pragma: no cover + if (vendor_model := gateway.find("vendor_model")) is not None: + model = vendor_model.text - model = vendor_model.text + # Check for Anna P1 function elec_point_meters = result.findall( "./location/logs/point_log/electricity_point_meter" ) From 6d5b83fed3c259840b477a93bf1478db0ddd61be Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Mon, 25 May 2026 17:40:46 +0200 Subject: [PATCH 7/7] Strengthen code as suggested --- plugwise/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugwise/__init__.py b/plugwise/__init__.py index 64fa4c36e..efe23dfd4 100644 --- a/plugwise/__init__.py +++ b/plugwise/__init__.py @@ -211,7 +211,7 @@ async def _collect_smile_data( "./location/logs/point_log/electricity_point_meter" ) for meter in elec_point_meters: - if meter.get("id") is not None and model == "smile_thermo": + if meter.get("id") and model == "smile_thermo": self.smile.anna_p1 = True break else: