I've rebuild this script for my purpose, but just need one additional functionality.
When i'm switch on the alarm mode i'm still standing in the room and of course the PIR will be activated.
Is it possible to have a delay to give time to leave the room without making any dummy switches ?
This is my script so far
Code: Select all
local scriptVar = '-=# inbraak #=-'
return {
on = {
devices = {
'Sensor - Achterdeur', -- door contact in de woonkamer
'Sensor - Garagedeur', -- door contact in de garage
'PIR Sensor', -- PIR Sensor
}
},
ustomEvents =
{
scriptVar,
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = '-=# inbraak #=-',
},
execute = function(dz, item)
local Achterdeur = dz.devices('Sensor - Achterdeur')
local Garagedeur = dz.devices('Sensor - Garagedeur')
local PIR = dz.devices('PIR Sensor')
local alarmmode = dz.devices('Alarm mode')
local lamp = dz.groups('Woonkamer') -- Alle lampen in woonkamer
local delay = 10
if (Achterdeur.state == 'On' or Garagedeur.state == 'On' or PIR.state == 'On' ) and alarmmode.state == 'On' then
dz.emitEvent(scriptVar).afterSec(delay)
lamp.switchOn()
--dz.log('Inbraak (thuis)!!',item.name .. ' geactiveerd',dz.LOG_DEBUG)
dz.log(item.name .. ' Alarm switched On',dz.LOG_DEBUG)
dz.notify('Inbraak (thuis)!!',item.name .. ' geactiveerd',dz.PRIORITY_HIGH)
end
end
}
}