Node polling...is it wrong

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.

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.

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

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.

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