Turning on Alarm autoomatically - help needed
Moderator: leecollings
-
- Posts: 12
- Joined: Sunday 19 May 2019 21:16
- Target OS: -
- Domoticz version:
- Contact:
Turning on Alarm autoomatically - help needed
Hi all,
I am looking for a simple way using dzvents to turn on my alarm system when no presence is detected.
I have found in the forum few examples but they are based on blocky.
Basically I have a couple of motion sensors, + systemalivechecker script to detect if mobile phones are connected to the router, or the TV is switched on.
I would like to switch the alarm on when after i.e. 20 minutes of pinger off and motion sensors no activity.
Can somebody help on this ?
Thanks in advance
Francesco
I am looking for a simple way using dzvents to turn on my alarm system when no presence is detected.
I have found in the forum few examples but they are based on blocky.
Basically I have a couple of motion sensors, + systemalivechecker script to detect if mobile phones are connected to the router, or the TV is switched on.
I would like to switch the alarm on when after i.e. 20 minutes of pinger off and motion sensors no activity.
Can somebody help on this ?
Thanks in advance
Francesco
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Turning on Alarm autoomatically - help needed
What does the systemalivechecker steer ? Does it set a uservariable or a virtual switch /sensor ?FrancescoS wrote: ↑Sunday 19 May 2019 21:28 I am looking for a simple way using dzvents to turn on my alarm system when no presence is detected.
Basically I have a couple of motion sensors, + systemalivechecker script to detect if mobile phones are connected to the router, or the TV is switched on.
I would like to switch the alarm on when after i.e. 20 minutes of pinger off and motion sensors no activity.
And what is domoticz version are you on ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 12
- Joined: Sunday 19 May 2019 21:16
- Target OS: -
- Domoticz version:
- Contact:
Re: Turning on Alarm autoomatically - help needed
Systemlivechecker switch on and off a virtual switch.
I am on dzvents 2.4.0
I am on dzvents 2.4.0
-
- Posts: 361
- Joined: Monday 25 December 2017 23:06
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: Paris
- Contact:
Re: Turning on Alarm autoomatically - help needed
Hi
I have a similar use case to put my heater on low when there is nobody at home and reverse.
And I have very poor info if somebody is home, so I need a lag before triggering the heater.
I have one script to set a evaluate if somebody with 4 values: nobody / perhaps nobody (during your 20 min) / somebody / somebody just arrived
Those 4 values allow to trigger other scripts
Note: I started something about a manual mode, but didn't go the end
and another script to pilot my heater
Maybe you could use those scripts for your use case
I have a similar use case to put my heater on low when there is nobody at home and reverse.
And I have very poor info if somebody is home, so I need a lag before triggering the heater.
I have one script to set a evaluate if somebody with 4 values: nobody / perhaps nobody (during your 20 min) / somebody / somebody just arrived
Those 4 values allow to trigger other scripts
Code: Select all
--[[
a dz dzVents Script to evaluate if anybody is at home to trigger something (heater for instance...)
--]]
local DOMAIN = 'YaQuelquUn' -- For logging, as you like!
local SBDY_MANUAL = 425 -- Dummy device to force the presence
local SBDY_RESULT= 451 -- Dummy device to store the result
local SBDY_SENSORS = {395, 385, 369} -- All the SENSORS to detect people
local DEVICES = {395, 385, 369, 203} -- All the devices to trigger the script
local l_maxAuto = 3600*2 -- seconds ; time keep on light on when switch on by SENSORS
local l_maxManual = 3600*4 -- seconds ; time keep on light on when switch on by switch / bigger than l_max_SENSORS
local TIME_INTERVAL = 'every 10 minutes' -- Period to check if nobody, l_maxAuto and l_maxManual to take into accoutn
return {
active = true,
logging = {
level = domoticz.LOG_ERROR, -- Select one of LOG_DEBUG, LOG_INFO, LOG_ERROR, LOG_FORCE to override system log level
marker = DOMAIN
},
on = {
devices = DEVICES,
timer = {TIME_INTERVAL},
},
execute = function(dz, the_device, triggerInfo)
local LOG_LEVEL = dz.LOG_INFO -- LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE
dz.log('*** start ' .. triggerInfo.type , dz.LOG_FORCE)
local l_sensorsOn = false
local l_maxOn = l_maxAuto + l_maxManual -- to be sure it is >
for i, f_sensors in pairs(SBDY_SENSORS) do
if dz.devices(f_sensors).active then
l_sensorsOn = true
-- print('active: ' .. dz.devices(f_sensors).name)
else
-- print ('lastupdate.secondsAgo: ' .. dz.devices(f_sensors).lastUpdate.secondsAgo)
if l_maxOn > dz.devices(f_sensors).lastUpdate.secondsAgo then
l_maxOn = dz.devices(f_sensors).lastUpdate.secondsAgo
-- print (' < ' .. dz.devices(f_sensors).name)
end
end
end
local l_sbdy = 0
if l_sensorsOn == true then
dz.log('Somebody there!', LOG_LEVEL)
l_sbdy = 20
else
if l_maxOn < l_maxAuto then
dz.log('Somebody there?', LOG_LEVEL)
l_sbdy = 10
else
dz.log('Nobody', LOG_LEVEL)
end
end
if l_sbdy == 20 then -- Somebody there!
if dz.devices(SBDY_RESULT).level == 0 then -- nobody to somebodymbody
dz.devices(SBDY_RESULT).switchSelector(30)
dz.log('Nobody to somebody there', LOG_LEVEL)
else -- somebody is confirmed
dz.devices(SBDY_RESULT).switchSelector(20) -- other cases to smbody
dz.log('Somebody still there now', LOG_LEVEL)
end
elseif l_sbdy == 10 then -- Somebody there perhaps!
if dz.devices(SBDY_RESULT).level ~= 10 then
dz.devices(SBDY_RESULT).switchSelector(10)
dz.log('Somebody there perhaps!', LOG_LEVEL)
end
elseif l_sbdy == 0 then -- Nobody
if dz.devices(SBDY_RESULT).level ~= 0 then
dz.devices(SBDY_RESULT).switchSelector(0)
dz.log('Nobody now', LOG_LEVEL)
end
end
end}
and another script to pilot my heater
Code: Select all
-- Pilotage Chaudière
local SBDY_RESULT = 451 -- dummy which knows if anyone at home
local PILOT = 427 -- dummy which knows the boiler mode
local TRIGGER = {451, 427, 346} -- {SBDY_RESULT, PILOT, MODE}
local DEVICE = 347 -- device to pilot -- "Saving" Chaudière ECO
local MODE = 346 -- Off 0 ECS 10 Prog. 20 Vac. 30 On 40
local DOMAIN = 'ChaudièreP' -- For logging, as you like!
local TIME_INTERVAL = 'every 1 hours'
return {
active = true,
logging = {
level = domoticz.LOG_ERROR, -- Select one of LOG_DEBUG, LOG_INFO, LOG_ERROR, LOG_FORCE to override system log level
marker = DOMAIN
},
on = {
devices = TRIGGER,
timer = { TIME_INTERVAL },
},
execute = function(dz, the_device, triggerInfo)
local LOG_LEVEL = dz.LOG_FORCE -- LOG_INFO, LOG_DEBUG, LOG_ERROR, LOG_FORCE
local l_status = 'xx' -- status
dz.log('*** start ' .. triggerInfo.type , dz.LOG_LEVEL)
if dz.devices(SBDY_RESULT).level ~= 0 then -- somebody at home
dz.log('Somebody at home' , dz.LOG_LEVEL)
if dz.devices(PILOT).level == 10 and dz.devices(PILOT).level == 20 then -- Normal / Prog.
dz.devices(DEVICE).switchOff().checkFirst() -- suppression du mode saving
l_status = 'Off'
dz.log('ECO to Off' , dz.LOG_LEVEL)
end
else -- nobody at home
dz.log('Nobody at home' , dz.LOG_LEVEL)
if dz.devices(PILOT).level == 10 and dz.devices(PILOT).level == 20 then -- Normal / Prog.
dz.devices(DEVICE).switchOn().checkFirst() -- mode saving
l_status = 'On'
dz.log('ECO to On' , dz.LOG_LEVEL)
end
end
dz.log(dz.devices(DEVICE).name .. ' ' .. dz.devices(DEVICE).state .. ' to ' .. l_status, dz.LOG_FORCE)
end
}
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Turning on Alarm autoomatically - help needed
Could be something likeFrancescoS wrote: ↑Sunday 19 May 2019 23:28 Systemlivechecker switch on and off a virtual switch.
I am on dzvents 2.4.0
Code: Select all
local scriptVar = 'setAlarm'
return
{
on =
{
timer = {'every 20 minutes'}
},
logging =
{
level = domoticz.LOG_DEBUG, -- set to LOG_ERROR when script runs OK
marker = scriptVar
},
execute = function(dz, item)
securityPanelDevice = dz.devices('Domoticz Security Panel') -- change name to reflect your system setup
systemLive = dz.devices('systemLive').active -- change name to your systemLivechecker device
securityIdleMinutes = 20
motionSensors =
{
'XMotion-2',
'XButton-1',
'Trap bewegingsmelder'
}
local function noMotion()
for _, name in ipairs(motionSensors) do
if dz.devices(name).lastUpdate.minutesAgo < securityIdleMinutes then
dz.log("Alarm will not be set because device " .. name .. " detected motion ", dz.LOG_DEBUG)
return false
end
end
return true
end
if ( securityPanelDevice.state == dz.SECURITY_DISARMED ) and ( not systemLive ) and noMotion() then
securityPanelDevice.armAway()
dz.log("Security State set to armAway", dz.LOG_DEBUG)
else
dz.log("No action needed. Security State: " ..securityPanelDevice.state .. "; systemLive switch active: " .. tostring(systemLive), dz.LOG_DEBUG)
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 12
- Joined: Sunday 19 May 2019 21:16
- Target OS: -
- Domoticz version:
- Contact:
Re: Turning on Alarm autoomatically - help needed
Hi,
thank you ! both work like a charm.
Now I have to improve the presence detection algorithm as systemlivechecker is not very reliable.
But this but works pretty fine.
Thanks and regards
thank you ! both work like a charm.
Now I have to improve the presence detection algorithm as systemlivechecker is not very reliable.
But this but works pretty fine.
Thanks and regards
-
- Posts: 587
- Joined: Wednesday 16 December 2015 19:13
- Target OS: NAS (Synology & others)
- Domoticz version: 2022.2
- Location: Netherlands
- Contact:
Re: Turning on Alarm autoomatically - help needed
if you have a asus router there might be an easier way to do presence detection
i have a routine running on my router which checks connected mac id's. if none of them are connected i flip a domoticz virtual switch by using a curl command.
so basically if al my devices are off, my girlfriends devices are off and my tv is off i am not at home
i have a routine running on my router which checks connected mac id's. if none of them are connected i flip a domoticz virtual switch by using a curl command.
so basically if al my devices are off, my girlfriends devices are off and my tv is off i am not at home
-
- Posts: 12
- Joined: Sunday 19 May 2019 21:16
- Target OS: -
- Domoticz version:
- Contact:
Re: Turning on Alarm autoomatically - help needed
Hi thanks,
I am now using this one >
https://easydomoticz.com/forum/viewtopic.php?t=7176
and it works perfectly with both iphone and android
Thx
I am now using this one >
https://easydomoticz.com/forum/viewtopic.php?t=7176
and it works perfectly with both iphone and android
Thx
-
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
Re: Turning on Alarm autoomatically - help needed
i have this:
but it does not change the security panel state for me. if i check with the scripts above it matches and should work?
anybody an idea on what i am doing wrong?
Code: Select all
return {
on = {
devices = {
'is someone home',
'nachtmodus'
}
},
execute = function(dz, device)
local home = dz.devices("is someone home")
local nacht = dz.devices("nachtmodus")
local security = dz.devices("Domoticz Security Panel")
if home == "Off" then
security.armAway()
elseif home == "On" and nacht == "Off" then
security.disarm()
elseif home == "On" and nacht == "On" then
security.armHome().afterMin(10)
end
end
}
anybody an idea on what i am doing wrong?
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Turning on Alarm autoomatically - help needed
Did you check the log ?snellejellep wrote: ↑Monday 03 June 2019 16:55 ... it does not change the security panel state for me. if i check with the scripts above it matches and should work?
anybody an idea on what i am doing wrong?
You declared home and nacht both as devices (which are tables for Lua) What you need are states (one entry in the device table)
Declare them using
Code: Select all
local home = dz.devices("is someone home").state
local nacht = dz.devices("nachtmodus").state
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 241
- Joined: Tuesday 16 May 2017 13:05
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: The Neterlands
- Contact:
Re: Turning on Alarm autoomatically - help needed
that was the fix, many thanks!!waaren wrote: ↑Monday 03 June 2019 17:09snellejellep wrote: ↑Monday 03 June 2019 16:55 ... it does not change the security panel state for me. if i check with the scripts above it matches and should work?
anybody an idea on what i am doing wrong?Code: Select all
local home = dz.devices("is someone home").state local nacht = dz.devices("nachtmodus").state
raspberry pi | xiaomi vacuum | yeelight | philips hue | zwave | ubiquiti unifi | harmony | sonoff | zigbee2mqtt | https://www.youtube.com/channel/UC2Zidl ... m1OLuNldfQ
Who is online
Users browsing this forum: No registered users and 1 guest