This user variable (Alarm) contains the following (example): 'vr 06:05'
My goal is to use a dzVents LUA to turn a switch on, I created the following script and I want to know if the timer part will work like this:
Code: Select all
function split(s, delimiter)
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
return result;
end
AlarmTotal = uservariables['Alarm']
rslt = split(AlarmTotal, " ")
TempDag = rslt[1]
Tijd = rslt[2]
if TempDag == 'ma' then Dag = "1" end
if TempDag == 'di' then Dag = "2" end
if TempDag == 'wo' then Dag = "3" end
if TempDag == 'do' then Dag = "4" end
if TempDag == 'vr' then Dag = "5" end
currenttime = tostring(os.date("%H:%M"))
currentday = tostring(os.date("%w"))
--print('Alarm Dag: '..Dag)
--print('Alarm Tijd: '..Tijd)
--print('Huidige Tijd: '..currenttime)
--print('Huidige Day: '..currentday)
return {
on = {
timer = {
'at '..Tijd..' on '..Dag,
}
},
execute = function(domoticz, device)
domoticz.log('Turn on switch', domoticz.LOG_INFO)
domoticz.device('Alarm Trigger').SwitchOn().forMin(5)
end
}