I'm looking to give me and my wife a warning through Telegram whenever we're both away and the alarm is not armed.
Is this correct? I can read and understand LUA / Dzvents, but writing it myself...
Switch IDX 394 is a presence dummy switch.
I also wish to send this warning only once, not again every minute as the value stays "true"... I hope this is scripted correct?
Code: Select all
return {
active = true,
on = {
timer = {
'every minute',
}
},
data =
{
Alerts = { initial = 0 },
},
logging =
{
level = domoticz.LOG_INFO,
marker = "AlarmPresenceCheck"
},
execute = function(domoticz, device)
local switch = domoticz.devices(394) -- virtual switch for presence
if (switch.state == 'Off' and switch.lastUpdate.minutesAgo >= 30 and domoticz.security == domoticz.SECURITY_DISARMED and domoticz.data.Alerts == 0) then
domoticz.notify('AlarmCheck','Er is al ' .. switch.lastUpdate.minutesAgo .. ' minuten niemand thuis en het alarm staat nog uit!',domoticz.PRIORITY_HIGH,nil,nil,domoticz.NSS_TELEGRAM,0)
domoticz.data.Alerts = domoticz.data.Alerts + 1
elseif (switch.state == 'Off' and switch.lastUpdate.minutesAgo >= 30 and domoticz.security == domoticz.SECURITY_DISARMED and domoticz.data.Alerts ~= 0) then
domoticz.log('Geen melding meer, counter staat al op ' ..domoticz.data.Alerts)
else
if (domoticz.data.Alerts ~= 0) then
domoticz.data.Alerts = 0
domoticz.log('Reset, counter staat terug op ' ..domoticz.data.Alerts)
else
domoticz.log('Niets te doen!')
end
end
end
}