I have a vision sirene coupled to my alarmsystem
the problem is that this siren only fires once for 1 minute.
I want it to fire 4 or 5 times for 1 minute.
Therefore I have made a LUA script to get this done.
I use a variable x which should be risen with 1 after 60 seconds.
Also after 60 sec the siren fires again.
When x=5 siren should be switchwed of.
I have tried a lot of coding but nothing works.
Could somebody help me?
Code: Select all
-- ~/domoticz/scripts/lua/script_device_AlarmBoven.lua
-- deze functie berekend de verstreken tijd
function timedifference(s)
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
t1 = os.time()
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = os.difftime (t1, t2)
return difference
end
commandArray = {}
uur = tonumber(os.date("%H"));
min = tonumber(os.date("%M"));
if (otherdevices['Alarm Boven']=='On' and (devicechanged['Logeerkamer']=='Open' or devicechanged['Behandelkamer']=='Open')) then
commandArray ["Sirene"]='On'
commandArray['SendEmail']='Alarm#Er is een raam boven open gegaan#[email protected]'
commandArray['SendEmail']='Alarm#Er is een raam boven open gegaan#[email protected]'
end
timeon2 = 60
if (otherdevices['Sirene']=='On' and x==nil) then
difference = timedifference(otherdevices_lastupdate['Sirene'])
print ("Verschil= " .. difference)
if (difference > timeon2 and difference < (timeon2 + 60) ) then
if (x==nil) then
x=1
print("x is " .. x)
end
commandArray ["Sirene"]='On'
end
end
return commandArray
Jan