Top 5 This Week

Related Posts

How I use Node-RED and Home Assistant together for the ultimate smart home

Ask any DIY enthusiast about the best utility for managing smart gadgets and IoT paraphernalia, and they’ll definitely point you to Home Assistant. While HASS is pretty useful on its own, you can pair it with a handful of plugins to automate every aspect of your living space.

Node-RED is one such add-on that relies on flow-based programming to create trigger-action conditions for your Home Assistant devices. But due to its high difficulty curve, it can appear intimidating when you’re a newcomer. So, here’s a detailed guide to help you integrate Node-RED’s amazing automation provisions into your Home Assistant server.

Related


A beginner’s guide to Ansible automation

Why bother with the tedious aspects of server management when Ansible can do all the heavy lifting?

Setting up Node-RED

If you’re running Home Assistant as a bare-metal OS or a virtual machine, you can install Node-RED as an add-on. To do so,

  1. Head to the Settings tab and select Add-ons.

    Selecting the Add-ons option in the Home Assistant web UI

  2. Click on the Add-on Store.

    Selecting the Add-on Store in the Home Assistant web UI

  3. Scroll down until you see Node-RED before clicking on it and selecting Install.

    Installing the Node-RED add-on in Home Assistant

  4. (Optional) If you haven’t set up proper SSL certificates for your Home Assistant system, the Node-RED add-on won’t boot. To fix this, you can navigate to the Configuration tab, disable the checkbox next to SSL, and hit Save.

    Disabling SSL for the Node-RED add-on inside the Home Assistant web UI

  5. Switch back to the Info tab and tap Start.

    Starting the Node-RED add-on

  6. Select Open Web UI to access the Node-RED interface.

    Opening the Node-RED web UI inside Home Assistant

But if you’re running Home Assistant inside a container or are using the Core version of the service, you won’t be able to access the Add-on Store. A simple solution involves deploying Node-RED as a container and linking it with your containerized HASS instance. Assuming you’ve set up Docker beforehand,

  1. Open the terminal app bundled with your OS.
  2. Execute the docker pull command to grab the Node-RED image,

    sudo docker pull nodered/node-red
    Pulling the Node-RED container image

  3. Deploy the Node-RED container using the docker run command with a couple of arguments.

    sudo docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red
    Deploying the Node-RED container

  4. You can access the Node-RED web UI by entering http://localhost:1880 into a web browser.

    Accessing the Node-RED web UI

    Alternatively, you can replace the localhost string with the IPv4 address of the system running the Node-RED container.

  5. Inside the Node-RED UI, click on the menu button and select the Manage palette option.

    Accessing the Manage palette option in the Node-RED web UI

  6. Switch to the Install tab, scroll down until you can spot node-red-contrib-home-assistant-websocket, and tap the Install button next to it.

    Installing the Home Assistant websocket palette in Node-RED

  7. Once the template has finished installing, drag a node associated with it onto the canvas before double-clicking on it and hitting Add next to the Server parameter.

    Configuring a node in Node-RED

  8. In a separate browser window, open the web UI of your Home Assistant container.
  9. Click on the Username at the bottom of the navbar, switch to the Security tab, and click on the Create token option under Long-lived access tokens.

    Creating an Access Code in HASS

  10. Give a Name to your token, tap OK, and copy the newly-created Access Token to your clipboard.

    Giving a name to an access token in HASS

  11. Head back to the Node-RED web UI, enter the URL of your HASS server as the Base URL, paste the Access Token you copied earlier into its respective field, and press Add.

    Adding the Home Assistant server to Node-RED

    If your Home Assistant server doesn’t have proper SSL certifications, check the Accept Unauthorized SSL Certificates option.

  12. Hit the Deploy button and wait for Node-RED to finish applying the changes.

    Deploying the Node-RED automation

Configuring Node-RED for your smart home gadgets

Regardless of the method you’ve used to set up Node-RED, its functionality and UI will be the same. If it looks too complicated, here are some pointers to help you get started with the automation tool:

  1. The left side of the Node-RED includes a variety of nodes, which use messages to communicate with each other and can perform certain actions on your HASS devices. As such, they’re the bread-and-butter of Node-RED automation.

    Adding nodes to Node-RED

  2. To use a node, you’ll have to drag it onto the canvas. For instance, you can use the Inject node to pass a message to other nodes, and double-clicking it will reveal a couple of parameters.

    Configuring the nodes in Node-RED

  3. On its own, most nodes aren’t all that useful. But by chaining multiple nodes, you can create flows comprising if-else conditions to automate your Home Assistant gadgets.

    Creating a flow inside Node-RED

  4. Once you’re done editing the node, be sure to click Deploy to execute the Node-RED flows.

    Deploying a Node-RED automation

Take home automation to the next level with Node-RED

With that, you can test different node combinations to your heart’s content. Hovering your cursor over a node gives a succinct description of its functionality, and you can always consult Node-RED’s rich documentation to learn about different flow libraries and node templates.

While it may seem like a complicated tool, there’s no shortage of projects you can build with Node-RED and Home Assistant. From automating your thermostat using data from SBC-powered weather stations to securing your home with RFID locks, the sky’s the limit when it comes to Node-RED projects.

Related


I use Terraform to automatically provision VMs on Proxmox – here’s how

While it may seem rather daunting, Terraform is an amazing automation tool for provisioning virtual machines on your home lab

#NodeRED #Home #Assistant #ultimate #smart #home

source: https://www.xda-developers.com/how-i-use-node-red-and-home-assistant-together/

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Popular Articles