[Plugin now available in Beta] Help with Yeelight Bulb

Moderator: leecollings

Post Reply
farhanito
Posts: 34
Joined: Friday 19 August 2016 5:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

[Plugin now available in Beta] Help with Yeelight Bulb

Post by farhanito »

hi,

i'm barely new here, so bare with me.
can anyone helps with integrating Yeelight bulbs with domoticz.
i can already control the bulb, but i got no idea how to get its status on domoticz. :roll:
attached below is the official documentation of the bulbs
https://www.yeelight.com/en_US/developer

thanks
Yeelight_Inter-Operation_Spec.pdf
(315.44 KiB) Downloaded 553 times
Last edited by farhanito on Friday 21 October 2016 10:18, edited 1 time in total.
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: Help with Yeelight Bulb

Post by corbin »

Hi, How are you controlling the bulb now, is it through the Yeelight app?
Regards,
Corbin
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Help with Yeelight Bulb

Post by Derik »

is this compatible with a supported hardware???? { Order i 1 ]
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: Help with Yeelight Bulb

Post by corbin »

Not yet, but they look to be easy to control from the linked pdf.
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
farhanito
Posts: 34
Joined: Friday 19 August 2016 5:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Help with Yeelight Bulb

Post by farhanito »

corbin wrote:Hi, How are you controlling the bulb now, is it through the Yeelight app?
Regards,
Corbin
Hi,

Currently by sending proper json message using Bash,

Code: Select all

printf "{json message}\r\n" > /dev/tcp/[bulb IP]/[port]
Not enough skill to do it in lua or python, still learning though
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: Help with Yeelight Bulb

Post by corbin »

Well I've ordered some of these bulbs, and hope to get them working with Domoticz - will update with my findings.
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: Help with Yeelight Bulb

Post by corbin »

Hi farhanito,
My lights have arrived, and like you I was able to control them through sending commands.

