Yeelight White, at least firmware 1.4.1_48, at least some setups, problems with get_properties()
This was initially discovered with HomeAssistant and submitted against it as https://github.com/home-assistant/home-assistant/issues/9141 . The relevant part of it:
After enabling debug logging for yeelight component, it still didn't show much, turned out downstream lib, python-yeelight, doesn't have reliable logging. After patching in the logging of what the bulb actually sends, following can be seen:
2017-08-26 16:58:03 DEBUG (Thread-3) [yeelight.main] Bulb<192.168.0.104:55443, type=BulbType.Unknown> > {'id': 0, 'params': ['power', 'bright', 'ct', 'rgb', 'hue', 'sat', 'color_mode', 'flowing', 'delayoff', 'flow_params', 'music_on', 'name'], 'method': 'get_prop'}
2017-08-26 16:58:03 DEBUG (Thread-3) [yeelight.main] RESP from Bulb<192.168.0.104:55443, type=BulbType.Unknown>: (255) b'{"id":0, "result":["on","7","","","","","2","0","0","0,0,250, 1, 1376000, 100, 250, 1, 44287, 100, 250, 1, 14745344, 100, 250, 1, 65384, 100, 250, 1, 16711931, 100, 250, 1, 14418175, 100, 250, 1, 65320, 100, 250, 1, 39935, 100, 250, 1, 8650496, 100","",""'
So, the response is truncated at 255 chars and lacks \r\n terminator, for which python-yeelight looks. It also uses socket.recv() to receive the response, which isn't proper/reliable way to deal with TCP traffic. So, my first idea was to see if second .recv() would read the reminder of the response, but it doesn't - the bulb really truncates the response it sends to 255 chars.
Then, request for "flow_params" property is to blame, its value takes too much chars. After patching python-yeelight to skip that param in its get_properties() call, everything works as expected (regarding the state showed in HASS UI and on/off commands).
Consequently, please kindly consider: a) logging the actual data that the device sends; b) removing "flow_params" and other suspicious properties from the default get_properties() call, and instead issuing a separate request for them, when actually demanded. Thanks!
--- main.py.org 2017-08-26 17:53:47.980668370 +0300
+++ main.py 2017-08-26 16:59:36.672112471 +0300
@@ -241,7 +241,7 @@
requested_properties = [
"power", "bright", "ct", "rgb", "hue", "sat",
- "color_mode", "flowing", "delayoff", "flow_params",
+ "color_mode", "flowing", "delayoff", #"flow_params",
"music_on", "name"
]
response = self.send_command("get_prop", requested_properties)