Hello. We have an ammonia tank that get depleted over about 8 weeks, then refilled. The tank has a meter that transmits its status once a week (every Friday about 16:33). The data looks like this:
We grab this info via Node-RED, store it in Influx, and display in Grafana as a gauge.
We ran into an issue where the meter failed (stopped transmitting). As a result, the LastReportedPercent value did not change for several weeks, went unnoticed, and we ran out of ammonia.
There are probably many ways to prevent this from happening (including Influx or Grafana alerts), but I would like to keep this in the Node-RED camp, such as:
Store LastReportedPercent in context and compare with incoming value every Friday at 16:33. If it has not changed vs the value stored in context, send off an email alert to someone.
If no value received in 8 days, send off an email alert to someone.
Can anyone suggest another (easy) way to catch this using standard Nodes if possible?....I can muster my way through javascript if I have to.
An inbound update will cause the trigger to reset and if another message isn't received in just over a week, it will send a msg to the second output port.
In order to cope better with things like node red restarts you could run a completely separate watchdog flow that runs daily that looks at the most recent records in influx and
Checks that it is not more than 8 days since the last update.
Checks that the difference between the last two samples is sensible.
I should have clarified that we do not currently store the LastReported date in Influx. I think I tried once, but I think I needed to fix something with the datatype (date vs. string-that-looks-like-a-date). I will revisit and use Colin's approach, but will also set up Julian's dead-simple method (and btw, I never would have thought to use a trigger node).