How to combine two script (on and off) based on active timer
Posted: Friday 18 January 2019 11:25
Hi,
How do i combine two scripts (group on and off) based on the active timer?
I like to switch the group on when timer 0 is active and when the other timers are active i like to switch it off.
I think a got all the rules and only need:
- an correction in my script to get the current timer
- my script does not execute
How do i combine two scripts (group on and off) based on the active timer?
I like to switch the group on when timer 0 is active and when the other timers are active i like to switch it off.
I think a got all the rules and only need:
- an correction in my script to get the current timer
- my script does not execute
Code: Select all
local trigger0 = "at 12:00 on mon,tue,wed,thu,fri,sat, sun" -- for testing
local trigger1 = "15 minutes before sunset on mon,tue,wed,thu,fri,sat,sun"
local trigger2 = "at 23:00 on mon,tue,wed,thu,sun"
local trigger3 = "at 23:45 on fri,sat"
return {
on = {
timer = {
trigger0,
trigger1,
trigger2,
trigger3
}},
logging = { level = domoticz.LOG_DEBUG , -- Uncomment to override the dzVents global logging setting
marker = "Timers"},
execute = function(dz,device, triggerInfo)
local scriptnaam= 'DZ_avond_start' -- kan dit niet automatisch?
--local activetimer= triggerInfo.trigger -- is this the active timertrigger ?
local activetimer= device.trigger -- is this the active timertrigger ?
if activetimer ~= trigger0 then -- als activetimer contains sunset then on
dz.groups('Sfeerverlichting').switchOn()
dz.groups('Buiten_sfeerverlichting').switchOn()
else
dz.groups('Sfeerverlichting').switchOff()
dz.groups('Buiten_sfeerverlichting').switchOff()
end
dz.log("Script: " .. scriptnaam .. " groepen wordt uitgevoerd....", dz.LOG_INFO)
end
}