Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Ongoing

- Code optimizations via PR [#837](https://github.com/plugwise/python-plugwise/pull/837), [#838](https://github.com/plugwise/python-plugwise/pull/838), [#839](https://github.com/plugwise/python-plugwise/pull/839)
- Code optimizations via PR [#837](https://github.com/plugwise/python-plugwise/pull/837), [#838](https://github.com/plugwise/python-plugwise/pull/838), [#839](https://github.com/plugwise/python-plugwise/pull/839), [#840](https://github.com/plugwise/python-plugwise/pull/840)

## v1.11.0

Expand Down
11 changes: 7 additions & 4 deletions plugwise/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ def _get_appliances(self) -> None:
appl = Munch()
appl.available = None
appl.entity_id = appliance.get("id")
appl.firmware = None
appl.hardware = None
appl.location = None
appl.name = appliance.find("name").text
appl.mac = None
appl.model = None
appl.model_id = None
appl.module_id = None
appl.firmware = None
appl.hardware = None
appl.mac = None
appl.name = appliance.find("name").text
appl.pwclass = appliance.find("type").text
appl.zigbee_mac = None
appl.vendor_name = None
Expand Down Expand Up @@ -205,6 +205,9 @@ def _get_locations(self) -> None:
counter = 0
loc = Munch()
locations = self._domain_objects.findall("./location")
if not locations:
raise KeyError("No location data present!")

for location in locations:
loc.loc_id = location.get("id")
loc.name = location.find("name").text
Expand Down
31 changes: 16 additions & 15 deletions plugwise/legacy/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ def item_count(self) -> int:
"""Return the item-count."""
return self._count

def _all_appliances(self) -> None:
def _get_appliances(self) -> None:
"""Collect all appliances with relevant info."""
self._count = 0
self._all_locations()
self._get_locations()

self._create_legacy_gateway()
# For legacy P1 collect the connected SmartMeter info
Expand All @@ -99,32 +99,33 @@ def _all_appliances(self) -> None:
for appliance in self._appliances.findall("./appliance"):
appl = Munch()
appl.pwclass = appliance.find("type").text

appl.available = None
appl.entity_id = appliance.get("id")
appl.firmware = None
appl.hardware = None
appl.location = self._home_loc_id
appl.mac = None
appl.model = appl.pwclass.replace("_", " ").title()
appl.model_id = None
appl.name = appliance.find("name").text
appl.vendor_name = None
appl.zigbee_mac = None

# Skip thermostats that have this key, should be an orphaned device (Core #81712)
if (
appl.pwclass == "thermostat"
and appliance.find("actuator_functionalities/") is None
):
continue # pragma: no cover

appl.location = self._home_loc_id
appl.entity_id = appliance.get("id")
appl.name = appliance.find("name").text
# Extend device_class name when a Circle/Stealth is type heater_central -- Pw-Beta Issue #739
if (
appl.pwclass == "heater_central"
and appl.name != "Central heating boiler"
):
appl.pwclass = "heater_central_plug"

appl.model = appl.pwclass.replace("_", " ").title()
appl.available = None
appl.model_id = None
appl.firmware = None
appl.hardware = None
appl.mac = None
appl.zigbee_mac = None
appl.vendor_name = None

# Determine class for this appliance
# Skip on heater_central when no active device present or on orphaned stretch devices
if not (appl := self._appliance_info_finder(appliance, appl)):
Expand All @@ -137,7 +138,7 @@ def _all_appliances(self) -> None:
self._create_gw_entities(appl)
self._reorder_devices()

def _all_locations(self) -> None:
def _get_locations(self) -> None:
"""Collect all locations."""
loc = Munch()

Expand Down
2 changes: 1 addition & 1 deletion plugwise/legacy/smile.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_all_gateway_entities(self) -> None:
Collect and add switching- and/or pump-group entities.
Finally, collect the data and states for each entity.
"""
self._all_appliances()
self._get_appliances()
self._get_groups()
self._all_entity_data()

Expand Down
2 changes: 0 additions & 2 deletions plugwise/smile.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ async def async_update(self) -> dict[str, GwEntityData]:
self._cooling_enabled = heat_cooler["binary_sensors"][
"cooling_enabled"
]
else: # cover failed data-retrieval for P1
_ = self.gw_entities[self.gateway_id]["location"]
except KeyError as err:
raise DataMissingError("No Plugwise actual data received") from err

Expand Down