Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xiaomi Yeelight support - TCP requests to use \n \r #415

Closed
mihaifireball opened this issue Jan 28, 2017 · 16 comments
Closed

Xiaomi Yeelight support - TCP requests to use \n \r #415

mihaifireball opened this issue Jan 28, 2017 · 16 comments
Assignees
Milestone

Comments

@mihaifireball
Copy link

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!

@bwssytems
Copy link
Owner

Yep, #296, asked for this as well

@mihaifireball
Copy link
Author

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

@bwssytems
Copy link
Owner

Is there an error message that occurs in the log?

@mihaifireball
Copy link
Author

mihaifireball commented Jan 29, 2017

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...

@bwssytems
Copy link
Owner

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

@mihaifireball
Copy link
Author

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

@bwssytems
Copy link
Owner

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

@bwssytems
Copy link
Owner

bwssytems commented Jan 30, 2017

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

@bwssytems bwssytems self-assigned this Jan 30, 2017
@mihaifireball
Copy link
Author

mihaifireball commented Jan 30, 2017

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.

@bwssytems
Copy link
Owner

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

@mihaifireball
Copy link
Author

mihaifireball commented Jan 30, 2017

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 .

@bwssytems
Copy link
Owner

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

@mihaifireball
Copy link
Author

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.

@bwssytems
Copy link
Owner

No updates to this yet

@darth-hp
Copy link

darth-hp commented Mar 7, 2017

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

@bwssytems
Copy link
Owner

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

@bwssytems bwssytems added this to the V4.2.1 milestone Mar 8, 2017
@bwssytems bwssytems changed the title Xiaomi Yeelight support Xiaomi Yeelight support - TCP requests to use \n \r Mar 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants