diff --git a/kasa/iot/iotstrip.py b/kasa/iot/iotstrip.py index a4b2ab99..a63b3e17 100755 --- a/kasa/iot/iotstrip.py +++ b/kasa/iot/iotstrip.py @@ -161,11 +161,17 @@ class IotStrip(IotDevice): async def turn_on(self, **kwargs) -> dict: """Turn the strip on.""" - return await self._query_helper("system", "set_relay_state", {"state": 1}) + for plug in self.children: + if plug.is_off: + await plug.turn_on() + return {} async def turn_off(self, **kwargs) -> dict: """Turn the strip off.""" - return await self._query_helper("system", "set_relay_state", {"state": 0}) + for plug in self.children: + if plug.is_on: + await plug.turn_off() + return {} @property # type: ignore @requires_update diff --git a/tests/fakeprotocol_iot.py b/tests/fakeprotocol_iot.py index 88e34647..23ce7827 100644 --- a/tests/fakeprotocol_iot.py +++ b/tests/fakeprotocol_iot.py @@ -308,10 +308,6 @@ class FakeIotTransport(BaseTransport): child_ids = [] _LOGGER.debug("Setting relay state to %s", x["state"]) - if not child_ids and "children" in self.proto["system"]["get_sysinfo"]: - for child in self.proto["system"]["get_sysinfo"]["children"]: - child_ids.append(child["id"]) - _LOGGER.info("child_ids: %s", child_ids) if child_ids: for child in self.proto["system"]["get_sysinfo"]["children"]: diff --git a/tests/iot/test_iotdevice.py b/tests/iot/test_iotdevice.py index 858c5fbc..0b822859 100644 --- a/tests/iot/test_iotdevice.py +++ b/tests/iot/test_iotdevice.py @@ -137,8 +137,9 @@ async def test_query_helper(dev): @device_iot @turn_on async def test_state(dev, turn_on): - await handle_turn_on(dev, turn_on) orig_state = dev.is_on + await handle_turn_on(dev, turn_on) + await dev.update() if orig_state: await dev.turn_off() await dev.update() diff --git a/tests/test_feature.py b/tests/test_feature.py index 3ccabeb4..0d621032 100644 --- a/tests/test_feature.py +++ b/tests/test_feature.py @@ -5,6 +5,7 @@ import pytest from pytest_mock import MockerFixture from kasa import Device, Feature, KasaException +from kasa.iot import IotStrip _LOGGER = logging.getLogger(__name__) @@ -168,7 +169,10 @@ async def test_feature_setters(dev: Device, mocker: MockerFixture): if feat.attribute_setter is None: return - expecting_call = feat.id not in internal_setters + # IotStrip makes calls via it's children + expecting_call = feat.id not in internal_setters and not isinstance( + dev, IotStrip + ) if feat.type == Feature.Type.Number: await feat.set_value(feat.minimum_value)