Last Will testament / Check if node is online / trigger and buffer

Dear Community,

1 have about 30 nodes within my network, and i used ping to check if they are "online" and send email alarm. This triggers a lot of notifications....

i found out abot LWT functionality, and i want to use it for online check but:

Some device go offline for short time and then go online again. so i need a buffer /counter.

To desribe logic: If LWT msg.topic == "Offline" then send email when Sum of "Offline" sent messages is higher than 5 within 1 hour. How to to? I use structure below, but that dont work...

regards Arnold

So you want a notification when it goes offline more than five times within one hour, but not if it goes offline once and stays offline for more than one hour?

Hy Colin,

i want a message when it is permanentely offline longer than one hour or more than 5 times offline within one hour.


OK, that isn't what you asked for the first time.
I would do the two requirements separately.
For the offline for longer than one hour requirement you could use a Switch node to separate the Offline and Online messages then feed Offline into a Trigger node set to send nothing immediately, then a message after 1 hour that you use to send the email. Feed the Online message into a Change node that changes it to a trigger Reset message (the info tab for the trigger node defines what is needed) and feed that into the Trigger node also. The result is that if an Offline message arrives it will prime the trigger and if no Online message is received then one hour later it will initiate the email. If, however, an Online message is received that will reset the Trigger so no message is sent.
For the Offline more than 5 times in an hour I think it would be easiest to write a function to do that. It would have to store the timestamps for the last five Offline messages and also have a 'tick' input from an inject node every, say, 1 minute, and use that to check whether the oldest is less than one hour ago. Others may have an alternative way of doing this, it isn't trivial.

hy, thank you! i try tomorrow after breakfast coffee :wink: