Skip to content

Commit 40f60ad

Browse files
committed
Add Smile/Legacy property gateway_id
1 parent 42bcfe8 commit 40f60ad

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

plugwise/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def cooling_present(self) -> bool:
9191
@property
9292
def gateway_id(self) -> str:
9393
"""Return the gateway-id."""
94-
return self._smile_props["gateway_id"]
94+
return self._smile_api.gateway_id
9595

9696
@property
9797
def heater_id(self) -> str:

plugwise/helper.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ def __init__(self) -> None:
9191
self.smile_model_id: str | None
9292
self.smile_version: version.Version
9393

94+
@property
95+
def gateway_id(self) -> str:
96+
"""Return the gateway-id."""
97+
return self._gateway_id
98+
9499
def _all_appliances(self) -> None:
95100
"""Collect all appliances with relevant info.
96101

plugwise/legacy/helper.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(self) -> None:
6666
"""Set the constructor for this class."""
6767
super().__init__()
6868
self._appliances: etree.Element
69+
self._gateway_id: str = NONE
6970
self._is_thermostat: bool
7071
self._loc_data: dict[str, ThermoLoc]
7172
self._locations: etree.Element
@@ -77,6 +78,11 @@ def __init__(self) -> None:
7778
self.smile_version: Version
7879
self.smile_zigbee_mac_address: str | None
7980

81+
@property
82+
def gateway_id(self) -> str:
83+
"""Return the gateway-id."""
84+
return self._gateway_id
85+
8086
def _all_appliances(self) -> None:
8187
"""Collect all appliances with relevant info."""
8288
self._count = 0
@@ -173,11 +179,11 @@ def _create_legacy_gateway(self) -> None:
173179
174180
Use the home_location or FAKE_APPL as entity id.
175181
"""
176-
self.gateway_id = self._home_loc_id
182+
self._gateway_id = self._home_loc_id
177183
if self.smile_type == "power":
178-
self.gateway_id = FAKE_APPL
184+
self._gateway_id = FAKE_APPL
179185

180-
self.gw_entities[self.gateway_id] = {"dev_class": "gateway"}
186+
self.gw_entities[self._gateway_id] = {"dev_class": "gateway"}
181187
self._count += 1
182188
for key, value in {
183189
"firmware": str(self.smile_version),
@@ -190,7 +196,7 @@ def _create_legacy_gateway(self) -> None:
190196
}.items():
191197
if value is not None:
192198
gw_key = cast(ApplianceType, key)
193-
self.gw_entities[self.gateway_id][gw_key] = value
199+
self.gw_entities[self._gateway_id][gw_key] = value
194200
self._count += 1
195201

196202
def _appliance_info_finder(self, appliance: etree, appl: Munch) -> Munch:
@@ -282,7 +288,7 @@ def _get_measurement_data(self, entity_id: str) -> GwEntityData:
282288

283289
# Anna: the Smile outdoor_temperature is present in the Home location
284290
# For some Anna's LOCATIONS is empty, falling back to domain_objects!
285-
if self._is_thermostat and entity_id == self.gateway_id:
291+
if self._is_thermostat and entity_id == self._gateway_id:
286292
locator = f"./location[@id='{self._home_loc_id}']/logs/point_log[type='outdoor_temperature']/period/measurement"
287293
if (found := self._domain_objects.find(locator)) is not None:
288294
value = format_measure(found.text, NONE)

0 commit comments

Comments
 (0)