Node Red for Beginners - 2021 Edition (Using Home Assistant)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today on the hookup we're going to take a beginner's look at my favorite program for home automation node red i'm going to show you how to use it in conjunction with home assistant to transform your connected home into a smart home so did i throw anybody off by saying that node red and not home assistant is my favorite program for home automation well let's start out with the most common question that i get about node-red and that's if i'm already running home assistant why do i need red and conversely if i already have node red why do i need home assistant well on the surface it might look like node red and home assistant do the same things but dig deeper and you'll find that they excel in very different areas home assistant is irreplaceable for bringing all of your different devices under one unified platform and keeping track of the state of each of those devices home assistance automation and scripting user interfaces have come a long way in the last year but i still find node-red significantly more powerful and user-friendly due to its visual user interface and excellent real-time output options and setting up node-red in your home assistant installation only takes a few minutes so why not thank you to govi for sponsoring this video their latest product the immersion led strip combines a 1080p camera mounted above or below your tv with their color sense controller to extend your tv's colors onto the surrounding wall the govi immersion leds are specifically designed for tvs between 55 and 65 inches and come pre-soldered with flexible corner sections so installing them is a breeze and you won't need to do any cutting or bending of your leds because the system uses a camera instead of an hdmi connection you can use it with any tv input including your tv's built-in smart apps the immersion package is compatible with google home and amazon echo devices and also includes music reactivity and dynamic lighting modes check out gobi's immersion leds using the link in the description for the purposes of this video i'll be using a fresh installation of home assistant running on the new home assistant blue hardware but the process would be exactly the same if you're running a full home assistant install on a raspberry pi or a virtual machine assuming you've finished the initial onboarding process for home assistant you're going to click on the supervisor button on the left side and then select the add-on store from the top bar in the list of community add-ons go down to node-red and hit install next head over to the configuration tab and put in a credential secret like the documentation tells you to then go back and start the add-on you can always check the progress of an add-ons launch by looking at the log tab in my case node-red failed to launch because i don't have ssl enabled on my fresh home assistant install and i told node-red to use ssl in the configuration file if you just installed home assistant you probably don't have ssl either so set those two parameters in the configuration to false hit save and then hit the start button one more time this time everything loaded up properly and it was time to hop into the node-red web interface inside node-red there are a few different important areas on the left side are all the pre-installed node types each node is like a little skill that you give to node-red and most of the must-have nodes are installed by default in the home assistant add-on package but there are thousands more specialized nodes made by node-red contributors that you can install when and if you need them the middle area in node-red is where you're going to make all your automations you can create as many tabs as you want using the bar at the top to organize your automations technically each tab is called a flow but i don't love that terminology and i often mistakenly called each automation or sequence a flow before we go too much further let me introduce you to the two most important node types and we're going to make our first sequence if you're unfamiliar with node-red you should really do this with me on the left side we're going to find a node called inject you could browse through the node list like a maniac or you can just use the search bar to filter results in real time pull that inject node into the main flow area inject is the second most important node for testing and learning in node-red it gives you a small button that you can press to immediately trigger an input for your automations if you double click on any node it's going to bring up the editable properties for that node for inject you can send a timestamp which is selected by default or you can choose between a bunch of other data types we're going to go with a string which is the data type for a bunch of letters in a row like a word or a sentence under message.payload we're going to type in the string i did it and under message.topic we'll put in my first sequence hit the done button and then hit deploy which is essentially the save button in node-red then click the little gray box on the side of the inject node and just like that nothing happens if we want to see the message we generate we need to utilize the most important node the debug node in the left column find the debug node and drag it into the main window then we're going to connect the two nodes by dragging the inject's output which is always on the right side of a node to the debug's input which is always on the left side hit deploy and then click your inject button still seems like nothing but if you open the debug window by clicking on the little bug icon in the right panel you'll notice that it says i did it which it says is located in the message payload and above that is the message topic which has a value of my first sequence as you get more advanced with node-red there's going to be a lot more message parts so i always recommend changing your debug nodes to output the complete message object instead of just the message payload so that way you can see everything when viewing the complete message object our debug window now contains an expandable entry that contains each message part which in this case is the message id message payload and message topic in programming we call this an object and each object can have many associated properties like topic or payload in this case just like my name is rob and rob eyes rob dot hair and rob dot shirt are all properties with values specific to me but if you looked at someone else like dr z's he's got justin.eyes and justin.shirt which all have values that are specific to him and he doesn't even have the justin.hair property your objects can have as many properties as you want and each will be passed through your entire sequence as it goes from the output of one node to the input of the next the point of automation is to get your devices to behave in a specific way without you needing to explicitly tell them what to do some people take this to the extreme by having their lights and music turn on based on a specific person entering or exiting a room but until my home can correctly identify my mood my specific needs are just not that predictable so instead i use automation to make physical controls more intuitive let's look at my daughter's room she's got rgbw leds under her bed nanoleaf tiles on the wall an overhead fan light and a standing lamp one switch on the wall is physically wired to the standing lamp and the other is wired to the fan light but that doesn't make much sense since these two lights should theoretically always get turned on together whenever you just want the room to be brighter similarly the underbed lights and the nanoleaf tiles seem like they should always be turned on together for mood lighting but neither of them are connected to physical switches so normally you'd need to use a voice command or a phone app to turn them on which is not exactly convenient and definitely not intuitive behind these normal looking switches i've installed shelley smart relays which when set to detach switch mode enabled me to separately monitor the state of the physical switch while independently controlling the lights for each circuit using their internal relays my end goal is to have the first switch control the fan light and the floor lamp together and then the other switch control the nanoleaf tiles and the underbed leds and i want to do all this without messing with any wires in the wall the first thing that i need to do is get all the devices into home assistant so they can talk to each other the new shelley integration might be the most painless way to add a device to home assistant that i've ever used unfortunately i'm currently having some issues with it due to my own vlan setup causing it to revert to local pulling instead of local push i'm in the process of figuring that out but for this video i'm going to set up my shelly devices using mqtt which requires editing the configuration file the only additional thing that i'm going to do is add an mqtt binary sensor for each of the switches to monitor the actual switch position which like i said is independent from the state of the relay when used in detached mode once you've added all your necessary devices check the home assistant configuration and then go ahead and restart once home assistant comes back up which is amazingly quick these days you're going to do one more step before jumping into node-red and that's restart the node-red add-on if you skip this step your new entities might not auto-populate into node-red which is going to make your life a lot more difficult okay let's get automating let's start out easy we're just going to get the switches configured the way we want them pull out the home assistant state node and select the binary sensor output for your switch in my case i'm going to configure the first and the third switches in this panel i happen to know that the two states that this node is going to output are going to be on or off but remember if you ever need to see what's coming out of a node you can always just use a debug node which will show you the exact output in the debug window the next node we're going to use is called a switch node which is like a fork in the road we want one of the forks to correspond to the on payload and the other one should be for off if the message.payload is exactly on it will travel out of the top output and if it's exactly off it will travel out of the bottom output the switch node has a ton of different options for analyzing the properties of your message object but in this one we're just going to leave it as equals equals which means that the values are exactly equal when the first switch turns on it will generate an on payload which travels up through the switch node and then we want it to turn on both the floor lamp and the ceiling light to do this we'll use a home assistant call services node in this node we'll set up the domain to switch and the service to turn on then under entity id you can just start typing the names of the home assistant entities that you want to turn on and the field will auto-complete for you if you want to turn on more than one entity you can just separate it with a comma and then keep on typing in my case i want to specify the entity id for the ceiling light and the floor lamp when the switch turns off it will generate an off payload and that's going to travel down the bottom output of the switch node since i want to control the exact same entities i can just copy and paste the call services node that i just set up but instead of the turn on service i'll change it to turn off for the third switch we can repeat the exact same process but because the rgb w2 and the nanoleaf are classified as lights in home assistant and not switches we'll need to change the domain to light instead of switch i'll enter the entity ids for the nanoleaf and the shelley rgb w2 and i'll configure the turn on and turn off services accordingly at this point the automation is complete and after hitting deploy the lights should just work as expected but we can do better so let's kick it up a notch the nanoleaf comes with all kinds of effects and the rgb w2 can of course be colors other than white again normally to control these attributes you'd use a voice command or a phone app but there's definitely a better way usually if you're going to put on colored lighting you'll use it alone but if you just want the room to be brighter you'd want the lights to turn on as white so to intuitively control these colored devices we need to check if the other lights in the room are on and then decide what we want to do based on that data to check the specific state of a home assistant entity you can use the current state node which will output either on or off for a switch and a bunch more information for a light in this case we'll split our output one more time based on the current state information using the switch node after the current state node we can add another fork to the road and send different turn on commands to the nanoleaf and rgbw2 in addition to turning the light on and off the call services node can also specify tons of other attributes under the data field for the mood lighting i had my daughter pick out the colors effects and brightness that she wanted using the home assistant app and then i used the current state node to discover their exact values in the debug window you can click on the copy value button next to attributes to get all the current values in the correct json format if the current state of the ceiling light is off my daughter wants the nanoleaf to turn on using the ocean effect at 192 brightness and the bed leds to be set to teal at 204 brightness however if the room lights are already on the nanoleaf and underbed leds should turn onto warm white instead to specify these additional attributes you're going to want to use the data field and you're going to want to put them in json form if you've copied the information from the debug window you can just paste it in the data field and delete any unnecessary attributes which will ensure that your data is given in the right format after hitting deploy there are no errors so we should just be able to walk into the room and flip the first light switch to turn on the ceiling light and floor lamp together then if we flip on the third switch the nanoleaf and the underbed leds come on as warm white as expected if i instead flip the third switch then the nanoleaf tiles and the underbed leds come on as the mood lighting that my daughter requested if she ever wanted to have the colored lights on with the white lights she can just flip the third switch and then the first switch and then if she wanted to change the nanoleaf and the bed lights to white she'd just flip the third switch off and then on again perfect this is just a small example of the automations that can be accomplished with node-red but really your imagination is the only limit with the built-in nodes you've got things like http tcp and mqtt based messages tons of home assistant specific controls and even the ability to send and receive messages via things like twitter amazon echo and email however that only scratches the surface of the possible nodes and community develop nodes can easily be added via the palette manager allowing you more control over your devices and the ability to add almost any functionality that you can dream of if this video left you wanting more don't worry i've got a second node-red video planned in the very near future but i want to hear your automation ideas no matter how crazy or far-fetched they seem go ahead and leave them down in the comments and i'll do my best to make them happen and include them in my next node-red video to sweeten the pot a little bit if i end up selecting your automation not only will i credit you in the next video but i'll also send you a nice giveaway pack including some shelley and toya gear all you need to do is comment with your most creative and useful home automation idea a big thanks to all my awesome patrons over at patreon for your continued support on my channel if you're interested in supporting my channel please check out the links down in the description if you enjoyed this video please hit that thumbs up button and consider subscribing and as always thanks for watching the hookup you
Info
Channel: The Hook Up
Views: 173,530
Rating: 4.938735 out of 5
Keywords: home assistant, hassio, home automation, hass.io, smart home, diy, electronics, arduino, esp8266, nodemcu, wemos d1, automation, node-red, govee, node red adn home assistant, node red adn home assitant, Node red and home assitant
Id: hBEb_FCLRU8
Channel Id: undefined
Length: 14min 48sec (888 seconds)
Published: Wed Jan 13 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.