Skip to content

Commit f00d86d

Browse files
committed
Return fixes
1 parent f21c78a commit f00d86d

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

plugwise/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
PRESET_AWAY: Final = "away"
2424
PRESSURE_BAR: Final = "bar"
2525
SIGNAL_STRENGTH_DECIBELS_MILLIWATT: Final = "dBm"
26+
STATE_ON: Final = "on"
2627
TEMP_CELSIUS: Final = "°C"
2728
TEMP_KELVIN: Final = "°K"
2829
TIME_MILLISECONDS: Final = "ms"

plugwise/legacy/smile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
OFF,
1919
REQUIRE_APPLIANCES,
2020
RULES,
21+
STATE_ON,
2122
GwEntityData,
2223
ThermoLoc,
2324
)
@@ -241,6 +242,7 @@ async def set_switch_state(
241242
For group switches, sets the state for each member in the group separately.
242243
For switch-locks, sets the lock state using a different data format.
243244
"""
245+
req_state = state == STATE_ON
244246
switch = Munch()
245247
switch.actuator = "actuator_functionalities"
246248
switch.func_type = "relay_functionality"
@@ -285,7 +287,7 @@ async def set_switch_state(
285287
return False
286288

287289
await self.call_request(uri, method="put", data=data)
288-
return True
290+
return req_state
289291

290292
async def _set_groupswitch_member_state(
291293
self, data: str, members: list[str], state: str, switch: Munch
@@ -294,12 +296,14 @@ async def _set_groupswitch_member_state(
294296
295297
Set the given State of the relevant Switch (relay) within a group of members.
296298
"""
299+
switched = 0
297300
for member in members:
298301
if not self.gw_entities[member]["switches"]["lock"]:
299302
uri = f"{APPLIANCES};id={member}/relay"
300303
await self.call_request(uri, method="put", data=data)
304+
switched += 1
301305

302-
return True
306+
return switched > 0
303307

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

plugwise/smile.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
NOTIFICATIONS,
2323
OFF,
2424
RULES,
25+
STATE_ON,
2526
GwEntityData,
2627
ThermoLoc,
2728
)
@@ -379,6 +380,7 @@ async def set_switch_state(
379380
self, appl_id: str, members: list[str] | None, model: str, state: str
380381
) -> bool:
381382
"""Set the given State of the relevant Switch."""
383+
req_state = state == STATE_ON
382384
switch = Munch()
383385
switch.actuator = "actuator_functionalities"
384386
switch.device = "relay"
@@ -423,7 +425,7 @@ async def set_switch_state(
423425
return False
424426

425427
await self.call_request(uri, method="put", data=data)
426-
return True
428+
return req_state
427429

428430
async def _set_groupswitch_member_state(
429431
self, members: list[str], state: str, switch: Munch
@@ -432,6 +434,7 @@ async def _set_groupswitch_member_state(
432434
433435
Set the given State of the relevant Switch within a group of members.
434436
"""
437+
switched = 0
435438
for member in members:
436439
locator = f'appliance[@id="{member}"]/{switch.actuator}/{switch.func_type}'
437440
switch_id = self._domain_objects.find(locator).attrib["id"]
@@ -443,8 +446,9 @@ async def _set_groupswitch_member_state(
443446
)
444447
if not self.gw_entities[member]["switches"].get("lock"):
445448
await self.call_request(uri, method="put", data=data)
449+
switched += 1
446450

447-
return True
451+
return switched > 0
448452

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

0 commit comments

Comments
 (0)