Premade scenes in the script is: Sunrise, Sunset, Calm, Alarm, Notify, Police 1, Police 2, Candle Flicker, Birthday Party.
Creata a dummy selector switch.
Copy script below to Eventseditor.
Change settings part to suit your needs.
Add level names to selector switch.
Code: Select all
--[[
Yeelight Scene Selector
Project: Domoticz
Interpreter: dzVents, Device
Author: DewGew
Version: 20190308
]]--
-- Settings
local selector= 123 --Selector Switch IDX
local yeelights = {'192.168.xxx.xxx', '192.168.xxx.xx'} -- yeelights ipnumbers
local port = '55443'
-- Put the level names here:
local level10 = 'Sunrise'
local level20 = 'Sunset'
local level30 = 'Calm'
local level40 = 'Alarm'
local level50 = 'Notify'
local level60 = 'Police 1'
local level70 = 'Police 2'
local level80 = 'Candle'
local level90 = 'Birthday Party'
-- End Settings
local sunrise = '[\"cf\",2,1,\"50,2,4000,1,900000,2,4000,100\"]'
local sunset = '[\"cf\",2,2,\"50,2,4000,75,900000,2,4000,1\"]'
local alarm = '[\"cf\",0,0,\"500,1,16711696,100,500,1,16711696,10\"]'
local calm = '[\"cf",0,0,\"2000,1,255,70,2000,1,255,100,5000,1,255,70,3000,1,13369548,100,3000,1,13369548,10\"]'
local notify = '[\"cf",0,0,\"1000,2,2700,100,1000,7,0,0,1000,2,2700,10,1000,7,0,0\"]'
local police_1 = '[\"cf",0,0,\"1000,1,1002236,100,1000,7,0,0,1000,1,16711696,10,1000,7,0,0\"]'
local police_2 = '[\"cf",0, 0,\"1000,1,1002236,100,1000,1,1002236,10,1000,1,16711696,50,1000,1,1002236,30,1000,7,0,0,1000,1,16711696,10,1000,7,0,0\"]'
local candle_flicker = '[\"cf",0,0,\"800,2,2700,50,800,2,2700,30,1200,2,2700,80,800,2,2700,60,1200,2,2700,90,2400,2,2700,50,1200,2,2700,80,800,2,2700,60,400,2,2700,70\"]'
local birthday_party = '[\"cf",0,0,\"1996,1,14438425,80,1996,1,14448670,80,1996,1,11153940,80\"]'
return {
on = {
devices = {selector}
},
execute = function(domoticz, device)
for ix, ipadress in ipairs(yeelights) do
if (device.state == 'Off') then
runcommandoff = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"off\", \"smooth\", 500]}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
os.execute(runcommandoff)
elseif (device.state == level10) then
runcommand = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":" ..sunrise.. "}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
os.execute(runcommand)
elseif (device.state == level20) then
runcommand = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":" ..sunset.. "}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
os.execute(runcommand)
elseif (device.state == level30) then
runcommand = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":" ..calm.. "}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
os.execute(runcommand)
elseif (device.state == level40) then
runcommand = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":" ..alarm.. "}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
os.execute(runcommand)
elseif (device.state == level50) then
runcommand = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":" ..notify.. "}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
os.execute(runcommand)
elseif (device.state == level60) then
runcommand = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":" ..police_1.. "}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
os.execute(runcommand)
elseif (device.state == level70) then
runcommand = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":" ..police_2.. "}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
os.execute(runcommand)
elseif (device.state == level80) then
runcommand = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":" ..candle_flicker.. "}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
os.execute(runcommand)
elseif (device.state == level90) then
runcommand = "sudo echo -ne '{\"id\":1,\"method\":\"set_scene\", \"params\":" ..birthday_party.. "}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
os.execute(runcommand)
end
domoticz.log('Set light to ' ..device.state..' mode',domoticz.LOG_FORCE)
end
end
}