# Node polling...is it wrong

**URL:** <https://discourse.nodered.org/t/node-polling-is-it-wrong/67245>\
**Category:** General\
**Created:** [2 September 2022 07:09 UTC](https://discourse.nodered.org/t/node-polling-is-it-wrong/67245 "2022-09-02T07:09:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thewaver](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thewaver/32/11917_2.png) [@Thewaver](https://discourse.nodered.org/u/Thewaver)\
**Post date:** [2 September 2022 07:09 UTC](https://discourse.nodered.org/t/node-polling-is-it-wrong/67245/1 "2022-09-02T07:09:44Z")

</div>

Is it deemed wrong to continually pole a node checking its state every second (does it use lots of bandwidth etc?). EG: I have a node waiting for a thermostate to turn off before it can turn on another device. If they are both on together they trip the breaker.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 September 2022 09:00 UTC](https://discourse.nodered.org/t/node-polling-is-it-wrong/67245/2 "2022-09-02T09:00:08Z")

</div>

> [@Thewaver](#):
>
> Is it deemed wrong to continually pole a node checking its state every second

Probably. How does the thermostat state get into node-red? Usually devices send a value either on change or regularly so you should not need to poll the thermostat to get the current state.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 September 2022 09:07 UTC](https://discourse.nodered.org/t/node-polling-is-it-wrong/67245/3 "2022-09-02T09:07:01Z")

</div>

Perhaps I misunderstood the question. If you mean that you have a message coming in that wants to turn the device on, but you must wait till another message tells you that it is ok? In which case you can use a Join node in key/value mode to get both the state of the thermostat and the On request together into one message so you will get a message when the thermostat changes state so that you can go ahead.

See [this article in the cookbook](https://cookbook.nodered.org/basic/join-streams) for an example of how to join messages into one object.

Import that example and play with it to make sure you understand how it works. You will probably need to set 'and every subsequent message' for your requirement. You can use the topic of the message that comes out to tell you which input has changed.

---

<div class="post-metadata">

**Author:** ![Thewaver](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thewaver/32/11917_2.png) [@Thewaver](https://discourse.nodered.org/u/Thewaver)\
**Post date:** [2 September 2022 12:46 UTC](https://discourse.nodered.org/t/node-polling-is-it-wrong/67245/4 "2022-09-02T12:46:07Z")

</div>

Hi Colin, Thank you for your reply. You are correct, when the device changes state it sends an update, which is prefect as it saves the polling. I have used a switch node to turn on device B when device's A thermostat is off.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [16 September 2022 12:46 UTC](https://discourse.nodered.org/t/node-polling-is-it-wrong/67245/5 "2022-09-16T12:46:54Z")

</div>

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