Weather variables - polling state node

Hello everyone,

I’m trying to refine my first automations with nodered. I am very new to NR :frowning:

My automations start with some weather variable meeting a certain condition (rain, wind). I initially thought that a state node would help me read and trigger off my flow but with no success. I then tried the poll state node and my automations did start to do things. This is very much how all of them are configured right now.

One of my automations is “untold the awning” and I would like for that to happen when sun azimuth reaches a certain value and, of course, it is not raining. I also have another automation doing the oposite: if it starts to rain or if the wind picks up, I want for my awning to be rolled back. And of course I don’t want to end up making a fool of myself having the awning unfolded yet the next minute rolled back, that’s why the first automation should only be triggered when the sun azimuth reaches a specific value and not >=, which is how I have it configured right now. If I change the >= to a more restrictive = (or IS), the condition is not met and my awning remains open :frowning:

I’m under the impression that the automation is not triggered because the variable I’m monitoring may never be the exact value I’ve defined as a triggering condition. I have a sensor defined on the azimuth and I’m plotting the values that I see and I believe the discrete value is somehow missed.

Not sure if I’m explaining myself well enough. Of course I could paste my configuration later on (now I’m on my mobile phone).


For something like sun position, it easy to calculate, there a couple of nodes that will do it for you based on a lat long.

It might be easier to start with one of them, go to and do a search for “sun”

What test have you used and in what node?

This is a quite sophisticated node available to handle most of your requirements.

Hi!! This looks very cool, although it does not address 2 important aspects that are crucial for my awning:

  1. Wind
  2. Rain

I love how it monitors the sun to decide the blind position and that is something that I will definitely use (just need to figure out how it works). Do you happen to use this component?

On another note, I still would love to understand how to handle the variable monitoring for polling state nodes. If anybody can help me with that, I would be very thankful.

Many thanks!

I am not using it, I use the time-range node which also uses sun-position, but I do use wind and rain variables.

I have a function node that performs the checks: if wind > 20m/s or rain then set a variable "allowed": no, if rain then allowed:no,else allowed:yes. Then I have a lux sensor in combination with the time-range node, if lux>2750, in the time-range and allowed, then awning down. Connected to a trigger node which is set to 10 minutes (which is 2x the lux sensor reading cycle) and this could be either triggered or reset.

Could you use a switch node to only output if the variable is between two values, or greater/less than a preset value?



this is the node that I use to monitor the azimuth value. I would like to say “is” 150 instead of “>=“ because of what I explained earlier. If I configure the node with “is”, in my experience I never manage to trigger the automation itself. I’ve tried with numbers and strings, to no avail.


Hi @Paul-Reed,

That could very well be a solution, yes!! I will try that out tomorrow!!

Thanks!! :slight_smile:

Cool. Thanks for answering back. Any chance you could share your flow here?

That demo also sets the value as a string (see the AZ) so you also need to check to see what the node before is sending.

Is is a string or a number?
(if it was true or false there’s also boolean)

You can check this using the debug node, the page i the docs entitled “working with messages” is also well worth a read

Cannot really extract the flow, using different types of nodes and api's to gather data.

This is the basic gist of it:

[{"id":"e2aa459c.3118c","type":"inject","z":"500a30d2.4c843","name":"wind 6 m/s","topic":"","payload":"6","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":224,"wires":[["8a68a483.ab23f8"]]},{"id":"2ac65508.a1bbfa","type":"inject","z":"500a30d2.4c843","name":"rain 0 mm","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":280,"wires":[["fe3f58f6.6ddcf8"]]},{"id":"fe3f58f6.6ddcf8","type":"change","z":"500a30d2.4c843","name":"","rules":[{"t":"set","p":"rain","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":406,"y":280,"wires":[[]]},{"id":"8a68a483.ab23f8","type":"change","z":"500a30d2.4c843","name":"","rules":[{"t":"set","p":"wind","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":406,"y":224,"wires":[[]]},{"id":"82cf00f1.f167b","type":"inject","z":"500a30d2.4c843","name":"down","topic":"","payload":"down","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":392,"wires":[["2ac0341c.65b49c"]]},{"id":"2ac0341c.65b49c","type":"switch","z":"500a30d2.4c843","name":"rain ?","property":"rain","propertyType":"flow","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":330,"y":392,"wires":[["8adcd7f9.71cb"],["4a764458.9111a4"]]},{"id":"4a764458.9111a4","type":"switch","z":"500a30d2.4c843","name":"wind > 18m/s ?","property":"wind","propertyType":"flow","rules":[{"t":"gte","v":"18","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":500,"y":420,"wires":[["8adcd7f9.71cb"],["eafad8fa.6416e8"]]},{"id":"eafad8fa.6416e8","type":"trigger","z":"500a30d2.4c843","op1":"","op2":"up","op1type":"pay","op2type":"str","duration":"10","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":714,"y":420,"wires":[["4c6ab8a0.c1e16"]]},{"id":"4c6ab8a0.c1e16","type":"debug","z":"500a30d2.4c843","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":910,"y":392,"wires":[]},{"id":"8adcd7f9.71cb","type":"change","z":"500a30d2.4c843","name":"up","rules":[{"t":"set","p":"payload","pt":"msg","to":"up","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":694,"y":364,"wires":[["4c6ab8a0.c1e16"]]}]

it is a string

On my suspicion above, check the following two snapshots:


so it literally never is 150.00 but either 149.98 or 151.53. In other words, Noder Red "never sees the sun azimuth crossing the 150.00 mark", it is either below or above.

I'm going to try Paul's suggestion for a spin today and report back later on.

As a new user I can't seem to be allowed to add more than 2 images. This additional one goes hand in hand with the second one above.

Can you explain why you can't test for >= again. I can't see above where you have explained that. The value will only be exactly 150 for an infinitesimally small time (well in practice, with floating point numbers, not quite infinitesimally small) so the chance of hitting it exactly is very small.