Page 1 of 18
[Plugin now available in Beta] Help with Yeelight Bulb
Posted: Friday 19 August 2016 5:49
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.
attached below is the official documentation of the bulbs
https://www.yeelight.com/en_US/developer
thanks
Re: Help with Yeelight Bulb
Posted: Saturday 20 August 2016 23:01
by corbin
Hi, How are you controlling the bulb now, is it through the Yeelight app?
Regards,
Corbin
Re: Help with Yeelight Bulb
Posted: Saturday 20 August 2016 23:26
by Derik
is this compatible with a supported hardware???? { Order i 1 ]
Re: Help with Yeelight Bulb
Posted: Saturday 20 August 2016 23:41
by corbin
Not yet, but they look to be easy to control from the linked pdf.
Re: Help with Yeelight Bulb
Posted: Sunday 21 August 2016 3:45
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
Re: Help with Yeelight Bulb
Posted: Monday 22 August 2016 10:47
by corbin
Well I've ordered some of these bulbs, and hope to get them working with Domoticz - will update with my findings.
Re: Help with Yeelight Bulb
Posted: Sunday 28 August 2016 0:08
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
Re: Help with Yeelight Bulb
Posted: Sunday 28 August 2016 12:05
by Derik
Perhaps some create a wiki... ...
Looks promising...
Re: Help with Yeelight Bulb
Posted: Sunday 28 August 2016 16:55
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.
Re: Help with Yeelight Bulb
Posted: Monday 29 August 2016 8:54
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.
Re: Help with Yeelight Bulb
Posted: Tuesday 30 August 2016 11:51
by farhanito
Yes. The app itself is not bad at all. it even have a tasker plugin built-in.
Great bulb.
Thanks
Re: Help with Yeelight Bulb
Posted: Thursday 08 September 2016 18:49
by Derik
got the light...
Some have a api / script or something..
Working in Domoticz?
Re: Help with Yeelight Bulb
Posted: Friday 09 September 2016 18:32
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
Re: Help with Yeelight Bulb
Posted: Saturday 10 September 2016 7:33
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..?
Re: Help with Yeelight Bulb
Posted: Sunday 11 September 2016 17:28
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
Re: Help with Yeelight Bulb
Posted: Monday 12 September 2016 10:58
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.
Re: Help with Yeelight Bulb
Posted: Monday 12 September 2016 12:00
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?
Re: Help with Yeelight Bulb
Posted: Monday 12 September 2016 12:23
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.
Re: Help with Yeelight Bulb
Posted: Monday 12 September 2016 12:37
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.
Re: Help with Yeelight Bulb
Posted: Monday 12 September 2016 18:18
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
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