I have got a question about a Node-Red solution. I want to control the operation of my blinds with Node-Red instance. (connected with my Home Assistant) I got it running, however.. I want to have an extra function.
How it works now;
The altitude of the sun is put into the "function blinding sun?" which checks if it is actually almost horizontal into the rooms. If so, the position will be 75% closed.
If not, it will check if it is night or day
If it is night it will close 100%. If it is day, it will open to 0% right now.
What I want, is to combine "if it is day AND he weather is sunny" it will not go to 0% but to 35%. Visually; the yellow line has to combine the FALSE output of sunrise/sunset with the TRUE/FALSE with the pollstate of weather. Depending on the "sunny state" it has to go to daymode or daymode sunny.
Can someone help me to find the puzzlepiece I am missing to do so?
To start I would use a join node followed by a function node with 2 outputs
In the join node I would try to create a key/value object from the messages for sun state and weather coming from your two nodes. In the function, evaluate the keys/values and depending on result, send to outputs
I would use a Finite State Machine to do this - simply set a context variable from the Sunrise/Sunset Node (say Daytime = Yes or whatever works for you) and another context variable for the Sun State (Sunny = Yes for instance)
Then test for this inside the FSM and set the state appropriately based on both of these
Cflurin (a regular on the forum) has a good FSM node and offers lots of support on here for it
Thank you so much! The Finite State Machine has the functionality that @krambriw describes in a function node. I got it working, and I couldn't be more happier! No more sun directly into my face when I am watching the TV.
I eventually changed the whole flow, the reason being that I couldn't determine if it had bugs in my flow, or that the hub controlling my blinds had some issues sending/receiving the commands.
Therefore, I made this (long) version of my flow. It works exactly as needed, and it checks every minute what the position of the blinds should be. Since the hub doesn't report the position of the blinds, it is impossible to use the "if state change" home assistant functionality. Therefore, I am using the timestamp that 'starts' each minute.
As for the 'round altitude' functionality, I selected the "Integer Part" in the calculator step. This removes all the decimal value. The functions 'BLINDING SUN?' and 'SUN BEHIND BUILDINGS?' both make use of the position of the sun. As shown here;