Ha-bridge: Xiaomi Yeelight support - TCP requests to use \n \r

Created on 28 Jan 2017  路  16Comments  路  Source: bwssytems/ha-bridge

I have a Yeelight bulb, which was working fine with ha-bridge v3.5.1, but with the latest versions (4.1.0) I cant make it work.
For example, in the v3.5.1, power on command was:

tcp://10.100.1.60:55443/{\"id\":1,\"method\":\"set_power\",\"params\":[\"on\"]}\r\n

Which will be the syntax for ha-bridge v4.1.0?

Thank you!

enhancement question

All 16 comments

Yep, #296, asked for this as well

So, as I understand, it is not working anymore in the latest version?

Is there an error message that occurs in the log?

No, there is no error in the log, and the webpage confirms that the command was successfully executed (green popup).
This is the entry from device.db:
{"id":"7","uniqueid":"00:17:88:5E:D3:07-07","name":"White Light","mapType":"tcpDevice","deviceType":"custom","offUrl":"[{\"item\":\"tcp://10.100.1.60:55443/{\\\\\\\"id\\\\\\\":1,\\\\\\\"method\\\\\\\":\\\\\\\"set_power\\\\\\\",\\\\\\\"params\\\\\\\":[\\\\\\\"off\\\\\\\"]}\\\\r\\\\n\",\"type\":\"tcpDevice\"}]","onUrl":"[{\"item\":\"tcp://10.100.1.60:55443/{\\\\\\\"id\\\\\\\":1,\\\\\\\"method\\\\\\\":\\\\\\\"set_power\\\\\\\",\\\\\\\"params\\\\\\\":[\\\\\\\"on\\\\\\\"]}\\\\r\\\\n\",\"type\":\"tcpDevice\"}]","inactive":false,"noState":false}

It seems that there are a lot of backslashes...

That entry is pretty bad. Did you cut and paste from somewhere?

Yes, from a notepad file, but I did the same thing with the previous version of ha-bridge and there was no problem.

Well let's create a new device by typing it in manually. It seems there are too many escapes

To create your device, type the tcp://10.100.1.60:55443/{"id":1,"method":"set_power","params":["off"]} and see if that has less escape \ characters in it

I made it work finally, but only by editing the device.db file. Here it is what i found:
the working entry in the device.db file is:
`"offUrl":"[{\"item\":\"tcp://10.100.1.60:55443/{\\"id\\":1,\\"method\\":\\"set_power\\",\\"params\\":[\\"off\\"]}\r\n\",\"type\":\"tcpDevice\"}]"

So, if i use the web interface i had to add this entry:
tcp://10.100.1.60:55443/{"id":1,"method":"set_power","params":["off"]}\r\n
but the problem is that \r\n is translated in "\\r\\n\", instead of "\r\n\" in the device.db file.

@mihaifireball I don't think you need the \r\n at all in the call since this is pure tcp

If i remove it, it doesn't give me any error, but the light bulb is not reacting.
I think this issue was discussed here, too #153 .

Now I remember, will look at the encoding when devices are saved.

This issue is not fixed, right? because i still have to delete manually 2 backslashes before \r and two before \n on 4.1.4 release.

No updates to this yet

I created some shell-scripts to play with the Yeelight and use them as wrappers inside HA-Bridge

@mihaifireball The next version of ha-bridge will support \r \n and others

Was this page helpful?
0 / 5 - 0 ratings