Skip to content

Commit b01476c

Browse files
committed
Improve var-name, correct returns
1 parent 4c8ba3c commit b01476c

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

plugwise/legacy/smile.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ async def set_switch_state(
242242
For group switches, sets the state for each member in the group separately.
243243
For switch-locks, sets the lock state using a different data format.
244244
"""
245-
req_state = state == STATE_ON
245+
requested_state = state == STATE_ON
246246
switch = Munch()
247247
switch.actuator = "actuator_functionalities"
248248
switch.func_type = "relay_functionality"
@@ -271,7 +271,7 @@ async def set_switch_state(
271271
"</appliances>"
272272
)
273273
await self.call_request(APPLIANCES, method="post", data=data)
274-
return req_state
274+
return requested_state
275275

276276
# Handle group of switches
277277
data = f"<{switch.func_type}><state>{state}</state></{switch.func_type}>"
@@ -284,10 +284,10 @@ async def set_switch_state(
284284
uri = f"{APPLIANCES};id={appl_id}/relay"
285285
if model == "relay" and self.gw_entities[appl_id]["switches"]["lock"]:
286286
# Don't bother switching a relay when the corresponding lock-state is true
287-
return False
287+
return not requested_state
288288

289289
await self.call_request(uri, method="put", data=data)
290-
return req_state
290+
return requested_state
291291

292292
async def _set_groupswitch_member_state(
293293
self, data: str, members: list[str], state: str, switch: Munch
@@ -296,7 +296,7 @@ async def _set_groupswitch_member_state(
296296
297297
Set the given State of the relevant Switch (relay) within a group of members.
298298
"""
299-
req_state = state == STATE_ON
299+
requested_state = state == STATE_ON
300300
switched = 0
301301
for member in members:
302302
if not self.gw_entities[member]["switches"]["lock"]:
@@ -305,9 +305,9 @@ async def _set_groupswitch_member_state(
305305
switched += 1
306306

307307
if switched > 0:
308-
return req_state
309-
else:
310-
return not req_state # pragma: no cover
308+
return requested_state
309+
310+
return not requested_state # pragma: no cover
311311

312312
async def set_temperature(self, _: str, items: dict[str, float]) -> None:
313313
"""Set the given Temperature on the relevant Thermostat."""

plugwise/smile.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ async def set_switch_state(
380380
self, appl_id: str, members: list[str] | None, model: str, state: str
381381
) -> bool:
382382
"""Set the given State of the relevant Switch."""
383-
req_state = state == STATE_ON
383+
requested_state = state == STATE_ON
384384
switch = Munch()
385385
switch.actuator = "actuator_functionalities"
386386
switch.device = "relay"
@@ -422,10 +422,10 @@ async def set_switch_state(
422422
uri = f"{APPLIANCES};id={appl_id}/{switch.device};id={switch_id}"
423423
if model == "relay" and self.gw_entities[appl_id]["switches"]["lock"]:
424424
# Don't switch a relay when its corresponding lock-state is true
425-
return False
425+
return not requested_state
426426

427427
await self.call_request(uri, method="put", data=data)
428-
return req_state
428+
return requested_state
429429

430430
async def _set_groupswitch_member_state(
431431
self, members: list[str], state: str, switch: Munch
@@ -434,7 +434,7 @@ async def _set_groupswitch_member_state(
434434
435435
Set the given State of the relevant Switch within a group of members.
436436
"""
437-
req_state = state == STATE_ON
437+
requested_state = state == STATE_ON
438438
switched = 0
439439
for member in members:
440440
locator = f'appliance[@id="{member}"]/{switch.actuator}/{switch.func_type}'
@@ -450,9 +450,9 @@ async def _set_groupswitch_member_state(
450450
switched += 1
451451

452452
if switched > 0:
453-
return req_state
454-
else:
455-
return not req_state
453+
return requested_state
454+
455+
return not requested_state
456456

457457
async def set_temperature(self, loc_id: str, items: dict[str, float]) -> None:
458458
"""Set the given Temperature on the relevant Thermostat."""

0 commit comments

Comments
 (0)