Bospieper wrote: ↑Saturday 14 November 2020 19:27
Hi Waaren,
I give you an example of one of my scripts. Maybe you can piont me out in the right direction.
Sure,
this extra script will be triggered on a master switch
Code: Select all
return
{
on =
{
timer =
{
'at 05:13', -- a quiet time on a moment that you know everyone is sleeping (or at least should) to reset the master switch
},
devices =
{
'masterSwitch', -- virtual switch to trigger a Scene that will switch all lights off
},
},
logging =
{
level = domoticz.LOG_DEBUG -- set to domoticz.LOG_ERROR when all ok
marker = 'One switch to rule them all',
},
execute = function(dz, item )
local master = dz.devices('masterSwitch')
local allLights = dz.scenes('All lights Off')
if item.isTimer then
master.switchOff().checkFirst().silent()
elseif item.active then
allLights.switchOn() -- trigger the scene that switches off all lights
end
end
}
this is your modified script that will evaluate the state of the masterswitch to decide if any further action is required
Code: Select all
return
{
active = true,
on =
{
timer =
{
'20 minutes before sunset',
'between sunset and 60 minutes after sunset',
'between 60 minutes after sunset and 120 minutes after sunset',
'between 120 minutes after sunset and 23:50',
'at 23:50'
},
devices =
{
'light'
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to domoticz.LOG_ERROR when all ok
marker = 'Lamp bank',
},
execute = function(dz, timer )
local master = dz.devices('masterSwitch') -- virtual switch to trigger a Scene that will switch all lights off
if master.active then
dz.log('Rest of script will be ignored because master switch is activated and every light should stay off',dz.LOG_DEBUG )
return
end
local light = dz.devices('Switch- lamp boven bank')
if dz.time.matchesRule('20 minutes before sunset') then
light.dimTo(5)
elseif dz.time.matchesRule('between sunset and 60 minutes after sunset') then
light.dimTo(20)
end
if dz.time.matchesRule('between 60 minutes after sunset and 120 minutes after sunset') then
light.dimTo(25)
elseif dz.time.matchesRule('between 120 minutes after sunset and 23:50') then
light.dimTo(15)
end
if dz.time.matchesRule('at 23:50') then
light.switchOff().checkFirst()
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki