Skip to content

Commit

Permalink
Implement improvement suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
bouwew committed Dec 12, 2024
1 parent 47de0e2 commit 8bf113e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugwise/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion plugwise/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
MODULE_LOCATOR,
NONE,
OFF,
PRIORITY_DEVICE_CLASSES,
P1_MEASUREMENTS,
TEMP_CELSIUS,
THERMOSTAT_CLASSES,
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 8bf113e

Please sign in to comment.