Page 1 of 1
trigger on counter not selective :-(
Posted: Wednesday 24 April 2019 20:22
by freijn
Guys, can you please help me understanding.
I have 3 counters as listed below with individual idx's 87, 99 and 98
I would like to get a notification when the 99 or 98 counter does get incremented however it I enable the below Lua I do get notifications from the idx 87
as well, more over incremented the idx 87 by 1 give an notification of 98 and 99 at the same time.
I am sure I am missing something.. please advice.
Thanks in advantage , Frank
Code: Select all
commandArray = {}
if (devicechanged['Police HeliCopter 10Km']) then
commandArray['SendNotification']='Police Heli in the Air!'
end
if (devicechanged['LifeLiner Rescue 10Km']) then
commandArray['SendNotification']='LifeLiner Heli in the Air!'
end
return commandArray
Re: trigger on counter not selective :-(
Posted: Wednesday 24 April 2019 20:56
by waaren
freijn wrote: ↑Wednesday 24 April 2019 20:22
I have 3 counters as listed below with individual idx's 87, 99 and 98
I would like to get a notification when the 99 or 98 counter does get incremented however it I enable the below Lua I do get notifications from the idx 87
as well, more over incremented the idx 87 by 1 give an notification of 98 and 99 at the same time.
I am sure I am missing something.. please advice.
If I look at "laatst gezien" all your counters got updated at the same second. Are they updated by a plugin or script ?
Please note that devicechanged["name"] will return true when the lastUpdate field is updated. This does not necessarily mean the value of the counter has changed.
Re: trigger on counter not selective :-(
Posted: Wednesday 24 April 2019 21:06
by freijn
waaren wrote: ↑Wednesday 24 April 2019 20:56
If I look at "laatst gezien" all your counters got updated at the same second. Are they updated by a plugin or script ?
Please note that devicechanged["name"] will return true when the lastUpdate field is updated. This does not necessarily mean the value of the counter has changed.
Thas is correct, all updated from the same script.
Is there not an event possible when the counter get's incremented ?
Do I need to store the counter value in an variable and compare that every minute for the change?
Re: trigger on counter not selective :-(
Posted: Wednesday 24 April 2019 21:56
by waaren
freijn wrote: ↑Wednesday 24 April 2019 21:06
Do I need to store the counter value in an variable and compare that every minute for the change?
That is an option but My preference would be to use dzVents persistent var for this.
It could look like:
Code: Select all
return {
on = {
devices = { 'Police HeliCopter 10Km',
'LifeLiner Rescue 10Km' ,
},
},
data = {
PoliceCounter = { initial = 0 },
LifeLinerCounter = { initial = 0 },
},
logging = {
level = domoticz.LOG_DEBUG,
marker = "Heli counter"
},
execute = function(dz, item)
if item.name == 'Police HeliCopter 10Km' and item.counter ~= dz.data.PoliceCounter then
dz.notify('Air alert','Police Heli in the Air!')
dz.data.PoliceCounter = item.counter
elseif item.name == 'LifeLiner Rescue 10Km' and item.counter ~= dz.data.LifeLinerCounter then
dz.notify('Air alert','LifeLiner Heli in the Air!')
dz.data.LifeLinerCounter = item.counter
end
end
}
Re: trigger on counter not selective :-(
Posted: Thursday 25 April 2019 15:01
by freijn
Waaren
Thanks for the script ! Set it in production.. now wait till the Heli fly over.
(to speed up I could make a phone call
)
no no, just a joke
.
Re: trigger on counter not selective :-(
Posted: Thursday 25 April 2019 21:08
by freijn
Waaren
Thanks !!!!