April 06, 2025

Home Assistant and Node-RED

Node-Red(NR) is Flow-based programming for the Internet of Things

I have in the past written a lot of posts for Node-RED and the HA implementation makes it easy to interact with HA:s entities.

The best thing is that even if you don't are a skilled programmer, but like logic flows, you can make really advanced things and it really complements the logic that could be made within Home Assistant(HA).

In this post a will do a quick introduction to what is possible with NR together with HA.


Install
Node-RED
Install NR from the "Add-on store" and search for "Node-RED". After the installation activate 
  • Start on boot
  • Watchdog
  • Show in sidebar
then go to the ”Configuration” tab, inhibit SSL and then ”Start”. 

Node-RED Companion
If you in NR, for example, want to create a temperature entity from some random sensor you also have to install a custom integration, using HACS, the "Node-RED Companion". Follow the instructions and then reload HA.

Examples
As an example, check picture, I'm retrieving temperature, with a poll node, from a SONOFF temperature  sensor. The resolution is just 0,2 degrees Celsius so taking the average of the last 10 measures I will get more decimals and a smoother output. Then the temperature is sent back to HA with a sensor node

The second flow is getting the temperatures, with a get history node, for the last 60 minutes from the HA database.

Raspberry Pi GPIO
Please note that you can't use the standard node for using the GPIO pins on a RPi !! 
This is because it was removed in Home Assistant Core version 2022.6, but as always there is a work around. Via HACS install rpi_gpio.

After the installation edit "/homeassistant/configuration.yaml" and add

switch:
  - platform: rpi_gpio
    switches:
      - port: 17
        name: "Speaker Relay"

restart HA and then you could use it as an output both from HA and NR.


.
.
.

To be continued !

No comments:

Post a Comment

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !