mattmattmatt / node-red-contrib-yeelight-compat-hue

💡 A Node-RED node for controlling Yeelight devices, compatible with node-red-contrib-node-hue flows.
https://flows.nodered.org/node/node-red-contrib-yeelight-compat-hue
MIT License
10 stars 12 forks source link

Setting brightness results in error #7

Open ulab opened 6 years ago

ulab commented 6 years ago

This is probably something that is more related to the device than this module, but I can't seem to be setting the brightness of my Yeelight Luna (ceiling light). Perhaps someone can point me in the right direction?

I can send "ct" with different color temperatures and "on" to switch the lamp on and off, but as soon as I try to send the "bri"ghtness, I get the following error:

"Yeelight "general error (code -5000)". Payload might be invalid."

mattmattmatt commented 6 years ago

Can you send a screenshot of the exact payload you are sending to the Yeelight node?

Unfortunately I don't have a Luna light, so I can not reproduce this error myself.

ulab commented 6 years ago

I have set up the following flow:

screen shot 2018-03-05 at 23 02 51

[{"id":"20b9d681.ef2672","type":"debug","z":"75274ba4.74e2fc","name":"","active":true,"console":"false","complete":"false","x":550.5,"y":511.5,"wires":[]},{"id":"756db4bc.79bc14","type":"inject","z":"75274ba4.74e2fc","name":"","topic":"","payload":"{\"on\":true}","payloadType":"json","repeat":"","crontab":"","once":false,"x":146,"y":243,"wires":[["f0df7e4b.9bd528"]]},{"id":"f0df7e4b.9bd528","type":"yeelight-compat-hue-out","z":"75274ba4.74e2fc","name":"Name","server":"3e67dcb6.4f833c","x":495.5,"y":257,"wires":[]},{"id":"603f6baa.44c1ac","type":"inject","z":"75274ba4.74e2fc","name":"","topic":"","payload":"{\"on\": false}","payloadType":"json","repeat":"","crontab":"","once":false,"x":144,"y":178,"wires":[["f0df7e4b.9bd528"]]},{"id":"7368752f.2c0c04","type":"inject","z":"75274ba4.74e2fc","name":"","topic":"","payload":"{\"ct\":1700}","payloadType":"json","repeat":"","crontab":"","once":false,"x":148,"y":310,"wires":[["f0df7e4b.9bd528"]]},{"id":"4444d87a.b2afe8","type":"inject","z":"75274ba4.74e2fc","name":"","topic":"","payload":"{\"ct\":6500}","payloadType":"json","repeat":"","crontab":"","once":false,"x":145,"y":357,"wires":[["f0df7e4b.9bd528"]]},{"id":"5af262f2.f51d44","type":"yeelight-compat-hue-state","z":"75274ba4.74e2fc","name":"","server":"3e67dcb6.4f833c","x":239.5,"y":510,"wires":[["20b9d681.ef2672"]]},{"id":"9c8c6fde.472888","type":"inject","z":"75274ba4.74e2fc","name":"","topic":"","payload":"{\"bri\":50}","payloadType":"json","repeat":"","crontab":"","once":false,"x":148,"y":416,"wires":[["f0df7e4b.9bd528"]]},{"id":"3e67dcb6.4f833c","type":"yeelight-compat-hue-config","z":"","hostname":"yeelink-light-ceiling1-mibt62556704.fritz.box","port":"55443","name":""}]

Clicking on the brightness button sends the following network traffic between my RaspberryPi (192.168.178.100) and the Luna (192.168.178.26):

###
T 192.168.178.100:46804 -> 192.168.178.26:55443 [AP]
  {"id":208,"method":"get_prop","params":["name","power","bright","rgb","ct","hue","sat","color_mode","delayoff","flowing","flow_params","music_on"]}..      