To get the light status, I have used a lua script to send {"id":1,"method\":"get_prop","params":["power"]}\r\n to the light and then inspect the result. This works ok but only polls once a minute.

Can I ask why you want to get the status? for my setup I can't see a need - the switch on and off is ok.

regards,
Corbin
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Help with Yeelight Bulb

Post by Derik »

Perhaps some create a wiki... ...
Looks promising...
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
farhanito
Posts: 34
Joined: Friday 19 August 2016 5:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Help with Yeelight Bulb

Post by farhanito »

corbin wrote:
Can I ask why you want to get the status? for my setup I can't see a need - the switch on and off is ok.

regards,
Corbin
Well i guess it's the advantage of having a wifi bulb instead of IR/RF controlled switch. We can make sure our commands work, especially when you are not home.

Anyway, according to the spec...
Right after Yeelight smart LED joined the local network, it will announce its presence by
multi-casting a advertisement requests. The purpose of this message is to notify 3rd party
devices that smart LED is online and ready to serve control request. Without this
advertisement message, 3rd party devices would have to probe the network from time to
time in order to achieve PnP (plug and play), which is obviously power-consuming and
inefficient.
I wonder if we can make domoticz listen to this advertisement, instead of polling the bulb status every minutes.
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: Help with Yeelight Bulb

Post by corbin »

farhanito wrote:
Well i guess it's the advantage of having a wifi bulb instead of IR/RF controlled switch. We can make sure our commands work, especially when you are not home.
I see, would be useful in Domoticz, as it is I use the Yeelight app to know the status remotely.
farhanito wrote: I wonder if we can make domoticz listen to this advertisement, instead of polling the bulb status every minutes.
I think this could be done as a hardware plugin - https://www.domoticz.com/wiki/Developin ... are_plugin which is beyond my abilities at present.
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
farhanito
Posts: 34
Joined: Friday 19 August 2016 5:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Help with Yeelight Bulb

Post by farhanito »

Yes. The app itself is not bad at all. it even have a tasker plugin built-in.
Great bulb.

Thanks
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Help with Yeelight Bulb

Post by Derik »

got the light...
Some have a api / script or something..
Working in Domoticz?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
TwoEasy
Posts: 13
Joined: Friday 09 September 2016 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Help with Yeelight Bulb

Post by TwoEasy »

Any progress with this amazing bulb? I mean damn, it is so good! And the api is there.. I wish I had the skill to create a hardware for this in domoticz.

So far I am using it with tasker and that works very well. Only thing that could make it better is well.. It working with Domoticz :D
Derik
Posts: 1601
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Help with Yeelight Bulb

Post by Derik »

mmm ask yeelight for some help...
Get a answer:

Code: Select all

The API is not HTTP based, which means you can't just send a http request to the bulb and control it. 
Basically, the automation procedure includes two parts:
1. Dynamic discover.
2. Control and monitor.

The dynamic discover used a SSDP like protocol. You can send a multi-cast requust to local network and will get response from bulbs. The request and response are encoded in HTTP format but are transferred through UDP.

After discovering the bulb, you can establish a TCP connection to the bulb and control and monitor the bulb through control requests which is encoded in JSON.

This is the search response, the location will tell you the IP and port the bulb is listening, you should establish a TCP socket to this location and then send command through that socket.

HTTP/1.1 200 OK
Cache-Control: max-age=3600
Date:
Ext:
Location: yeelight://192.168.1.239:55443
Server: POSIX UPnP/1.0 YGLC/1
id: 0x000000000015243f
model: color
fw_ver: 18
support: get_prop set_default set_power toggle set_bright start_cf stop_cf set_scene
cron_add cron_get cron_del set_ct_abx set_rgb a
power: on
bright: 100
color_mode: 2
ct: 4000
rgb: 16711680
hue: 100
sat: 35
name: my_bulb

This is the control request encoded in JSON which is used to turn on the bulb.

{"id":1,"method":"set_power","params":["on", "smooth", 500]}
Only i do not ubderstand the ssdp protocol? Working with putty?
Or how do i send the request.

some one understand this..?
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
TwoEasy
Posts: 13
Joined: Friday 09 September 2016 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Help with Yeelight Bulb

Post by TwoEasy »

corbin wrote:Hi farhanito,
My lights have arrived, and like you I was able to control them through sending commands.

To get the light status, I have used a lua script to send {"id":1,"method\":"get_prop","params":["power"]}\r\n to the light and then inspect the result. This works ok but only polls once a minute.

Can I ask why you want to get the status? for my setup I can't see a need - the switch on and off is ok.

regards,
Corbin
Hello Corbin, how are your bulbs working?

I am very new to all this and understand some of lua. How would I by LUA replicate the "Sunrise" and "Sunset" scene from the app?

{"id":1,"method":"set_scene", "params": ["hsv", 300, 70, 100]} ?

Thanks
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: Help with Yeelight Bulb

Post by corbin »

TwoEasy wrote:
Hello Corbin, how are your bulbs working?

I am very new to all this and understand some of lua. How would I by LUA replicate the "Sunrise" and "Sunset" scene from the app?

{"id":1,"method":"set_scene", "params": ["hsv", 300, 70, 100]} ?

Thanks
Hi TwoEasy,
The bulbs are excellent, really impressed with the hardware quality, and the software and API.

To control the bulbs from lua, I used a console application I wrote in C# to send the actual commands (I'm running on Windows). I think you could do it natively in lua if you can use the socket library - viewtopic.php?t=3676

I'm also attempting to write a hardware plugin in C++, so that may be available some time in the future. I've got it to do the UDP broadcast to detect Yeelights on the network at this stage.
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
TwoEasy
Posts: 13
Joined: Friday 09 September 2016 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Help with Yeelight Bulb

Post by TwoEasy »

corbin wrote:
TwoEasy wrote:
Hello Corbin, how are your bulbs working?

I am very new to all this and understand some of lua. How would I by LUA replicate the "Sunrise" and "Sunset" scene from the app?

{"id":1,"method":"set_scene", "params": ["hsv", 300, 70, 100]} ?

Thanks
Hi TwoEasy,
The bulbs are excellent, really impressed with the hardware quality, and the software and API.

To control the bulbs from lua, I used a console application I wrote in C# to send the actual commands (I'm running on Windows). I think you could do it natively in lua if you can use the socket library - viewtopic.php?t=3676

I'm also attempting to write a hardware plugin in C++, so that may be available some time in the future. I've got it to do the UDP broadcast to detect Yeelights on the network at this stage.

Thanks very much for your reply! I dont fully understand what the lua socket is. Would it be possible to send a command from within domoticz by calling a lua script?
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: Help with Yeelight Bulb

Post by corbin »

You need a way to send the commands over TCP, and I don't think that is possible with the lua setup that comes with Domoticz. So you will need to add this capability someway. Once you have that capability, then yes you could initiate the command from a lua script.

I think another way would be to call a bash script as farhanito showed above, using the lua os.execute command. Or using python, there is an example available on the yeelight website.
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
User avatar
corbin
Posts: 463
Joined: Saturday 20 August 2016 22:57
Target OS: Windows
Domoticz version: Beta
Location: Brisbane, Australia
Contact:

Re: Help with Yeelight Bulb

Post by corbin »

Derik wrote: Only i do not ubderstand the ssdp protocol? Working with putty?
Or how do i send the request.

some one understand this..?
Are you able to run a command like this?

Code: Select all

printf '{"id":1,"method":"toggle","params":[]}\r\n' > /dev/tcp/192.168.0.2/55443
change 192.168.0.2 to the IP address of your bulb. Also check that you have developer mode enabled on the bulb. The quotes may need escaping, I'd check myself but don't have a Linux install handy.
Question about the Xiaomi Gateway in Domoticz? Please check the Wiki first: https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara)
TwoEasy
Posts: 13
Joined: Friday 09 September 2016 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Help with Yeelight Bulb

Post by TwoEasy »

corbin wrote:You need a way to send the commands over TCP, and I don't think that is possible with the lua setup that comes with Domoticz. So you will need to add this capability someway. Once you have that capability, then yes you could initiate the command from a lua script.

I think another way would be to call a bash script as farhanito showed above, using the lua os.execute command. Or using python, there is an example available on the yeelight website.
Thanks for your information, pointing me in the right direction :D I will see what I can do, I am not at my homeautomation base at the moment to experiment..

Also looking forward to a possible plugin :)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests