python-kasa / python-kasa

🏠🤖 Python API for TP-Link smarthome products
https://python-kasa.readthedocs.io/en/stable/
Other
1.2k stars 194 forks source link

Light Strips and get_light_state -> set_light_state #116

Open jimboca opened 3 years ago

jimboca commented 3 years ago

With existing smart bulbs I call get_light_state, change the return value params and pass that to set_light_state which seems to make all params change at the same time. This doesn't seem to work with smartlightstrip's.

2020-11-16 17:30:30,832 Controller polyinterface      DEBUG    SmartBulbNode:cmd_set_color_temp_brightness: Test KL120: current_state={'on_off': 1, 'mode': 'normal', 'hue': 0, 'saturation': 0, 'color_temp': 3000, 'brightness': 29}
2020-11-16 17:30:30,833 Controller polyinterface      DEBUG    SmartBulbNode:cmd_set_color_temp_brightness: Test KL120:     new_state={'on_off': 1, 'mode': 'normal', 'hue': 0, 'saturation': 0, 'color_temp': 5000, 'brightness': 100}
2020-11-16 17:30:30,978 Controller polyinterface      DEBUG    SmartDeviceNode:set_state: start: dev=<DeviceType.Bulb model KL120(US) at 192.168.86.184 (Test KL120), is_on: True - dev specific: {'Brightness': 29, 'Is dimmable': True, 'Color temperature': 3000, 'Valid temperature range': (2700, 5000)}>
2020-11-16 17:30:31,195 Controller polyinterface      DEBUG    SmartDeviceNode:set_state: end:   dev=<DeviceType.Bulb model KL120(US) at 192.168.86.184 (Test KL120), is_on: True - dev specific: {'Brightness': 100, 'Is dimmable': True, 'Color temperature': 5000, 'Valid temperature range': (2700, 5000)}>

This does not work with Light Strips:

2020-11-16 17:33:03,686 Controller polyinterface      DEBUG    SmartBulbNode:cmd_set_color_temp_brightness: Master Bed Strip: current_state={'transition': 0, 'length': 14, 'on_off': 1, 'mode': 'normal', 'groups': [[0, 13, 0, 0, 46, 6000]]}
2020-11-16 17:33:03,688 Controller polyinterface      DEBUG    SmartBulbNode:cmd_set_color_temp_brightness: Master Bed Strip:     new_state={'transition': 0, 'length': 14, 'on_off': 1, 'mode': 'normal', 'groups': [[0, 13, 0, 0, 46, 6000]], 'brightness': 100, 'color_temp': 5000}
2020-11-16 17:33:03,851 Controller polyinterface      DEBUG    SmartDeviceNode:set_state: start: dev=<DeviceType.LightStrip model KL430(US) at 192.168.86.177 (Master Bed Strip), is_on: True - dev specific: {'Brightness': 47, 'Is dimmable': True, 'Color temperature': 2500, 'Valid temperature range': (2500, 9000), 'HSV': (0, 0, 47), 'Length': 14}>
2020-11-16 17:33:04,010 Controller polyinterface      DEBUG    SmartDeviceNode:set_state: end:   dev=<DeviceType.LightStrip model KL430(US) at 192.168.86.177 (Master Bed Strip), is_on: True - dev specific: {'Brightness': 47, 'Is dimmable': True, 'Color temperature': 2500, 'Valid temperature range': (2500, 9000), 'HSV': (0, 0, 47), 'Length': 14}>

If there really is no advantage to calling set_light_state, then I'll just change to setting each param.

rytilahti commented 3 years ago

Probably a different implementation between those device series. What does the device respond to your request on light strips? Are you getting an error?

We could change the set_light_state call to drop any unknown parameters, if that makes passing a modified get_light_state to work again. What do you think?

DaveGut commented 3 years ago

Discovery while developing my Hubitat implementation: