Skip to content

Commit 7061525

Browse files
committed
Improvements
1 parent 90430e0 commit 7061525

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

plugwise/smile.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ 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-
5958
data: dict[str, Any] = self._get_device_data(device_id)
59+
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)
6262
device.update(data)
@@ -85,7 +85,7 @@ def get_all_devices(self) -> None:
8585
self.single_master_thermostat()
8686

8787
for appliance, details in self._appl_data.items():
88-
loc_id: str = details["location"]
88+
loc_id: str | None = details["location"]
8989
# Don't assign the _home_location to thermostat-devices without a location, they are not active
9090
if loc_id is None and details["class"] not in THERMOSTAT_CLASSES:
9191
details["location"] = self._home_location
@@ -106,15 +106,15 @@ def get_all_devices(self) -> None:
106106
# Collect data for each device via helper function
107107
self._all_device_data()
108108

109-
def _device_data_switching_group(self, details, device_data) -> dict[str, Any]:
109+
def _device_data_switching_group(self, details, device_data) -> dict[str, bool]:
110110
"""Helper-function for _get_device_data().
111111
Determine switching group device data.
112112
"""
113113
if details["class"] in SWITCH_GROUP_TYPES:
114114
counter: int = 0
115115
for member in details["members"]:
116-
appl_data: dict[str, Any] = self._get_appliance_data(member)
117-
if appl_data["relay"]:
116+
member_data: dict[str, Any] = self._get_appliance_data(member)
117+
if member_data["relay"]:
118118
counter += 1
119119

120120
device_data["relay"] = True
@@ -123,7 +123,7 @@ def _device_data_switching_group(self, details, device_data) -> dict[str, Any]:
123123

124124
return device_data
125125

126-
def _device_data_adam(self, details, device_data) -> dict[str, Any]:
126+
def _device_data_adam(self, details, device_data) -> dict[str, bool]:
127127
"""Helper-function for _get_device_data().
128128
Determine Adam device data.
129129
"""
@@ -156,12 +156,11 @@ def _device_data_climate(self, details, device_data) -> dict[str, Any]:
156156
avail_schemas, sel_schema, sched_setpoint, last_active = self._schemas(loc_id)
157157
device_data["available_schedules"] = avail_schemas
158158
device_data["selected_schedule"] = sel_schema
159-
if not self._smile_legacy:
160-
device_data["schedule_temperature"] = sched_setpoint
161159
if self._smile_legacy:
162160
device_data["last_used"] = "".join(map(str, avail_schemas))
163161
else:
164162
device_data["last_used"] = last_active
163+
device_data["schedule_temperature"] = sched_setpoint
165164

166165
# Operation mode: auto, heat, cool
167166
device_data["mode"] = "auto"
@@ -184,23 +183,22 @@ def _get_device_data(self, dev_id) -> dict[str, Any]:
184183
"""Helper-function for _all_device_data() and async_update().
185184
Provide device-data, based on Location ID (= dev_id), from APPLIANCES.
186185
"""
187-
devices: dict[str, Any] = self._devices
188-
details: dict[str, Any] = devices.get(dev_id)
186+
details: dict[str, Any] = self._devices.get(dev_id)
189187
device_data: dict[str, Any] = self._get_appliance_data(dev_id)
190188

191189
# Generic
192190
if details["class"] == "gateway" or dev_id == self.gateway_id:
193191
# Adam & Anna: the Smile outdoor_temperature is present in DOMAIN_OBJECTS and LOCATIONS - under Home
194192
# The outdoor_temperature present in APPLIANCES is a local sensor connected to the active device
195193
if self.smile_type == "thermostat":
196-
outdoor_temperature: str = self._object_value(
194+
outdoor_temperature: str | None = self._object_value(
197195
self._home_location, "outdoor_temperature"
198196
)
199197
if outdoor_temperature is not None:
200198
device_data["outdoor_temperature"] = outdoor_temperature
201199

202200
# Get P1 data from LOCATIONS
203-
power_data: dict[str, Any] = self._power_data_from_location(
201+
power_data: dict[str, Any] | None = self._power_data_from_location(
204202
details["location"]
205203
)
206204
if power_data is not None:
@@ -583,7 +581,7 @@ async def _set_groupswitch_member_state(
583581
return True
584582

585583
async def set_switch_state(
586-
self, appl_id: str, members: dict[str], model: str, state: str
584+
self, appl_id: str, members: dict[str] | None, model: str, state: str
587585
) -> bool:
588586
"""Set the given State of the relevant Switch."""
589587
switch = Munch()

0 commit comments

Comments
 (0)