Multiple IF's in a row


Fairly new to NodeRed, only managed to make a few automations (Turn on LED light at specific time to alert my son, that it is bedtime)

I wanted to make another automation.

I have a solarcell system with a battery.

We offcourse want to run the washer, the dryer and the dishwasher, whenever we produce more power than we use. (We get very little for power we sell to the supplier so we need to maximize the self-use of power)

So...My wife is not that technical and always asks me if it is ok to start this and that machine, and i wanted to do a simple automation

Its more or less like this.

If the battery is charged above 30% and (Solar cell production minus current use) is more than X Kwh then turn on a lamp.

I have entities for battery charge state, current solar cell production and the current useage.

I was thinking this was easy...Just find something that i could drag in, and say

"If this integration has a value of >=30 then set output high" and connect that to another similar one that had

"if current production minus current comsumption is > 1 kw" then set output high and then connect that to a Call service node, that would then turn on the lamp.

If either of the conditions fell below, the lamp would then turn off.

But all of the examples of something that looks a bit like what i want, seems to be programming, not dragging a box in and changing some parameters and adding an entity.

So..Does such a node exist, and if so, what is it called. :slight_smile:

The low code option is to use a switch node, then on the outputs you can use a change node to set a msg property. e.g.


Thank you, i am not a coder so even a "low" code option is quite a steep hurdle, i was hoping that there were some building blocks where it was "flow" oriented in a way that i could understand.

I managed to make the "Turn on the Shelly LED" without any code for my sons room, using a Cronplus node attached to a "Call service" node, without any actual coding.

Is the code snippet you posted something that i put into the switch node, i have 0 experience with actual coding, hence why i hoped Nodered was more of a "lego blocks with selectable fields for each lego block" :slight_smile:

What i posted was a flow json.

copy it to your clipboard.
Then in the flow editor press ctrl i .
Then paste the code and press import.
This will import the flow example, showing how to use the switch node and change nodes to do what you wish.

You can also export flows by highlighting the nodes required and press ctrl e and copy to clipboard.

you would do well to read the docs and watch the videos, it will tell you a lot and show you some important features to make using node-red easier for you

That's an importable snippet. Copy it, then in node red go to node red and hit ctrl+i, or click the menu in the upper right and select "import." Paste the copied block in and import the nodes.

Wow, you learn every day, i did not know what to do, but now i imported it, i see it made a structure on my NodeRed.

So i replace the "20 and 30" with some other node type that i can pass the value of my "battery state of charge" entity, and the "msg.payload" part with a ?? Call service node to call the lamp. ?

I will certainly read up on the docs, i have actually watched some video's to be able to do the LED strip turn on part :slight_smile:

It'd be worth you time watching the node-red videos...

I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

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