Dimmer Light Daytime
Posted: Saturday 08 February 2020 0:10
Inglese
Hi everyone I use this code to dim the lights according to the time and some switches, it works perfectly, only it sends the z-wave network in tilt by sending the same command twice both when I turn on the light and when off here is a log screen? is there any way to improve the code? thank you
Hi everyone I use this code to dim the lights according to the time and some switches, it works perfectly, only it sends the z-wave network in tilt by sending the same command twice both when I turn on the light and when off here is a log screen? is there any way to improve the code? thank you
Code: Select all
return
{
on =
{
devices = { 'Studio'},
},
logging =
{
-- level = domoticz.LOG_DEBUG,
-- marker = 'dim based on time'
},
execute = function(dz, item)
dz.log('Studio stato: ' .. item.state,dz.LOG_DEBUG)
if item.active and item.lastUpdate.secondsAgo > 6 then
if dz.time.matchesRule('at 06:30-15:00') then
item.dimTo(10).silent()
end
if dz.time.matchesRule('at 15:00-17:00') then
item.dimTo(20).silent()
end
if dz.time.matchesRule('at 17:00-21:30') then
item.dimTo(30).silent()
end
if dz.time.matchesRule('at 21:30-22:30') then
item.dimTo(20).silent()
end
if dz.time.matchesRule('at 22:30-06:30') then
item.dimTo(10).silent()
end
if dz.devices('TV Studio').state == 'Paused' then
item.dimTo(1).silent()
end
if dz.devices('Ospiti').state == 'On' then
item.dimTo(80).silent()
end
if dz.devices('Modalità Notte').state == 'On' then
item.dimTo(1).silent()
end
if dz.devices('Buonanotte').state == 'On' then
item.dimTo(1).silent()
end
elseif item.lastUpdate.secondsAgo > 6 then
item.dimTo(0).silent()
end
end
}