Node-RED in Docker and Home Assistant integration

 

Especially complex automations may become a bit confusing in Home Assistant and its automations. If you reach the limits of the integrated automations, you can alternatively use your own automation platform such as Node-Red. In Node-Red, processes can be put together using various logic modules in a visual GUI via drag and drop.

After running Home-Assistant in Docker, Node-Red cannot be added through the add-on store, but through its own Docker container. The Node-Red container can be started in the terminal with the following command:

docker run -it -p 1880:1880 -v /home/pi/.node-red:/data --name mynodered nodered/node-red

Building on the article: Home Assistant setup in Docker, the setup described can be extended to include Node-Red by adding another text block to the file: docker-compose.yml:

version: "3"
services:
  haas:
      ....
  nodered:
      container_name: nodered
      restart: always
      image: nodered/node-red
      ports:
        - 1880:1880
      volumes:
        - ./nodered:/data
       ...

After starting the container, its web interface can be accessed via the port used:

See: https://nodered.org/docs/getting-started/docker

Username / Password

After the first start, the subfolder ./nodered used in docker-compose.yml will be filled automatically. For setting a new admin password, a password hash can be generated using the following command. Entered in the settings.js file, the password will be changed:

user@rechner:/$ docker exec -it nodered node-red-admin hash-pw
Password:
$2b$08$C.6kGG29J41ZAE2Mq3mp1eU3p/o3/1rLWNISIw7kN1fe6V65Ncq4u

File settings.js:

    adminAuth: {
        type: "credentials",
        users: [{
              username: "admin",
              password: "$2b$08$C.6kGG29J41ZAE2Mq3mp1eU3p/o3/1rLWNISIw7kN1fe6V65Ncq4u",
              permissions: "*"
          }]
      },

The web interface can then be invoked using the IP address of the Docker host and port 1880:

Now Node-RED is missing a connection to Home-Assistant, this can be set up as follows:

Connect Home Assistant to Node-Red

First I added the Node-RED Companion repository via HACS and activated the integration.

Access from Node-Red to Home Assistant is done via an Access Token, this can be created in Home Assistant via the User menu.

Back in Node-Red, we still need a "palette" for access: node-red-contrib-home-assistant-websocket

first Flow

The connection to Home Assistant takes place in a flow via "call service" to corresponding entities in Home-Assistant:

If the HACS integration is missing in Home-Assitant, a corresponding note will appear when activating it:

Conclusion

The connection to Home Assistant is done. My smart home automation requirements so far have been relatively easy to implement with Home Assistant Automations. Should I have more complex requirements in the future, I am prepared for this with Node-RED.😉

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Publication: 2023-09-11 from Bernhard | Übersetzung Deutsch |🔔 | Comments:0

WordPress in Docker incl. HTTPS Let's Encrypt setup | Container | VS code in browser - tested
HA: Use values of any WebGUI as entities | Integrations

Top articles in this section


Nextcloud Server Docker | Setup + https: Let's Encrypt [ssl]

To synchronize contacts, appointments, and photos of my NAS, I tested Nextcloud and thus turned my back on other cloud providers for my private data. Thanks to Docker, the installation is easier and more flexible than ever, allowing Nextcloud to run on almost any hardware.


Send signal messages via script / API: signal-cli-rest-api

The well-known Signal Messenger can besides the app also be used via command line or from other systems. The signal-cli-rest-api, which is available in the form of a Docker container, offers a simple option for this. For the API to work, it has to be coupled via the Signal app beforehand.


Commissioning Zigbee2MQTT in Docker - step by step

Zigbee2MQTT is an open source Zigbee bridge which can be easily integrated into existing smart home solutions thanks to the MQTT network protocol. As an example, Zigbee2MQTT combined with MQTT broker Mosquitto and Home Assistant can collect, display, record and control data from Zigbee devices. The setup described here uses Docker as a base. Manufacturer's website: https://www.zigbee2mqtt.io

Questions / Comments


By continuing to browse the site, you agree to our use of cookies. More Details