Skip to content

Commit a09cf6c

Browse files
committed
Simplify legacy too
1 parent f50b70b commit a09cf6c

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

plugwise/legacy/helper.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,13 @@ def _get_measurement_data(self, entity_id: str) -> GwEntityData:
294294
if appliance.find("type").text in ACTUATOR_CLASSES:
295295
self._get_actuator_functionalities(appliance, entity, data)
296296

297-
# Adam & Anna: the Smile outdoor_temperature is present in DOMAIN_OBJECTS and LOCATIONS - under Home
298-
# The outdoor_temperature present in APPLIANCES is a local sensor connected to the active device
297+
# Anna: the Smile outdoor_temperature is present in DOMAIN_OBJECTS or LOCATIONS - under Home
298+
# Some Anna's have an empty LOCATIONS!
299299
if self._is_thermostat and entity_id == self.gateway_id:
300-
outdoor_temperature = self._home_loc_value("outdoor_temperature")
301-
if outdoor_temperature is not None:
302-
data.update({"sensors": {"outdoor_temperature": outdoor_temperature}})
300+
locator = f"./location[@id='{self._home_loc_id}']/logs/point_log[type='outdoor_temperature']/period/measurement"
301+
if (found := self._domain_objects.find(locator)) is not None:
302+
value = format_measure(found.text, NONE)
303+
data.update({"sensors": {"outdoor_temperature": value}})
303304
self._count += 1
304305

305306
if "c_heating_state" in data:
@@ -394,20 +395,6 @@ def _get_actuator_functionalities(
394395
act_item = cast(ActuatorType, item)
395396
data[act_item] = temp_dict
396397

397-
def _home_loc_value(self, measurement: str) -> float | int | None:
398-
"""Helper-function for smile.py: _get_entity_data().
399-
400-
Obtain the value/state for the given measurement from the Home location
401-
"""
402-
val: float | int | None = None
403-
search = self._domain_objects
404-
locator = f"./location[@id='{self._home_loc_id}']/logs/point_log[type='{measurement}']/period/measurement"
405-
if (found := search.find(locator)) is not None:
406-
val = format_measure(found.text, NONE)
407-
return val
408-
409-
return val
410-
411398
def _preset(self) -> str | None:
412399
"""Helper-function for smile.py: _climate_data().
413400

0 commit comments

Comments
 (0)