# Count number of sensors reporting data

**URL:** <https://discourse.nodered.org/t/count-number-of-sensors-reporting-data/60428>\
**Category:** General\
**Tags:** function-node\
**Created:** [28 March 2022 05:13 UTC](https://discourse.nodered.org/t/count-number-of-sensors-reporting-data/60428 "2022-03-28T05:13:53Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 March 2022 06:18 UTC](https://discourse.nodered.org/t/count-number-of-sensors-reporting-data/60428/5 "2022-03-28T06:18:18Z")

</div>

> [@alpha815](#):
>
> our sensors have unique id

Here is a solution for a similar requirement. It should work for you...

> [@Counting messages per main topic](https://discourse.nodered.org/t/counting-messages-per-main-topic/56814/2):
>
> First you would need to split the topic and grab the first part. Then you could use a function node and an object stored in context to count them... example... [chrome\_ay2VTcASfH] demo flow... [{"id":"8f7f9a59772e9c54","type":"inject","z":"a4633311d1bf470d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"main1/sub1","payload":"","payloadType":"date","x":1940,"y":800,"wires":[["4b61f945350d10d6"]]},{"id":"4b61f945350…

... Just change topic to the path of your id

---

_[View the full topic](https://discourse.nodered.org/t/count-number-of-sensors-reporting-data/60428)._
