Hi all,
I want to setup an motion alarm bsed on several motion detectors, the issue is some times there is a bird that triggers it and some times it's the mail delivery.
How can I check if an motion is detected a second time within a time period?
trigger between time
Moderator: leecollings
- jacobsentertainment
- Posts: 223
- Joined: Thursday 01 October 2020 1:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021-1
- Location: Not @ home
- Contact:
- waltervl
- Posts: 5852
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: trigger between time
It also depends on the motion sensor as some only report off (no motion) after x seconds.
But you can calculate the time delta with the second motion trigger with function domoticz.time.compare()
eg
https://www.domoticz.com/wiki/DzVents:_ ... ime_object
But you can calculate the time delta with the second motion trigger with function domoticz.time.compare()
eg
Code: Select all
local deltatime = domoticz.time.compare(myDevice.lastUpdate).secs)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 660
- Joined: Thursday 10 November 2016 9:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: trigger between time
Some sensors with config parameters can be configured to require several pulse in a time frame to trigger.
Anyway, the most generic way to manage sensors is imo to use weights and add them over a time slice of 1mn for instance.
For ext sensors you may use a weight that is a fraction of trigger weight so several trig of any sensors in this mn would be needed to ring a siren.
Weigh attribution may come from a sensor name prefix for instance. So future additions do not need script changes if naming convention is respected.
See alarm wiki.
Anyway, the most generic way to manage sensors is imo to use weights and add them over a time slice of 1mn for instance.
For ext sensors you may use a weight that is a fraction of trigger weight so several trig of any sensors in this mn would be needed to ring a siren.
Weigh attribution may come from a sensor name prefix for instance. So future additions do not need script changes if naming convention is respected.
See alarm wiki.
- jacobsentertainment
- Posts: 223
- Joined: Thursday 01 October 2020 1:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021-1
- Location: Not @ home
- Contact:
Re: trigger between time
I found my way to get something working and added a couple of things to it, so here is my little alarm script. Still work in progress (fine tuning)
Code: Select all
return {
active = true,
on = {
devices = { 47, 49, 176, 603, 621, 65, },
},
logging = {
level = domoticz.LOG_DEBUG,
marker = "##Alarm"
},
data = {
Mot_a = { initial = 0 },
Mot_b = { initial = 0 },
Mot_c = { initial = 0 },
Mot_d = { initial = 0 },
Mot_e = { initial = 0 },
},
execute = function(domoticz, device)
local thuis = domoticz.devices(65)
local sirene = domoticz.devices(161)
local cam_script = domoticz.devices(620)
--motion sensors buiten "Ikea trädrfi" on time ca 180sec
local Mot_A = domoticz.devices(47) -- Voordeur
local Mot_B = domoticz.devices(49) -- Achterdeur
local Mot_C = domoticz.devices(176) -- Carport
local Mot_D = domoticz.devices(603) -- Terras
local Mot_E = domoticz.devices(621) -- Schuren
--sirene timings
local So = '5' --Sirene_on_time
local Si = '5' --Sirene_interval
local Sr = '3' --Sirene_repeat
--camera snapshot settings
local Co = '1' --Camera trigger on for
local Ci = '30' --Camera --Sirene_interval
local Cr = '3' --Camera snapshots repeat
--Voordeur
if thuis.state == 'Off' and Mot_A.state == 'On' then
local currentTime = domoticz.time.minutesSinceMidnight
local lastTriggerTime = domoticz.data.Mot_a
if (currentTime - lastTriggerTime) <= 5 then --aangepaste tijd voor de postbode
sirene.switchOn().forSec(So).repeatAfterSec(Si, Sr)
cam_script.switchOn().forSec(Co).repeatAfterSec(Ci, Cr)
end
domoticz.data.Mot_a = currentTime
--Achterdeur
elseif thuis.state == 'Off' and Mot_B.state == 'On' then
local currentTime = domoticz.time.minutesSinceMidnight
local lastTriggerTime = domoticz.data.Mot_b
if (currentTime - lastTriggerTime) <= 5 then --aangepaste tijd voor postbode
sirene.switchOn().forSec(So).repeatAfterSec(Si, Sr)
cam_script.switchOn().forSec(Co).repeatAfterSec(Ci, Cr)
end
domoticz.data.Mot_b = currentTime
--Carport
elseif thuis.state == 'Off' and Mot_C.state == 'On' then
local currentTime = domoticz.time.minutesSinceMidnight
local lastTriggerTime = domoticz.data.Mot_c
if (currentTime - lastTriggerTime) <= 4 then
sirene.switchOn().forSec(So).repeatAfterSec(Si, Sr)
cam_script.switchOn().forSec(Co).repeatAfterSec(Ci, Cr)
end
domoticz.data.Mot_c = currentTime
--Terras
elseif thuis.state == 'Off' and Mot_D.state == 'On' then
local currentTime = domoticz.time.minutesSinceMidnight
local lastTriggerTime = domoticz.data.Mot_d
if (currentTime - lastTriggerTime) <= 4 then
sirene.switchOn().forSec(So).repeatAfterSec(Si, Sr)
cam_script.switchOn().forSec(Co).repeatAfterSec(Ci, Cr)
end
domoticz.data.Mot_d = currentTime
--Schuren
elseif thuis.state == 'Off' and Mot_E.state == 'On' then
local currentTime = domoticz.time.minutesSinceMidnight
local lastTriggerTime = domoticz.data.Mot_e
if (currentTime - lastTriggerTime) <= 4 then
sirene.switchOn().forSec(So).repeatAfterSec(Si, Sr)
cam_script.switchOn().forSec(Co).repeatAfterSec(Ci, Cr)
end
domoticz.data.Mot_e = currentTime
--Thuis aan
elseif thuis.state == 'On' then
sirene.cancelQueuedCommands()
cam_script.cancelQueuedCommands()
sirene.switchOff()
cam_script.switchOff().afterSec(60).checkFirst()
end
if thuis.state == 'Off' and device.state == 'On' then
domoticz.log('##Beweging bij ' ..device.name.. '')
domoticz.notify("Camera", 'Beweging gedetecteerd bij de ' ..device.name.. '', domoticz.PRIORITY_NORMAL,domoticz.SOUND_DEFAULT, "" , "telegram")
end
end
}
Who is online
Users browsing this forum: No registered users and 1 guest