Temp, humidity and current AC state flow

New to NodeRed and not a programmer, trying to setup a flow where after polling the temperature and humidity sensors, and knowing the current state of the AC, I will

  • turn on the AC if the temp it >=28, but only if the AC is not currently "on"

  • turn on the AC if the temp >= 26 AND humidity is >=70, but only if the AC is not currently "on"

  • turn off the AC if the temperature is <=24, but only if the AC is not currently "off"

I can poll the temp/humidity sensors and the state of the AC unit (on or off), and I can turn the AC unit on and off, but I'm having difficultly understanding how to build this flow

Take a look at this flow from the cookbook

which should explain the general idea. You can also do it in a function as described in the docs

ukmoose, thanks! I've got this step, 2 switch nodes, one for temp and one for humidity, but what node would I then use to combine the output of the 2 switch nodes (temp and humidity), along with the current state mode of the AC, to then send a payload to the call service node to turn on the AC?

To join temp and humidity i would look to use the JOIN node, there’s an example in the cookbook something along the lines of create a single flow from separate streams of messages


There are many ways to skin this cat. For example you could store each value in flow or global context. You could use join nodes. You could use function blocks etc.

What I'd suggest is just play, have fun and learn.

Drop an inject node (to generate test data). Drop a change node and debug node to see how it works. Drop a 2nd inject and wire both to a join node then to a debug node.

The important thing I find is getting people to understand the concept of passing the msg from node to node AND inspecting what happens to the msg after each node by using debug nodes.

Once a person understands the basics, they can quite literally throw this kind of node together in a few minutes.

One last thing, you find people on this forum very willing to help if you have given it a go yourself & got stuck. Post screenshots or for debug output, and post your flow (correctly formatted between ticks)

Good luck.

Hey Steve-Mcl, thanks! This was my first flow using node-red...ever, it solved a problem I had so it was a bit challenging. I suspect I should be using flow/global variables, but that's beyond me at this point...maybe in the future. I ended up doing the following and it worked. I really like node-red, it takes the programming out (except for the function node). Looking forward to more flows.


@bwanajag - just a point about your flow.
In the node is AC on? you exit from the top to turn on the AC, so I would assume thatt that is the NO response. On the node is AC off? you also exit from the top to turn off the AC. So you have similar nodes but the first ones top exit point is resulting from a 'NO' condition and the secont the top exit point is resulting from a 'YES' condition.

You might want to be consistent so that in the future it will make sense to you and remember to document your flow - the Comment node is great to put over a section of code explaining that section.

I hope you keep enjoying building flows! :grin:

This is an example of a lack to logical sense on my part (and the fact that I'm inept at programming). To me, they are both a "NO" condition. If is AC on? is "NO", then turn it on. Likewise, if is AC off? is "NO", then turn it off. So both would exit from the top.

This actually brings up a topic for which I'm still confused. It seems that for the current state node, the if state is the bottom connector. In my current state node is AC on? I exit from the top because the if state is 'ON'. Is there a more proper way, or logical way, or standardized way, of looking at this. As a non-programmer, this is how I see the problem and address it. However, I would prefer to learn a standardized way so that my flows would conform to a more structured, logical approach.

The fact you waited 2 months to reply means I’ve completely forgotten this issue. If you want help, please provide your flow BUT first read How to share code or flow json