#
T 192.168.178.26:55443 -> 192.168.178.100:46804 [AP]
  {"id":208, "result":["","on","50","","6359","","","2","0","0","0,0,800,2,2700,50,800,2,2700,30,1600,2,2700,80,800,2,2700,60,1200,2,2700,90,2400,2,2700,50,1
  200,2,2700,80,800,2,2700,60,400,2,2700,70",""]}..                                                                                                          
##
T 192.168.178.100:46804 -> 192.168.178.26:55443 [AP]
  {"id":150,"method":"set_scene","params":["cf",1,1,"500, 1, 3355185, 20"]}..                                                                                
#
T 192.168.178.26:55443 -> 192.168.178.100:46804 [AP]
  {"id":150, "error":{"code":-5000,"message":"general error"}}..                                                                                             
#

If I use python example code from Yeelight, it just sends the following command:

{"id":1,"method":"set_bright","params":[100]}..

I'm guessing the difference is that one sends a set_scene command (which the Luna might not be able to understand because it doesn't have colors?), while the other sends the set_bright command as I'd expect.

mattmattmatt commented 6 years ago

Thanks for the response, all those details are very helpful!

This node-red-contrib-yeelight-compat-hue node uses set_scene to create smooth transitions between states, but in your case this might impact functionality.

When you log network traffic just like you did above but for the { "ct": 6500 } node, do you also see that set_scene is called, but without the error response?

ulab commented 6 years ago

Sorry for the late reply, I wasn't able to test it over the last few days and today it doesn't seem to change the color temperature anymore (unless I use the app), but it doesn't report an error either.

Sending {"ct":1700}:

#
T 192.168.178.100:33878 -> 192.168.178.26:55443 [AP]
  {"id":218,"method":"get_prop","params":["name","power","bright","rgb","ct","hue","sat","color_mode","delayoff","flowing","flow_params","music_on"]}..      
#
T 192.168.178.26:55443 -> 192.168.178.100:33878 [AP]
  {"id":218, "result":["","on","32","","6359","","","2","0","0","0,0,800,2,2700,50,800,2,2700,50,1600,2,2700,50,800,2,2700,50,1200,2,2700,50,2400,2,2700,50,1
  200,2,2700,50,800,2,2700,50,400,2,2700,50",""]}..                                                                                                          
##
T 192.168.178.100:33878 -> 192.168.178.26:55443 [AP]
  {"id":192,"method":"set_scene","params":["cf",1,1,"500, 2, 1700, 32"]}..                                                                                   
#
T 192.168.178.26:55443 -> 192.168.178.100:33878 [AP]
  {"id":192, "result":["ok"]}..                                                                                                                              
##
T 192.168.178.26:55443 -> 192.168.178.100:33878 [AP]
  {"method":"props","params":{"flowing":1}}..                                                                                                                
#

This is {"ct":6500}

#
T 192.168.178.100:33878 -> 192.168.178.26:55443 [AP]
  {"id":115,"method":"get_prop","params":["name","power","bright","rgb","ct","hue","sat","color_mode","delayoff","flowing","flow_params","music_on"]}..      
#
T 192.168.178.26:55443 -> 192.168.178.100:33878 [AP]
  {"id":115, "result":["","on","32","","6359","","","2","0","0","0,0,800,2,2700,50,800,2,2700,50,1600,2,2700,50,800,2,2700,50,1200,2,2700,50,2400,2,2700,50,1
  200,2,2700,50,800,2,2700,50,400,2,2700,50",""]}..                                                                                                          
##
T 192.168.178.100:33878 -> 192.168.178.26:55443 [AP]
  {"id":131,"method":"set_scene","params":["cf",1,1,"500, 2, 6500, 32"]}..                                                                                   
#
T 192.168.178.26:55443 -> 192.168.178.100:33878 [AP]
  {"id":131, "result":["ok"]}..                                                                                                                              
#
T 192.168.178.26:55443 -> 192.168.178.100:33878 [AP]
  {"id":131, "result":["ok"]}..                                                                                                                              
##
T 192.168.178.26:55443 -> 192.168.178.100:33878 [AP]
  {"method":"props","params":{"flowing":1}}..                                                                                                                
#
KL-AU-S commented 5 years ago

I have the some error with the brightness. Is there any solution? Kind regards

S474N commented 4 years ago

I tested this and it's ok on Yeelight 320:

{"on": true,"ct": 6500, "bri": 255, "duration": 500}