Skip to content

Commit d57567e

Browse files
committed
More review updates
1 parent 2b19da6 commit d57567e

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

plugwise/smile.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _all_device_data(self) -> None:
8080

8181
def get_all_devices(self) -> None:
8282
"""Determine the devices present from the obtained XML-data."""
83-
self._devices: dict[str, Any] = {}
83+
self._devices: dict[str, dict[str, Any]] = {}
8484
self._scan_thermostats()
8585
self.single_master_thermostat()
8686

@@ -420,7 +420,7 @@ async def _update_domain_objects(self) -> None:
420420
f"{self._endpoint}{DOMAIN_OBJECTS}",
421421
)
422422

423-
async def async_update(self) -> tuple[dict, dict]:
423+
async def async_update(self) -> dict[str, Any]:
424424
"""Perform an incremental update for updating the various device states."""
425425
if self.smile_type != "power":
426426
await self._update_domain_objects()
@@ -465,7 +465,7 @@ async def async_update(self) -> tuple[dict, dict]:
465465

466466
async def _set_schedule_state_legacy(self, name: str, status: str) -> bool:
467467
"""Helper-function for set_schedule_state()."""
468-
schema_rule_id: str = None
468+
schema_rule_id: str | None = None
469469
for rule in self._domain_objects.findall("rule"):
470470
if rule.find("name").text == name:
471471
schema_rule_id = rule.attrib["id"]
@@ -525,6 +525,18 @@ async def set_schedule_state(self, loc_id: str, name: str, state: str) -> bool:
525525

526526
return True
527527

528+
async def _set_preset_legacy(self, preset) -> bool:
529+
"""Set the given Preset on the relevant Thermostat - from DOMAIN_OBJECTS."""
530+
locator: str = f'rule/directives/when/then[@icon="{preset}"].../.../...'
531+
if (rule := self._domain_objects.find(locator)) is None:
532+
return False
533+
534+
uri: str = f"{RULES}"
535+
data: str = f'<rules><rule id="{rule.attrib["id"]}"><active>true</active></rule></rules>'
536+
537+
await self._request(uri, method="put", data=data)
538+
return True
539+
528540
async def set_preset(self, loc_id: str, preset: str) -> bool:
529541
"""Set the given Preset on the relevant Thermostat - from LOCATIONS."""
530542
if self._smile_legacy:
@@ -558,9 +570,7 @@ async def set_temperature(self, loc_id: str, temperature: str) -> bool:
558570
await self._request(uri, method="put", data=data)
559571
return True
560572

561-
async def _set_groupswitch_member_state(
562-
self, members: dict[str], state: str, switch: str
563-
) -> bool:
573+
async def _set_groupswitch_member_state(self, members, state, switch) -> bool:
564574
"""Helper-function for set_switch_state() .
565575
Set the given State of the relevant Switch within a group of members.
566576
"""
@@ -579,7 +589,7 @@ async def _set_groupswitch_member_state(
579589
return True
580590

581591
async def set_switch_state(
582-
self, appl_id: str, members: dict[str] | None, model: str, state: str
592+
self, appl_id: str, members: list[str] | None, model: str, state: str
583593
) -> bool:
584594
"""Set the given State of the relevant Switch."""
585595
switch = Munch()
@@ -623,18 +633,6 @@ async def set_switch_state(
623633
await self._request(uri, method="put", data=data)
624634
return True
625635

626-
async def _set_preset_legacy(self, preset: str) -> bool:
627-
"""Set the given Preset on the relevant Thermostat - from DOMAIN_OBJECTS."""
628-
locator: str = f'rule/directives/when/then[@icon="{preset}"].../.../...'
629-
if (rule := self._domain_objects.find(locator)) is None:
630-
return False
631-
632-
uri: str = f"{RULES}"
633-
data: str = f'<rules><rule id="{rule.attrib["id"]}"><active>true</active></rule></rules>'
634-
635-
await self._request(uri, method="put", data=data)
636-
return True
637-
638636
async def delete_notification(self) -> bool:
639637
"""Delete the active Plugwise Notification."""
640638
uri: str = f"{NOTIFICATIONS}"

0 commit comments

Comments
 (0)