diff --git a/tests/test_device_types.py b/tests/test_device_types.py index e7f306f..4fb66a3 100644 --- a/tests/test_device_types.py +++ b/tests/test_device_types.py @@ -130,8 +130,8 @@ async def test_power_on_uses_lighting_service(self): with patch.object(device, '_pass_through_request', new_callable=AsyncMock) as mock: await device.power_on() mock.assert_called_once_with( - 'smartlife.iot.smartbulb.lightingservice', - 'transition_light_state', + 'smartlife.iot.lightStrip', + 'set_light_state', {'on_off': 1} ) @@ -143,8 +143,8 @@ async def test_set_color(self): with patch.object(device, '_pass_through_request', new_callable=AsyncMock) as mock: await device.set_color(hue=240, saturation=100, brightness=75) mock.assert_called_once_with( - 'smartlife.iot.smartbulb.lightingservice', - 'transition_light_state', + 'smartlife.iot.lightStrip', + 'set_light_state', {'on_off': 1, 'hue': 240, 'saturation': 100, 'color_temp': 0, 'brightness': 75} ) @@ -157,8 +157,8 @@ async def test_set_color_temp(self): with patch.object(device, '_pass_through_request', new_callable=AsyncMock) as mock: await device.set_color_temp(color_temp=4000) mock.assert_called_once_with( - 'smartlife.iot.smartbulb.lightingservice', - 'transition_light_state', + 'smartlife.iot.lightStrip', + 'set_light_state', {'on_off': 1, 'color_temp': 4000} ) @@ -188,8 +188,8 @@ async def test_set_brightness(self): with patch.object(device, '_pass_through_request', new_callable=AsyncMock) as mock: await device.set_brightness(50) mock.assert_called_once_with( - 'smartlife.iot.smartbulb.lightingservice', - 'transition_light_state', + 'smartlife.iot.lightStrip', + 'set_light_state', {'on_off': 1, 'brightness': 50} ) diff --git a/tplinkcloud/kl420l5.py b/tplinkcloud/kl420l5.py index 327e915..54430e8 100644 --- a/tplinkcloud/kl420l5.py +++ b/tplinkcloud/kl420l5.py @@ -1,7 +1,11 @@ from .device_type import TPLinkDeviceType from .device import TPLinkDevice -_LIGHTING_SERVICE = 'smartlife.iot.smartbulb.lightingservice' +# The KL42x/KL43x light strips do not support the smartbulb lighting +# service (err_code -2001 'module not support'); they use the +# lightStrip module with set_light_state. Verified against a live +# KL420L5(US). +_LIGHTING_SERVICE = 'smartlife.iot.lightStrip' class KL420L5LightState: @@ -79,7 +83,7 @@ async def set_light_state(self, on_off=None, brightness=None, hue=None, if transition_period is not None: state['transition_period'] = transition_period return await self._pass_through_request( - _LIGHTING_SERVICE, 'transition_light_state', state) + _LIGHTING_SERVICE, 'set_light_state', state) async def power_on(self): return await self.set_light_state(on_off=1) diff --git a/tplinkcloud/kl430.py b/tplinkcloud/kl430.py index 3881c75..bfdefcd 100644 --- a/tplinkcloud/kl430.py +++ b/tplinkcloud/kl430.py @@ -1,7 +1,11 @@ from .device_type import TPLinkDeviceType from .device import TPLinkDevice -_LIGHTING_SERVICE = 'smartlife.iot.smartbulb.lightingservice' +# The KL42x/KL43x light strips do not support the smartbulb lighting +# service (err_code -2001 'module not support'); they use the +# lightStrip module with set_light_state. Verified against a live +# KL420L5(US). +_LIGHTING_SERVICE = 'smartlife.iot.lightStrip' class KL430LightState: @@ -79,7 +83,7 @@ async def set_light_state(self, on_off=None, brightness=None, hue=None, if transition_period is not None: state['transition_period'] = transition_period return await self._pass_through_request( - _LIGHTING_SERVICE, 'transition_light_state', state) + _LIGHTING_SERVICE, 'set_light_state', state) async def power_on(self): return await self.set_light_state(on_off=1)