Help with dropping messages within a timeframe

Hello!

I've a few temperature sensors around the place. Each has a topic for room name and spits out the temperature value as the payload.

I am trying to store a value in context every 10 minutes, but the every 10 minutes part is proving tricky. I've tried the limit node set to each msg.topic, but the time is not applied to each topic, just to each outgoing message (the second topic can take 20 minutes, the third 30 minutes). Would be perfect if it applied to each topic individually.

I guess I could put a limit for each sensor, but doesn't seem the most elegant solution if the sensor count goes up.

The purpose of this if for an icon to show if the temp is going up, down or around the same. I compare the current temp with the stored value. Is there a better way to do this?

Make up a flow which is nearly the same as the real one.

But instead of getting the value from the sensor, set an inject node to do that.
(Actually, have a couple with different values to even better explain the problem)

And instead of what ever stuff you do down the track, put a debug node on the part where you want to see things happen.

Then: post the code (use the </> button when pasting.) and maybe people can help.

Thanks for the reply. Yes I have the simplified code. The limit node is set 'Send each topic in turn' queues them up, can take a long time if many topics. 'Send all topics' works better, but it seems to be on a timer, so it may be updated anywhere from 1 second up to the time set. I've learnt a lot about limit anyways! :smiley:

[{"id":"77dd880e.414488","type":"delay","z":"33871f41.a966a","name":"Limit","pauseType":"queue","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":315,"y":430,"wires":[["237f0796.bc3eb8"]],"icon":"node-red/inject.svg","l":false},{"id":"3de1c9ba.1c1656","type":"inject","z":"33871f41.a966a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Bathroom","payload":"2","payloadType":"num","x":170,"y":500,"wires":[["77dd880e.414488"]]},{"id":"bb6859e2.ed1228","type":"debug","z":"33871f41.a966a","name":"Driveway","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":500,"y":400,"wires":[]},{"id":"501c4dbd.6f7184","type":"inject","z":"33871f41.a966a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Bathroom","payload":"1","payloadType":"num","x":170,"y":460,"wires":[["77dd880e.414488"]]},{"id":"a100911f.266cf","type":"inject","z":"33871f41.a966a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Driveway","payload":"1","payloadType":"num","x":180,"y":370,"wires":[["77dd880e.414488"]]},{"id":"1bb0165d.5a1a0a","type":"inject","z":"33871f41.a966a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Driveway","payload":"2","payloadType":"num","x":180,"y":410,"wires":[["77dd880e.414488"]]},{"id":"237f0796.bc3eb8","type":"switch","z":"33871f41.a966a","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"Driveway","vt":"str"},{"t":"eq","v":"Bathroom","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":375,"y":430,"wires":[["bb6859e2.ed1228"],["24d18a9a.fb39c6"]],"l":false},{"id":"24d18a9a.fb39c6","type":"debug","z":"33871f41.a966a","name":"Bathroom","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":500,"y":460,"wires":[]}]

SO what is the use of the limit node?

That won't store the values in context. You say you want to store the values "in context for 10 minutes" then your code has a limit node.

I'm missing something.
And sorry, it is 22:31 local time. Bed time.

You may need to explain better what you are wanting to do.

In your flow you have a Delay node which looks to be configured correctly except that you probably want Send All Topics, and you have selected 1 message every 10 seconds, whereas you say you want 10 minutes. So change those and every 10 minutes it should send the most recent message for each topic.

Hey Colin. The 10 seconds were just for testing. Send all is better, but almost none of the values will be 10 minutes. The limit node seems to run on a timer, not from when the messages come in. The message could be in the queue for 1 second to 10 minutes.

Yes, that is how it works, but that is what you said you wanted (to store values every 10 minutes).

If you want to individually rate limit the topics so that a new message is sent immediately if at least 10 minutes has elapsed since the last message for that topic then I think you will have to split out the individual messages based on topic and feed each one through its own Delay node configured for All Messages. Or do this earlier in the flow before they are channelled into one wire, if there is such a point in the flow.

Sorry to be late to the party... I think you just need the "Send all topics" option set - so it will then send the last message to arrive on every topic it has seen in the time period set... so every x mins it will send the latest value for each topic...

My understanding is that @philosoma does not want to have to wait for the next ten minute tick if, for example, a sample for a particular topic arrives 11 minutes after the previous one. I am not entirely certain that is what is required though.

Following a post in another thread I realise that a Trigger node configured as below may do what @philosoma is looking for