Check child state before updating

This commit is contained in:
Steven B 2024-12-20 09:29:34 +00:00
parent 3992a39264
commit a99af97b65
No known key found for this signature in database
GPG Key ID: 6D5B46B3679F2A43

View File

@ -162,13 +162,15 @@ class IotStrip(IotDevice):
async def turn_on(self, **kwargs) -> dict: async def turn_on(self, **kwargs) -> dict:
"""Turn the strip on.""" """Turn the strip on."""
for plug in self.children: for plug in self.children:
await plug.turn_on() if plug.is_off:
await plug.turn_on()
return {} return {}
async def turn_off(self, **kwargs) -> dict: async def turn_off(self, **kwargs) -> dict:
"""Turn the strip off.""" """Turn the strip off."""
for plug in self.children: for plug in self.children:
await plug.turn_off() if plug.is_on:
await plug.turn_off()
return {} return {}
@property # type: ignore @property # type: ignore