Skip to content

Commit ca9ae24

Browse files
committed
Revert back to returning None's
1 parent 1ff1a09 commit ca9ae24

File tree

3 files changed

+9
-35
lines changed

3 files changed

+9
-35
lines changed

plugwise/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,10 @@ async def set_temperature_offset(self, dev_id: str, offset: float) -> None:
398398

399399
async def set_switch_state(
400400
self, appl_id: str, members: list[str] | None, model: str, state: str
401-
) -> bool:
401+
) -> None:
402402
"""Set the given State of the relevant Switch."""
403403
try:
404-
return await self._smile_api.set_switch_state(
404+
await self._smile_api.set_switch_state(
405405
appl_id, members, model, state
406406
)
407407
except ConnectionFailedError as exc:

plugwise/legacy/smile.py

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,14 @@ async def set_schedule_state(
235235

236236
async def set_switch_state(
237237
self, appl_id: str, members: list[str] | None, model: str, state: str
238-
) -> bool:
238+
) -> None:
239239
"""Set the given state of the relevant switch.
240240
241241
For individual switches, sets the state directly.
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
Return the requested state when succesful, the current state otherwise.
245245
"""
246-
current_state = self.gw_entities[appl_id]["switches"]["relay"]
247-
requested_state = state == STATE_ON
248246
switch = Munch()
249247
switch.actuator = "actuator_functionalities"
250248
switch.func_type = "relay_functionality"
@@ -273,7 +271,6 @@ async def set_switch_state(
273271
"</appliances>"
274272
)
275273
await self.call_request(APPLIANCES, method="post", data=data)
276-
return requested_state
277274

278275
# Handle group of switches
279276
data = f"<{switch.func_type}><state>{state}</state></{switch.func_type}>"
@@ -284,12 +281,11 @@ async def set_switch_state(
284281

285282
# Handle individual relay switches
286283
uri = f"{APPLIANCES};id={appl_id}/relay"
287-
if model == "relay" and self.gw_entities[appl_id]["switches"]["lock"]:
284+
if model == "relay" and self.gw_entities[appl_id]["switches"].get("lock"):
288285
# Don't bother switching a relay when the corresponding lock-state is true
289-
return current_state
286+
return None
290287

291288
await self.call_request(uri, method="put", data=data)
292-
return requested_state
293289

294290
async def _set_groupswitch_member_state(
295291
self, appl_id: str, data: str, members: list[str], state: str, switch: Munch
@@ -299,19 +295,10 @@ async def _set_groupswitch_member_state(
299295
Set the given State of the relevant Switch (relay) within a group of members.
300296
Return the requested state when at least one requested change was succesful, the current state otherwise.
301297
"""
302-
current_state = self.gw_entities[appl_id]["switches"]["relay"]
303-
requested_state = state == STATE_ON
304-
switched = 0
305298
for member in members:
306-
if not self.gw_entities[member]["switches"]["lock"]:
299+
if not self.gw_entities[member]["switches"].get("lock"):
307300
uri = f"{APPLIANCES};id={member}/relay"
308301
await self.call_request(uri, method="put", data=data)
309-
switched += 1
310-
311-
if switched > 0:
312-
return requested_state
313-
314-
return current_state # pragma: no cover
315302

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

plugwise/smile.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -379,14 +379,11 @@ def determine_contexts(
379379

380380
async def set_switch_state(
381381
self, appl_id: str, members: list[str] | None, model: str, state: str
382-
) -> bool:
382+
) -> None:
383383
"""Set the given State of the relevant Switch.
384384
385385
Return the requested state when succesful, the current state otherwise.
386386
"""
387-
model_type = cast(SwitchType, model)
388-
current_state = self.gw_entities[appl_id]["switches"][model_type]
389-
requested_state = state == STATE_ON
390387
switch = Munch()
391388
switch.actuator = "actuator_functionalities"
392389
switch.device = "relay"
@@ -434,34 +431,24 @@ async def set_switch_state(
434431
if lock_blocked or lock_blocked is None:
435432
# Don't switch a relay when its corresponding lock-state is true or no
436433
# lock is present. That means the relay can't be controlled by the user.
437-
return current_state
434+
return None
438435

439436
await self.call_request(uri, method="put", data=data)
440-
return requested_state
441437

442438
async def _set_groupswitch_member_state(
443439
self, appl_id: str, data: str, members: list[str], state: str, switch: Munch
444-
) -> bool:
440+
) -> None:
445441
"""Helper-function for set_switch_state().
446442
447443
Set the given State of the relevant Switch within a group of members.
448444
Return the requested state when at least one requested change was succesful, the current state otherwise.
449445
"""
450-
current_state = self.gw_entities[appl_id]["switches"]["relay"]
451-
requested_state = state == STATE_ON
452-
switched = 0
453446
for member in members:
454447
locator = f'appliance[@id="{member}"]/{switch.actuator}/{switch.func_type}'
455448
switch_id = self._domain_objects.find(locator).attrib["id"]
456449
uri = f"{APPLIANCES};id={member}/{switch.device};id={switch_id}"
457450
if not self.gw_entities[member]["switches"].get("lock"):
458451
await self.call_request(uri, method="put", data=data)
459-
switched += 1
460-
461-
if switched > 0:
462-
return requested_state
463-
464-
return current_state
465452

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

0 commit comments

Comments
 (0)