Set Dimmer/Switch default to percentage
Posted: Monday 31 December 2018 17:11
Hi,
I have created a Selector Switch/Dimmer for a Yeelight LED Bulb RGBWW lamp.
In dzVents have created a script to dim the brightness of the lamp.
The script works but I want the slider of the Dimmer always to start at 25% when the Lamp is turned on again.
The current script remembers, when the lamp is set to OFF, the last slider location.
I already tried the device.dimTo(25) function, but this triggers strange behaviour, because dimming also to turn on the lamp.
Can somebody help me with this?
I have created a Selector Switch/Dimmer for a Yeelight LED Bulb RGBWW lamp.
In dzVents have created a script to dim the brightness of the lamp.
The script works but I want the slider of the Dimmer always to start at 25% when the Lamp is turned on again.
The current script remembers, when the lamp is set to OFF, the last slider location.
I already tried the device.dimTo(25) function, but this triggers strange behaviour, because dimming also to turn on the lamp.
Can somebody help me with this?
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\", 3000, " .. brightvalue .. "]}\\r\\n' | nc -w1 " ..ipadress.." " ..port..""
-- device.dimTo(25);
os.execute(runcommand)
end
end
end
}