Skip to content

Commit e20bef7

Browse files
committed
Smile.py: clean up typing hints
1 parent e23914c commit e20bef7

File tree

1 file changed

+32
-36
lines changed

1 file changed

+32
-36
lines changed

plugwise/smile.py

Lines changed: 32 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _all_device_data(self) -> None:
5555
temp_bs_dict: dict[str, bool] = {}
5656
temp_s_dict: dict[str, Any] = {}
5757
temp_sw_dict: dict[str, bool] = {}
58-
data: dict[str, Any] = self._get_device_data(device_id)
58+
data = self._get_device_data(device_id)
5959

6060
self._create_dicts_from_data(data, temp_bs_dict, temp_s_dict, temp_sw_dict)
6161
self._append_special(device_id, temp_bs_dict, temp_s_dict)
@@ -111,9 +111,9 @@ def _device_data_switching_group(self, details, device_data) -> dict[str, bool]:
111111
Determine switching group device data.
112112
"""
113113
if details["class"] in SWITCH_GROUP_TYPES:
114-
counter: int = 0
114+
counter = 0
115115
for member in details["members"]:
116-
member_data: dict[str, Any] = self._get_appliance_data(member)
116+
member_data = self._get_appliance_data(member)
117117
if member_data["relay"]:
118118
counter += 1
119119

@@ -141,7 +141,7 @@ def _device_data_climate(self, details, device_data) -> dict[str, Any]:
141141
"""Helper-function for _get_device_data().
142142
Determine climate-control device data.
143143
"""
144-
loc_id: str = details["location"]
144+
loc_id = details["location"]
145145

146146
# Presets
147147
device_data["preset_modes"] = None
@@ -191,7 +191,7 @@ def _get_device_data(self, dev_id) -> dict[str, Any]:
191191
# Adam & Anna: the Smile outdoor_temperature is present in DOMAIN_OBJECTS and LOCATIONS - under Home
192192
# The outdoor_temperature present in APPLIANCES is a local sensor connected to the active device
193193
if self.smile_type == "thermostat":
194-
outdoor_temperature: str | None = self._object_value(
194+
outdoor_temperature = self._object_value(
195195
self._home_location, "outdoor_temperature"
196196
)
197197
if outdoor_temperature is not None:
@@ -224,7 +224,7 @@ def single_master_thermostat(self) -> None:
224224
"""Determine if there is a single master thermostat in the setup."""
225225
if self.smile_type == "thermostat":
226226
self._is_thermostat = True
227-
count: int = 0
227+
count = 0
228228
for dummy, data in self._thermo_locs.items():
229229
if "master_prio" in data:
230230
if data.get("master_prio") > 0:
@@ -409,9 +409,9 @@ async def _update_domain_objects(self) -> None:
409409
notifications: etree = self._domain_objects.findall(".//notification")
410410
for notification in notifications:
411411
try:
412-
msg_id: str = notification.attrib["id"]
413-
msg_type: str = notification.find("type").text
414-
msg: str = notification.find("message").text
412+
msg_id = notification.attrib["id"]
413+
msg_type = notification.find("type").text
414+
msg = notification.find("message").text
415415
self._notifications.update({msg_id: {msg_type: msg}})
416416
LOGGER.debug("Plugwise notifications: %s", self._notifications)
417417
except AttributeError: # pragma: no cover
@@ -434,7 +434,7 @@ async def async_update(self) -> dict[str, Any]:
434434
self.gw_data["notifications"] = self._notifications
435435

436436
for dev_id, dev_dict in self.gw_devices.items():
437-
data: dict[str, Any] = self._get_device_data(dev_id)
437+
data = self._get_device_data(dev_id)
438438
for key, value in list(data.items()):
439439
if key in dev_dict:
440440
dev_dict[key] = value
@@ -463,7 +463,7 @@ async def async_update(self) -> dict[str, Any]:
463463

464464
return [self.gw_data, self.gw_devices]
465465

466-
async def _set_schedule_state_legacy(self, name: str, status: str) -> bool:
466+
async def _set_schedule_state_legacy(self, name, status) -> bool:
467467
"""Helper-function for set_schedule_state()."""
468468
schema_rule_id: str | None = None
469469
for rule in self._domain_objects.findall("rule"):
@@ -473,15 +473,15 @@ async def _set_schedule_state_legacy(self, name: str, status: str) -> bool:
473473
if schema_rule_id is None:
474474
return False
475475

476-
state: str = "false"
476+
state = "false"
477477
if status == "on":
478478
state = "true"
479-
locator: etree = f'.//*[@id="{schema_rule_id}"]/template'
479+
locator = f'.//*[@id="{schema_rule_id}"]/template'
480480
for rule in self._domain_objects.findall(locator):
481481
template_id = rule.attrib["id"]
482482

483-
uri: str = f"{RULES};id={schema_rule_id}"
484-
data: str = (
483+
uri = f"{RULES};id={schema_rule_id}"
484+
data = (
485485
"<rules><rule"
486486
f' id="{schema_rule_id}"><name><![CDATA[{name}]]></name><template'
487487
f' id="{template_id}" /><active>{state}</active></rule></rules>'
@@ -526,12 +526,12 @@ async def set_schedule_state(self, loc_id: str, name: str, state: str) -> bool:
526526

527527
async def _set_preset_legacy(self, preset) -> bool:
528528
"""Set the given Preset on the relevant Thermostat - from DOMAIN_OBJECTS."""
529-
locator: str = f'rule/directives/when/then[@icon="{preset}"].../.../...'
529+
locator = f'rule/directives/when/then[@icon="{preset}"].../.../...'
530530
if (rule := self._domain_objects.find(locator)) is None:
531531
return False
532532

533533
uri = RULES
534-
data: str = f'<rules><rule id="{rule.attrib["id"]}"><active>true</active></rule></rules>'
534+
data = f'<rules><rule id="{rule.attrib["id"]}"><active>true</active></rule></rules>'
535535

536536
await self._request(uri, method="put", data=data)
537537
return True
@@ -541,15 +541,15 @@ async def set_preset(self, loc_id: str, preset: str) -> bool:
541541
if self._smile_legacy:
542542
return await self._set_preset_legacy(preset)
543543

544-
current_location: etree = self._locations.find(f'location[@id="{loc_id}"]')
545-
location_name: str = current_location.find("name").text
546-
location_type: str = current_location.find("type").text
544+
current_location = self._locations.find(f'location[@id="{loc_id}"]')
545+
location_name = current_location.find("name").text
546+
location_type = current_location.find("type").text
547547

548548
if preset not in self._presets(loc_id):
549549
return False
550550

551-
uri: str = f"{LOCATIONS};id={loc_id}"
552-
data: str = (
551+
uri = f"{LOCATIONS};id={loc_id}"
552+
data = (
553553
"<locations><location"
554554
f' id="{loc_id}"><name>{location_name}</name><type>{location_type}'
555555
f"</type><preset>{preset}</preset></location></locations>"
@@ -560,8 +560,8 @@ async def set_preset(self, loc_id: str, preset: str) -> bool:
560560

561561
async def set_temperature(self, loc_id: str, temperature: str) -> bool:
562562
"""Set the given Temperature on the relevant Thermostat."""
563-
uri: str = self._temperature_uri(loc_id)
564-
data: str = (
563+
uri = self._temperature_uri(loc_id)
564+
data = (
565565
"<thermostat_functionality><setpoint>"
566566
f"{temperature}</setpoint></thermostat_functionality>"
567567
)
@@ -574,14 +574,12 @@ async def _set_groupswitch_member_state(self, members, state, switch) -> bool:
574574
Set the given State of the relevant Switch within a group of members.
575575
"""
576576
for member in members:
577-
locator: str = (
578-
f'appliance[@id="{member}"]/{switch.actuator}/{switch.func_type}'
579-
)
580-
switch_id: str = self._appliances.find(locator).attrib["id"]
581-
uri: str = f"{APPLIANCES};id={member}/{switch.device};id={switch_id}"
577+
locator = f'appliance[@id="{member}"]/{switch.actuator}/{switch.func_type}'
578+
switch_id = self._appliances.find(locator).attrib["id"]
579+
uri = f"{APPLIANCES};id={member}/{switch.device};id={switch_id}"
582580
if self._stretch_v2:
583581
uri = f"{APPLIANCES};id={member}/{switch.device}"
584-
data: str = f"<{switch.func_type}><{switch.func}>{state}</{switch.func}></{switch.func_type}>"
582+
data = f"<{switch.func_type}><{switch.func}>{state}</{switch.func}></{switch.func_type}>"
585583

586584
await self._request(uri, method="put", data=data)
587585

@@ -611,14 +609,12 @@ async def set_switch_state(
611609
if members is not None:
612610
return await self._set_groupswitch_member_state(members, state, switch)
613611

614-
locator: str = (
615-
f'appliance[@id="{appl_id}"]/{switch.actuator}/{switch.func_type}'
616-
)
617-
switch_id: str = self._appliances.find(locator).attrib["id"]
618-
uri: str = f"{APPLIANCES};id={appl_id}/{switch.device};id={switch_id}"
612+
locator = f'appliance[@id="{appl_id}"]/{switch.actuator}/{switch.func_type}'
613+
switch_id = self._appliances.find(locator).attrib["id"]
614+
uri = f"{APPLIANCES};id={appl_id}/{switch.device};id={switch_id}"
619615
if self._stretch_v2:
620616
uri = f"{APPLIANCES};id={appl_id}/{switch.device}"
621-
data: str = f"<{switch.func_type}><{switch.func}>{state}</{switch.func}></{switch.func_type}>"
617+
data = f"<{switch.func_type}><{switch.func}>{state}</{switch.func}></{switch.func_type}>"
622618

623619
if model == "relay":
624620
locator = (

0 commit comments

Comments
 (0)