From 8bf113e0ee28622b5e531e1e8362949a2a95b9e3 Mon Sep 17 00:00:00 2001 From: Bouwe Westerdijk Date: Thu, 12 Dec 2024 13:44:28 +0100 Subject: [PATCH] Implement improvement suggestions --- plugwise/constants.py | 1 + plugwise/helper.py | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugwise/constants.py b/plugwise/constants.py index 63c6af3e9..232da091b 100644 --- a/plugwise/constants.py +++ b/plugwise/constants.py @@ -85,6 +85,7 @@ MODULE_LOCATOR: Final = "./logs/point_log/*[@id]" NONE: Final = "None" OFF: Final = "off" +PRIORITY_DEVICE_CLASSES = ("heater_central", "gateway") # XML data paths APPLIANCES: Final = "/core/appliances" diff --git a/plugwise/helper.py b/plugwise/helper.py index bcfa9bc5e..783aa9648 100644 --- a/plugwise/helper.py +++ b/plugwise/helper.py @@ -28,6 +28,7 @@ MODULE_LOCATOR, NONE, OFF, + PRIORITY_DEVICE_CLASSES, P1_MEASUREMENTS, TEMP_CELSIUS, THERMOSTAT_CLASSES, @@ -344,6 +345,8 @@ def _get_smartmeter_info(self) -> None: """For P1 collect the connected SmartMeter info from the Home/buildinglocation. There is no appliance available for this device. + Note: For P1 devices, we switch the gateway_id to the smartmeter device_id + to maintain backward compatibility with existing implementations. """ if self.smile_type == "power": self._p1_smartmeter_info_finder() @@ -356,7 +359,7 @@ def _get_smartmeter_info(self) -> None: def _sort_gw_entities(self) -> None: """Place the gateway and optional heater_central devices as 1st and 2nd.""" - for dev_class in ("heater_central", "gateway"): + for dev_class in PRIORITY_DEVICE_CLASSES: for entity_id, entity in dict(self.gw_entities).items(): if entity["dev_class"] == dev_class: priority_entity = entity