Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions plugwise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ async def _smile_detect_legacy(
locator = f"./{network}/mac"
if (net_locator := system.find(locator)) is not None:
self.smile_mac_address = net_locator.text
break
# P1 legacy:
elif dsmrmain is not None:
status = await self._request(STATUS)
Expand Down
4 changes: 4 additions & 0 deletions plugwise/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def _update_gw_entities(self) -> None:
if entity_id == self._gateway_id:
mac_list = self._detect_low_batteries()
self._add_or_update_notifications(entity_id, entity, data)
break # one gateway present

entity.update(data)
is_battery_low = (
Expand Down Expand Up @@ -228,6 +229,7 @@ def _check_availability(
for msg in item.values():
if message in msg:
data["available"] = False
break

def _get_adam_data(self, entity: GwEntityData, data: GwEntityData) -> None:
"""Helper-function for _get_entity_data().
Expand Down Expand Up @@ -334,11 +336,13 @@ def _get_schedule_states_with_off(
loc_schedule_states[schedule] = "off"
if schedule == selected and data["climate_mode"] == "auto":
loc_schedule_states[schedule] = "on"

self._schedule_old_states[location] = loc_schedule_states

all_off = True
for state in self._schedule_old_states[location].values():
if state == "on":
all_off = False

if all_off:
data["select_schedule"] = OFF
1 change: 1 addition & 0 deletions plugwise/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def _sort_gw_entities(self) -> None:
other_entities = self.gw_entities
priority_entities = {entity_id: priority_entity}
self.gw_entities = {**priority_entities, **other_entities}
break

def _all_locations(self) -> None:
"""Collect all locations."""
Expand Down
4 changes: 3 additions & 1 deletion plugwise/legacy/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
LIMITS,
NONE,
OFF,
PRIORITY_DEVICE_CLASSES,
P1_LEGACY_MEASUREMENTS,
TEMP_CELSIUS,
THERMOSTAT_CLASSES,
Expand Down Expand Up @@ -130,14 +131,15 @@ def _all_appliances(self) -> None:
self._create_gw_entities(appl)

# 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:
tmp_entity = entity
self.gw_entities.pop(entity_id)
cleared_dict = self.gw_entities
add_to_front = {entity_id: tmp_entity}
self.gw_entities = {**add_to_front, **cleared_dict}
break

def _all_locations(self) -> None:
"""Collect all locations."""
Expand Down
4 changes: 2 additions & 2 deletions plugwise/legacy/smile.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ async def set_schedule_state(
for rule in self._domain_objects.findall("rule"):
if rule.find("name").text == name:
schedule_rule_id = rule.attrib["id"]
break

if schedule_rule_id is None:
raise PlugwiseError(
Expand All @@ -215,8 +216,7 @@ async def set_schedule_state(
new_state = "true"

locator = f'.//*[@id="{schedule_rule_id}"]/template'
for rule in self._domain_objects.findall(locator):
template_id = rule.attrib["id"]
template_id = self._domain_objects.find(locator).attrib["id"]

data = (
"<rules>"
Expand Down
5 changes: 3 additions & 2 deletions plugwise/smile.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,13 @@ async def set_switch_state(
locator = f'appliance[@id="{appl_id}"]/{switch.actuator}/{switch.func_type}'
found: list[etree] = self._domain_objects.findall(locator)
for item in found:
# multiple types of e.g. toggle_functionality present
if (sw_type := item.find("type")) is not None:
if sw_type.text == switch.act_type:
switch_id = item.attrib["id"]
else:
break
else: # actuators with a single item like relay_functionality
switch_id = item.attrib["id"]
break

data = (
f"<{switch.func_type}>"
Expand Down