This weekend we had quite a bit of rain, so I attempted to upgrade my smart home system setup using Node-Red and Home Assistant in a Docker Container on my unRAID server. I recommend using the Community Applications Plugin on unRAID to help you find these dockers and other plugins/containers of interest. I’m going to assume a basic knowledge of Home Assistant and editing its configuration files.
Installing the required Docker Containers
I installed the homeassisant docker from Balloob’s Repository by searching for “Home Assistant” in the Community Applications Tab. I left the docker install options pretty much default. Make sure the network type is “Host”.
Now you need to install Node-Red. Search for “Node-Red” in the Community Applications Tab. Select the “NodeRed Offical Docker” from Spants’ Repository.
If you just install this docker with the default options, you will have problems. You’ll get errors warning you that you can’t connect to the Home Assistant docker (which we’ll go over later in this post). The new version of Home Assistant only works with NodeJS 8.x. Make sure to change the Repository from “nodered/node-red-docker” to “nodered/node-red-docker:v8”. I also changed the Host Path 1 from “/mnt/user/docker/appdata/nodered” to “/mnt/user/appdata/nodered” because that’s the default unRAID appdata installation folder (which I use also). Also make sure that the “Network Type” is set to “Host”. There have been reports of people having issues if this is set to “Bridge”.
You now have all the required dockers installed! I’m not going to go over Home Assistant in this post, so you’ll be on your own to search and find out how to install smart home devices in Home Assistant.
Setting up the Docker Containers
You will need to setup your Home Assistant Docker Container first. Go to your server’s appdata folder and find the configuration files for Home Assistant. Edit your “configuration.yaml” file and somewhere in the file add:
http: api_password: YOURPASSWORDHERE
This allows the Node Red docker to use the API of Home Assistant to talk to the docker container.
Now you can go to the Node-Red Docker Container. Use the hamburger menu in the top right of the page and select “Manage Pallete”. Go to the “Install” tab and search for “home-assistant”. Look for the “node-red-contrib-home-assistant” palette and click install. Give it a moment or two to install.
Once it installs you will now have a list of nodes on the left hand side of the Node-Red page under “home assistant”. Drop one onto a flow and double click it. Edit the server. Give it a name of your choosing. Set the “Base URL” to be “http://your.server.ip.here:8123” and the “API Pass” as your password that you set in the home assistant configuration.yaml file.
Now your Node-Red should be able to connect to the Home Assistant Docker through its API.
A Test…
To make sure it works, we’ll run a quick test. Pick the “call service” node from the Home Assistant list on the left side. Drag and drop it onto your flow page.
Now double click it and a dialog box will open. Fill in the “Name” field with whatever you want. (I’m using my old Christmas Tree Controller to test it, so I named mine Xmas Tree Light) Select the Home Assistant server that you setup in previous steps in the “Server” field. For the “Domain” field, I’m using a light, so I selected “light”. For the “Service” Field, select “Toggle” for now so we can press the button and test. The “Data” field needs to have the JSON for the entity, so you’ll have to go to your Home Assistant screen to get that.
In main screen on Home Assistant, select the “Services” button in the Developer Tools menu. Select the “light.toggle” service and then select the light you want to toggle under “Entity”.
Copy the JSON from the “Service Data” Field in Home Assistant into the “Data” field in Node-Red. Make sure to include the curly brackets! {} You can leave the “Merge Context” field blank.
Press “Done” when you have it all entered correctly. You now should have a blue home assistant node on your flow screen with the name you gave it. Scroll clear up to the top on the Node-Red left hand menu and drag the “inject” node onto the flow screen. Connect the output of the inject node to the input of the home assistant node you setup earlier. Then press “Deploy”.
Now when you click the button next to the input node labeled “timestamp”, your light should toggle off and on.
Now go enjoy making some new flows and controlling your devices in home assistant!
Hello,
How did you setup your authentication with the. lattest hasS.io version?
Thank you for your feedback!
Stijn