I wondered if I could make a blockly script which turns of a Yeelight LED Bulb lamp with a 433mhz remote button.
First I learned the 433 mhz remote button in the switches page, and it created a on\off switch automatically.
I called the switch "Yeelights AB", and turning the switch on and off with the remote button is working.
I also have a Yeelight LED Bulb RGBWW wifi lamp.
For this lamp I have created a light/switch, selector switch, dimmer (Hoek Lamp 1) with a virtual switch.
With a dzVents script I control this lamp. Also working (see code below)
Code: Select all
return {
active = true,
on = {
devices = { 'Hoek Lamp 1'}
},
execute = function(domoticz, device)
port = '55443'
yeelights = {'192.168.1.57'}
for ix, ipadress in ipairs(yeelights) do
if (device.state == 'Off') then
domoticz.log('Turning light off')
runcommand = "sudo echo -ne '{\"id\":1,\"method\":\"set_power\", \"params\":[\"off\", \"smooth\", 500]}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
os.execute(runcommand)
else
domoticz.log('Changing brightness level')
brightvalue = (device.level - 1);
runcommand = "sudo echo -ne '{\"id\":1, \"method\":\"set_scene\",\"params\":[\"ct\",2950, " .. brightvalue .. "]}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
os.execute(runcommand)
end
end
end
}
What am I missing here?
Greetzzz,
Gerben