Node red - counter timer

844 views
Skip to first unread message

Andy Haig

unread,
Oct 21, 2017, 7:30:31 AM10/21/17
to Node-RED
HI 

I am having a brain fade, so if someone could point me in the right direction here, I would be grateful

I want to count the number of messages i receive on a given flow in a given time - and then (When the timer expires) 
- emit a single message with the total
- reset the time and total 

All help and commentary gratefully received; abuse less so, but acknowledged as karmic punishment for my hangover

Cheers

Andy

Julian Knight

unread,
Oct 21, 2017, 8:18:16 AM10/21/17
to Node-RED
One way would be 2 flows:

1st: use inject node to trigger every x seconds/minutes/whatever, read flow variable, output, reset flow variable
2nd: for each msg recvd, add 1 to a flow variable, continue processing

Colin Law

unread,
Oct 21, 2017, 8:32:17 AM10/21/17
to node...@googlegroups.com
It looks like this might do it, though not used it myself
https://flows.nodered.org/node/node-red-contrib-message-counter

Colin
> --
> http://nodered.org
>
> Join us on Slack to continue the conversation: http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to node-red+u...@googlegroups.com.
> To post to this group, send email to node...@googlegroups.com.
> Visit this group at https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/node-red/3d9029b7-86ba-4c6a-b8dd-112ad04d0e17%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Eugene Schava

unread,
Oct 23, 2017, 10:04:59 AM10/23/17
to Node-RED
I use https://flows.nodered.org/node/node-red-contrib-counter for similar task
It counts incoming messages and also allows special messages to reset counter or report current state (for this I set "Default Step"=0 and enrich every message that has to be counted with msg.increment=1)

субота, 21 жовтня 2017 р. 14:30:31 UTC+3 користувач Andy Haig написав:
Reply all
Reply to author
Forward
0 new messages