Yeelight

From Domoticz
Jump to: navigation, search

Yeelight LED Bulbs

These are WiFi enabled LED Bulbs that come with excellent supporting software, and can also be controlled from Domoticz. Currently working with the White and Color LED Bulbs http://www.yeelight.com/en_US

Yeelight bulb.jpg

Compatible Lights

  1. LED Bulb (White)
  2. LED Bulb (Color)
  3. LED Desk Lamp
  4. Lightstrip (Color)
  5. LED Ceiling Light

The Bedside Lamp is not compatible with this Domoticz plugin as it uses Bluetooth instead of WiFi.

Adding Yeelight Bulbs in Domoticz

You first need to enable developer mode on your bulbs through the Yeelight Android or iOS App. http://www.yeelight.com/en_US/developer. If developer mode is not enabled, Domoticz will not be able to communicate with your lights.

Then go to Setup -> Hardware, and choose the Yeelight LED Type. Enter a name (such as 'Yeelight Controller'), and then click Add.

Note that the IP address of the light is used as the device ID in Domoticz. For that reason, use static IP addresses for your lights (assign via MAC address reservation on your router)

Yeelight-hardware1.png

After a minute, Domoticz should start detecting your bulbs and be visible under Setup -> Devices

Yeelight-devices.png

If your Yeelight is not found automatically, try adding it manually by clicking the 'Add Light' button

Yeelight-addlight.PNG

Adding White Temperature Control (RGBW Bulb Only)

First You have to add a dummy selector switch, and set it as a dimmer on switch page

White temp yeelight.PNG

And get your yeelight IP (Fing app on Android do the job)

Then create a LUA Script via Domoticz event Editor:

This script turn Bulb ON if you choose a value from 1% to 100%. This script turn Bulb OFF if you set the dimmer to 0%. This Dimmer can be call on scene, groupe, events, or API call

commandArray = {}
DomDevice = 'nameofyourdummyselectorsetasdimmer';
IP = 'youryeelightip';
PORT = '55443'
 
if devicechanged[DomDevice] then
   if(devicechanged[DomDevice]=='Off') then 
     DomValue = 0;
     runcommandoff = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"off\", \"smooth\", 500]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";;
     os.execute(runcommandoff);
   else
     DomValue = otherdevices_svalues[DomDevice];   
   CalcValue = ((DomValue-1) * 48)+1700;
   end
   if CalcValue==nil then CalcValue=0 end
     runcommand = " sudo echo -ne '{\"id\":1, \"method\":\"set_scene\",\"params\":[\"ct\"," .. CalcValue .. ", 75]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
   os.execute(runcommand);
   print(runcommand)
   print("Color Temp= "..CalcValue);
end
return commandArray

Adding simple Dimmer Control (RGBW Bulb Only)

First You have to add a dummy selector switch, and set it as a dimmer on switch page

Yeelight dimmer.PNG

And get your yeelight IP (Fing app on Android do the job)

Then create a LUA Script via Domoticz event Editor:

This Script change Brightness Bulb from 0 to 100% This Script turn ON Bulb set it to dimmer value and White Temperature choose on the previous slider. This Dimmer can be call on scene, groupe, events, or API call

commandArray = {}
DomDevice = 'Yeelight Dimmer';
TempDevice = 'White Temp Yeelight'
IP = '192.168.0.207';
PORT = '55443'
 
if devicechanged[DomDevice] then
   if(devicechanged[DomDevice]=='Off') then 
     DomValue = 0;
     runcommandoff = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"off\", \"smooth\", 500]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";;
     os.execute(runcommandoff);
   else
    TempValue = otherdevices_svalues[TempDevice];   
    CalcValue = ((TempValue-1) * 48)+1700;
    DomValue = otherdevices_svalues[DomDevice]; 
   end
   if CalcValue==nil then CalcValue=0 end
 
     runcommand = "sudo echo -ne '{\"id\":1, \"method\":\"set_scene\", \"params\":[\"ct\", " .. CalcValue .. ", " .. DomValue .. "]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
      os.execute(runcommand);
   print(runcommand)
   print("bright value= "..DomValue);
end
return commandArray

Adding Scenes

Yeelight Bulb offer an API, who allow use to made scene : http://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf

Idea here is to reproduce scene who are stored on Yeelight App.

For White Bulb (Mono)

First You have to add a dummy selector switch and set it like this :

Selector.PNG

And get your yeelight IP (Fing app on Android do the job)

Then create a LUA Script via Domoticz event Editor, don't forget to set your script as de device one !

commandArray = {}
DomDevice = 'Yeelight Mono Scenes';
IP = 'Your Yeelight IP';
PORT = '55443'
 
if devicechanged[DomDevice]=='Off' then -- turn off
     runcommandoff = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"off\", \"smooth\", 500]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
     os.execute(runcommandoff);
   --  print(runcommandoff) 
 
     elseif devicechanged[DomDevice]=='Sunrise' then -- turn to sunrise mode from 0 to 100% on 15 minutes
     runcommandsunrise = " sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"cf\",2,1,\"50,2,4000,1,900000,2,4000,100\"]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
     os.execute(runcommandsunrise);
   --  print(runcommandsunrise) 
 
     elseif devicechanged[DomDevice]=='Sunset' then -- turn to sunset mode from 100% to 0 on 15 minutes and turn off bulb
     runcommandsunset = " sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"cf\",2,2,\"50,2,4000,75,900000,2,4000,1\"]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
     os.execute(runcommandsunset);
   --  print(runcommandsunset) 
 
    elseif devicechanged[DomDevice]=='Bright 25%' then -- turn to 25% bright
     runcommand25 = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"bright\", 25, 500]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
     os.execute(runcommand25);
    -- print(runcommand25) 
 
     elseif devicechanged[DomDevice]=='Bright 50%' then -- turn to 50% bright
     runcommand50 = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"bright\", 50, 500]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
     os.execute(runcommand50);
    -- print(runcommand50) 
 
    elseif devicechanged[DomDevice]=='Bright 75%' then -- turn to 75% bright
     runcommand75 = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"bright\", 75, 500]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
     os.execute(runcommand75);
    -- print(runcommand75) 
 
    elseif devicechanged[DomDevice]=='Baby' then -- turn to Baby Mode
     runcommandbaby = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"bright\", 1, 500]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
     os.execute(runcommandbaby);
    -- print(runcommandbaby) 
 
    elseif devicechanged[DomDevice]=='4-7-8' then -- turn to 4-7-8 mode
     runcommand478 = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":[\"cf_\",24,2,\"4000,2,4000,30,7000,2,4000,10,8000,2,4000,1\"]}\\r\\n' | nc -w1 " ..IP.." " ..PORT.."";
     os.execute(runcommand478);
    -- print(runcommand478) 
 
end
return commandArray

I add a 4-7-8 fonction, who is a helping to sleep methode base on breath : http://www.medicaldaily.com/life-hack-sleep-4-7-8-breathing-exercise-will-supposedly-put-you-sleep-just-60-332122

Exhale completely through your mouth, making a whoosh sound.

Close your mouth and inhale quietly through your nose to a mental count of four : light is on 30% bright

Hold your breath for a count of seven : light is on 10% bright

Exhale completely through your mouth, making a whoosh sound to a count of eight : light is on 1% bright

After 8 cycles : Bulb will turn OFF because you are sleeping