I have added a Yeelight RGBWW bulb to domoticz as an RGBWW Color Switch.
I want to control the brightness level of the switch.
On the domoticz/yeelight page I found a LUA script which I use:
Code: Select all
return {
active = true,
on = {
devices = { 'Tafel Lamp'}
},
execute = function(domoticz, device)
port = '55443'
yeelights = {'192.168.1.54'}
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
}Code: Select all
brightvalue = (device.level - 1);Is it also possible to set an initial dimmer value of e.g. 5% i this script?