Node-red - My experience so far

Hello All, I transitioned over to using Node-Red for all of my automations over a week ago and can say that I’m astonished how good it is! As others have done, I still use Home-assistant to maintain state, feed sensor data, handle integrations and trigger actions but anything that was an automation is now within Node-Red.
Key things I like:

  • Automations that were split over multiple files have been combined into single flows
  • There where opportunities for automations to clash/interfere with each other. Node-Red visually makes this apparent if it happens
  • Use of the ‘function’ node has enabled things that simply cannot be done in automations
  • Ability to manually inject and debug has been invaluable

I haven’t found a nice way of sharing flows, but here are some of the things I’m able to do (if anyone has an interest in one of those, then would be happy to share the flow)

  • Arm/Disarm a Manual Alarm when group.all_people go from home to not_home and send out a notification. As the same time when disarming and it’s dark then also turn on the hallway lamp for 15mins
  • Group.all_people has to be stable for at least 1min to counteract device trackers that drop intermittently (equivalent of ‘for’ in an automation)
  • Take multiple sensors from the DarkSky weather integration, combine them into single message and then format them into a string that is sent as TTS to my Sonos. Providing a nice friendly message at 8am every morning
  • Use Google Calendar integration in HA to read next trash collection date, manipulate the date such that it triggers a TTS to my Sonos the evening before the trash collection date (my local authority fortunately provides an iCal for this)

3 Likes

I’d like to check out some of these flows. Most people export the flows via the menu in the upper right. But you need to paste into notepad or somethign first and redacted connection strings/user/pass typically at the bottom before posting anywhere.
I’m still trying to wrap my head around NodeRed and how to orcestrate things flowing thru the sequences the way I want to / think they should.

Nice! :slight_smile:
Would you be so nice and post json files? (or upload them to flows.nodered.org?)
I must be slow cause moving into NR is a bit painful for me

TIA :slight_smile:

Thanks @Dilby

I have tried to import your flow using the clipboard but it wont it me save it.

Is it the format you saved it as. Compact/Formatted.

Thank you very much @cameron!
Imported second versio w/o problems. :slight_smile:

@Dilby just a quick reply to say just dug out this thread and it really helped me with node-red for alarms.

Thank you.

Hi @Dilby

I am new and completely novice to node red and your post has intrigued me to find out more and possibly convert my automations as you mentioned to node red.

Can you please help me with how do I get started i.e. do I install it on my raspberry pi which is running home assistant or?

Many thanks.

Hi @bachoo786,

The simplest way to get started is if you are using Hass.io, as you can simply install it through the add-on menu in home-assistant. You can do a manual install if you’re not using Hass.io, but is more involved and requires installing node-js, node-red and the node-js home-assistant library all on your raspberry pi (instructions here : https://flows.nodered.org/node/node-red-contrib-home-assistant).

Just to re-itterate, I suggest moving to Hass.io if you are not already using it first as it just works out of the box and is pre-configured.

1 Like

@eperdeme, glad you found it useful. My flows have since moved on, so will share once I clean them up again.

What is a good solution with a device tracker to track the one change when it arrives home but ignore all of the previous event states until it changes to not_home?

We use google for our location tracking and everytime it updates the GPS even if we’re home NR picks up a new home event.

How would I take the old_state into consideration. Like a switch node that == msg.payload.old_state . I’m still learning this tool so I haven’t quite figured out how to monitor the attributes completely yet.

Thank you

Use the RBE node

1 Like

yes… rbe is the node you are looking for

image

1 Like

@oakbrad @xx_Nexus_xx Well thats easy enough. I feel stupid lol

In my case, I use a function node with some java script to specifically monitor state change from not_home to home and vice-versa. The function node is set-up with two outputs and the below code.

var newState = msg.data.new_state.state;
var oldState = msg.data.old_state.state;
if (oldState == "not_home" && newState == "home") {
    return [ msg, null ];
}
else if (oldState == "home" && newState == "not_home") {
    return [ null, msg ];
}
else { return [ null, null ]; 
}

If the transition is from home to not home then the first output used else it’s the second output. In addition to that, I use a trigger node in front of it to ensure the state change is stable for 1min before it triggers. This means in those situations the tracker is bouncing where it may have lost GPS or bluetooth signal etc is ignored.

I’ve pasted all my flows in an earlier post so should be able to see in more detail.

@Dilby so I managed to install node red and set it up with HA. I am now learning on how to work with nodes etc.

Quick question: if I was to copy your json code and change the entities to mine would the flows appear automatically on my node red? And the automation execute as per your json code ?

That should just work after updating entity names. You might need to edit the server configs from my flows which are set-up with my username and password.

Also when you import, import into new tabs and it shouldn’t mess with your existing flows.

Thanks.

1 Like

Just wanted to echo the words of others and say THANK YOU!
Learning NR now, and your flows were quite valuable to observe. Thanks for sharing.
~Bryan

@Dilby Would you mind sharing your json code for the ‘Climate and Temperature’ flow? Its exactly what I’m looking for in node-red.

Is there a specific bit you’re interested in as just had a look at that tab and there isn’t anything special in there specific to climate other than checking fish tank temperature and also reporting weather through TTS.

Hi @Dilby,
Would you mind sharing your “bin schedule” flow? I would like to do something very similar.