Page 1 of 1
help needed with delaying trigger
Posted: Tuesday 29 December 2020 22:25
by jenski
..sorry, I'm probably staring at it to long..
I'm searching for something to delay the initial trigger.
.cancelQueuedCommands() seems like a solution but it only seems to work for switch commands
Code: Select all
if ( device(1) == on ) --[i]for more then 20 sec[/i]
then
device(2).switchOn().checkFirst().afterSec(30)
domoticz.email("blabla"..).afterMin(2)
elseif ( device(1) == off )
then
device(2).cancelQueuedCommands()
domoticz.email("blabla"..).cancelQueuedCommands()
Am I correct in assuming .cancelQueuedCommands() does not work on email and notifications?
Re: help needed with delaying trigger
Posted: Tuesday 29 December 2020 22:33
by waaren
jenski wrote: ↑Tuesday 29 December 2020 22:25
I'm searching for something to delay the initial trigger.
Can you describe in a bit more words what you try to achieve.
Also.. your profile states you are on stable. Is that 2020.2 ?
Am I correct in assuming .cancelQueuedCommands() does not work on email and notifications?
Yes
Re: help needed with delaying trigger
Posted: Thursday 31 December 2020 12:12
by jenski
I am messing around with zwave smoke detectors and I'm trying to catch false triggers. I don't know why but every once in a while these devices fail to report in time I guess and this would then falsely trigger the alarm. But firing a trigger and then do the check feels wrong.
Blocky does allow for .setOnAfter(20 sec) apparently... and so:

- blokkycrop.png (139.08 KiB) Viewed 516 times
With this you can differentiate between email txt's.
..the roof, the roof is on fire!!..
This solution also works for door-contact/burglar alarms, in the case of kicking the annoying cat out the door in the middle of the night.
Re: help needed with delaying trigger
Posted: Thursday 31 December 2020 15:01
by waaren
jenski wrote: ↑Thursday 31 December 2020 12:12
I am messing around with zwave smoke detectors and I'm trying to catch false triggers. I don't know why but every once in a while these devices
Something to play with?
Code: Select all
local scriptVar = 'delayed Alarm'
return
{
on =
{
devices =
{
'rookmelder*', 'Carbon*',
},
customEvents = {
scriptVar,
}
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = scriptVar,
},
execute = function(dz, item)
local delay = 20 -- default (can be overided in messages table)
local mail = '[email protected]' -- default (can be overided in messages table)
local messages =
{
['rookmelder 1.2 - keuken'] = { delay = 30, subject = 'brand alarm keuken', message = 'het alarm (voor brandmelding in de keuken) gaat af' },
['rookmelder 2.2 - zolder'] = { subject = 'brand alarm zolder', message = 'het alarm (voor de brandmelding op zolder) gaat af'},
['rookmelder 3.2 - schuur'] = { subject = 'brand alarm schuur', message = 'het alarm (voor de brandmelding in de schuur) gaat af', mail = '[email protected]' },
['Carbon Monoxide'] = { delay = 1, subject = 'CO alarm zolder', message = 'het alarm (voor een CO melding op zolder) gaat af' },
}
if item.isDevice then
if item.active then
local t = messages[item.name]
local delay = t.delay or delay
local mail = t.mail or mail
dz.email(t.subject, t.message .. ' over ' .. delay .. ' seconden.', mail )
dz.log( t.message .. ' over ' .. delay .. ' seconden.', dz.LOG_FORCE )
dz.emitEvent(scriptVar, { device = { name = item.name, idx = item.idx, at = { dDate = dz.time.dDate, rawTime = dz.time.rawTime }}} ).afterSec(delay)
end
else
local dv = item.json.device
local sensor = dz.devices(dv.idx)
local alarm = dz.devices('Alarmsituatie')
if sensor.lastUpdate.dDate == dv.at.dDate then -->> no new updates to alarm
local t = messages[dv.name]
local mail = t.mail or mail
dz.email(t.subject, t.message .. '. De melding is actief sinds ' .. dv.at.rawTime, mail )
dz.log('Alarm ' .. t.message .. '. De melding is actief sinds ' .. dv.at.rawTime, dz.LOG_DEBUG )
alarm.switchOn()
else
dz.log('Alarm ' .. dv.name .. ' has been updated between since ' .. dv.at.rawTime, dz.LOG_DEBUG ) -- >> no further action
end
end
end
}
Re: help needed with delaying trigger [Solved]
Posted: Sunday 03 January 2021 22:37
by jenski
Oe! wow TNX!
I didn't realise you could do
,thats awesome
I am gonna play some more with this for sure..