Ideas for comparing week-over-week values

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:

0: object
LastReported: "2022-09-09T16:33:58"
LastReportedPercent: 75

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.

You should be able to do this with a simple trigger node set something like this:

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

  1. Checks that it is not more than 8 days since the last update.
  2. Checks that the difference between the last two samples is sensible.

Thanks to both of you.

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).

And you shouldn't need to. You just need to look at the timestamps of the last two records.

Oh brilliant! I don't know why I did not make that connection. Will write the Flux query shortly...

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.