Some newbie help on Node-Red

I just created my first Node-Red automation and while I got there I found it a bit trickier than I expected…
For some reason I expected all of the variables of a device to appear (similar to how they do in HA) in a list for me to just select, but the only way I could grab them was to use a debug node to output them - is this correct or have I missed something?

I then also found it tricky to identify which output node to use and just sort of guessed that the cover one was the option - is there a way to know this better?

Finally, out of interest, is there a way to do this in Home Assistant UI with just one item? It seems it would take three, but might be missing something as I’m new to the whole thing…

no, that is how to get details of events. Set the debug to complete message object for all attributes.

Trigger and event are most common. Trigger allows conditions, while the event state has a wait_for option. Then there are mqtt and other specialty nodes that can act as triggers.

There is also a new device node that has specific options for devices that are auto fill. Also the time node that paired with a datetime helper in ha allows you set specific times. There are also other triggers but these are some of the main ones.

Not sure if you have watched the Youtube videos ? These are from the developers of Node red and give you a good understanding of the basics

Once you have watched those then i would highly recommend these two that are specificy to HA and the NR Webhooks integration

and an older one from him but more basic

Craig

1 Like

Thanks - I’ve actually watched both of those but I didn’t find them too useful

They go straight into capturing motion but missed the simplest thing of ‘pressing a button’ - in fact, I couldn’t find a single guide that mentioned how to do that…

Once I got my head around the fact that I was waiting for a state change rather than a trigger it started making more sense, but nobody really stated that anywhere

I guess the Alpha “Device” action seems to work as I was expecting, but the warnings plastered over it made me steer clear!

EDIT:
One other question
image

Is there any way to add a folder structure under flows?

This seems to be something that both Node Red and HA automations is missing - you can’t organise your flows/automations which I imagine will get quite unwieldly later

No no folder structure under flows at this stage - just keep making more flows and then you can make subflows to try and help organise and structure things - but yes my Home Automation system that is all done in NR has about 50 flows in it now

Craig

Fair enough… I guess I’ll just use a naming convention.

Wonder if you can help - I have this in an automation and I’m trying to add it to Node Red instead…

What’s the simplest way? I used Call Service in my last flow, but is there a way to just select the action from a list like In the automations?

I seem to be able to guess the right thing, but wonder if there’s a better way?!

Oh, and one more question…

Will everything in NodeRED get backed up with my Home Assistant backups? Or do I need to backup separately?

It is all backed up together. No additional steps are needed.

And for a bit of organization, you can create different tabs across the top.

1 Like

Ah - I was using each of those as a separate flow - but presume you can pump different flows into the same tab

Yeah don’t do that - use link nodes across flows or Context variables as appropriate as it quickly becomes complex to track down problems in a flow if you have multiple things happening on the same flow tab.

There is a also a dropbox backup node (check on the NR discord about this) that will backup all your flows on a daily basis - simple to setup and just does its thing in the background - well worth the effort if you are going to put a lot of time into NR)

Craig

Not sure what you are asking here - is there a way to find the right node or the service action ?

Typically if replacing an automation you go to the logbook and see what it is doing in terms of calls etc and then map out what you want to achieve

In the example automation you give above - not sure what is triggering it ? It seems to be a simple toggle of a light so if on - turn off etc ?

Step abck and explain how it fits in and then you can decide on the best way to do it.

I came from the NR side into Home Assistant as i found that HA had more devices being integrated and exposed on an ongoing basis - i still do all my processing in NR and all my logic flows etc as it just seems easier and smarter than templates and yaml - i typically use HA for display and device presentation (if not done natively in NR)

Craig

So I’m new to HA entirely (coming over from Homey) and I’ve already found that some of my simple flows are tricky to replicate in the HA UI but are pretty easy in Node Red, so I think I’m sticking with NR

The question above was asking (in the context of a blank slate) if
a) is call service the right node to be using in every “action” phase (i.e. turn on bulb / send notification etc - haven’t actually worked out the latter yet, but the former seems to work)
And if so
b) how do I easily identify the actions a available for a device - at the moment I’m sort of guessing with a bit of trial and error. In HA automations if I select the device it lists all the possible actions that can be taken, but NR doesn’t seem to and I have to guess the service - hence wondering if I’m doing something wrong

Edit. Here’s a good example - I’m trying to add Wake-on-Lan node - I know I can do this via wake_on_lan which is built in, but I can’t find the wake_on_lan or magic_packet under the call service node - should I be looking somewhere else?!

Edit2: Another question (almost certainly a newbie one) - how do i do an OR / ELSE?

I have many flows on a single tab. I use the group function from the hamburger menu on the right to create sections on the page.

I wouldn’t worry much about diagnosing problem flows, NR has a robust search function again in the right hamburger menu. You can easily find nodes by their name/number, it also uses a regex search for code inside a node.

Most of the time the call service will be your action. There are specialty cases like modbus out or mqtt out that NR can talk to directly rather than go through HA. At the same time you could use a call service to publish mqtt rather than the mqtt out.

In the example above the or/else would be the other output of the current state node.

That doesn’t actually work tho - if I only cared about one of them it does, but I want to know

psuedo code...
if {
   the Lamp OR Light is on 
      then 
         turn both off
      else 
        turn both on

So I need an OR between them

Just wire them in series rather than parallel.

1 Like

Oh okay. I guess there is a way to do an OR / ELSE tho? (for future reference?)

There is a function node that you can write formal if/else statements.

var br = msg.payload

if (br < 1) {
  msg.ct = 2500, msg.brightness = 25;
} else if (br > 0) {
  msg.ct = 3500, msg.brightness = 50;
} else {
  msg.ct = 4500, msg.brightness = 100;
}


1 Like

or look up the ultimate boolean nodes for Node red

Craig