← Back to Home

How to Set Up Home Assistant with Node-RED for Automation 2026

Published: March 2026 | Reading Time: 16 minutes

Home Assistant is the most powerful open-source smart home platform available, and Node-RED provides a visual flow-based programming environment that makes complex automations accessible to everyone.

Together, Home Assistant + Node-RED gives you enterprise-grade automation capabilities with a intuitive drag-and-drop interface. In this guide, I'll walk you through setting up both from scratch.

Why Home Assistant + Node-RED?

Home Assistant's built-in automation editor is functional, but YAML-based automations become hard to maintain as your system grows. Node-RED solves this by providing:

Prerequisites

Method 1: Install Node-RED via Home Assistant Add-on (Recommended)

The easiest way to install Node-RED is through the Home Assistant Community Add-ons store.

Step 1: Add the Community Add-ons Repository

1. Go to Settings → Add-ons
2. Click "Add-on store" in the bottom right
3. Click the three dots menu → "Repositories"
4. Add: https://github.com/hassio-addons/repository
5. Click "Add" then "Close"

Step 2: Install Node-RED Add-on

1. Find "Node-RED" in the add-on store
2. Click "Install"
3. Wait for installation to complete
4. Configure the add-on (see recommended settings below)

Step 3: Configure Node-RED

Recommended configuration for config.yaml:

credential_secret: your-secret-password
dark_mode: true
http_node:
  username: ""
  password: ""
http_static:
  username: ""
  password: ""
ssl: true
certfile: fullchain.pem
keyfile: privkey.pem
require_ssl: true
init_commands: []

Step 4: Start Node-RED

1. Start the add-on
2. Open the web UI
3. Set up your username/password
4. You're ready!

Method 2: Standalone Node-RED Installation

If you prefer running Node-RED separately or already have Node.js installed:

Install via npm

sudo npm install -g --unsafe-perm node-red

Install the Home Assistant nodes

cd ~/.node-red
npm install node-red-contrib-home-assistant-websocket

Run Node-RED

node-red -p 1880

Connecting Node-RED to Home Assistant

For the integration to work, you need to generate a Long-Lived Access Token in Home Assistant:

Step 1: Generate Access Token

1. In Home Assistant, go to your Profile (click your name)
2. Scroll down to "Long-Lived Access Tokens"
3. Click "Create Token"
4. Name it "Node-RED" and copy the token

Step 2: Add Home Assistant Server in Node-RED

1. In Node-RED, drag an "Events: All" node or "Current State" node onto the canvas
2. Double-click to edit
3. Click the pencil icon to add a new server
4. Enter your Home Assistant URL: http://YOUR_HASS_IP:8123
5. Paste your access token
6. Click "Add"

Essential Node-RED Nodes for Home Assistant

Node Purpose
Events: AllListen for all Home Assistant events
Events: StateListen for entity state changes
Current StateGet current state of any entity
Call ServiceControl Home Assistant devices
APIMake direct API calls
Fire EventTrigger Home Assistant events

Building Your First Node-RED Automation

Example 1: Motion-Triggered Lights

Let's create a simple automation: when motion is detected after sunset, turn on the living room lights.

[Step 1] Events: State node
  - Entity ID: sensor.motion_living_room
  - State: "on"

[Step 2] Current State node (for sun condition)
  - Entity ID: sun.sun
  - State: "below_horizon"

[Step 3] Switch node
  - Check if sun is below_horizon

[Step 4] Call Service node
  - Domain: light
  - Service: turn_on
  - Entity ID: light.living_room
  - Data: {"brightness": 255, "kelvin": 2700}

Example 2: Presence-Based Automation

// Pseudo-code for "Everyone Left Home" automation
WHEN: Any phone's device_tracker state changes to "not_home"
AND: All other phones are also "not_home"
AND: No one is home for 2 minutes
THEN:
  - Lock all doors
  - Set thermostat to eco mode
  - Arm security system
  - Turn off all lights
  - Close garage door

Example 3: Advanced: Smart Lighting Scene Controller

Create a flow that cycles through scenes when you double-tap a switch:

[Trigger] Scene activated → "switch.button1"
[Check] Current scene state entity
[Switch]
  - Scene 1 → Set Scene 1
  - Scene 2 → Set Scene 2
  - Scene 3 → Set Scene 3
  - Default → Set Scene 1
[Delay] 50ms (debounce)
[Fire Event] homeassistant/scene_changed

Node-RED Best Practices

1. Use Subflows for Reusable Logic

Create subflows for common patterns like notifications, scene changes, or presence detection. This makes your flows modular and easier to debug.

2. Implement Error Handling

[Catch node] → [Debug node] → [Notify me via Pushbullet]

Always include error handling in critical flows. The Catch node catches any errors in your flow.

3. Use Comments and Labels

Add comment nodes to document your flows. Future you will thank present you.

4. Debug with Inject Nodes

The Inject node lets you manually trigger events during testing. Use it to simulate state changes without physically triggering sensors.

Importing Community Flows

The Node-RED community has thousands of pre-built flows. To import:

1. Find a flow you like (e.g., on flows.nodered.org)
2. Copy the JSON
3. In Node-RED, click Menu → Import
4. Paste the JSON
5. Click "Import" and drag to canvas
6. Configure for your entities

Performance Tips

Troubleshooting Common Issues

Node-RED can't connect to Home Assistant

Automation not triggering

Flows running slowly

Recommended Add-ons for Node-RED Power Users

Add-on Purpose
node-red-contrib-bigtimerAdvanced time-based scheduling
node-red-contrib-stoptimerCountdown timers
node-red-dashboardCreate custom dashboards
node-red-contrib-telegramTelegram notifications
node-red-contrib-pushbulletPush notifications

Final Thoughts

Home Assistant + Node-RED is the most powerful automation combination available for smart homes. While there's a learning curve, the visual interface makes complex automations accessible to non-programmers.

Start simple — build one or two basic flows and expand from there. The beauty of Node-RED is that you can always see exactly what's happening in your automations, making debugging a breeze compared to YAML.

Ready to get started? Install Node-RED on your Home Assistant today and import some community flows to see what's possible!

--- This site contains affiliate links. We may earn a commission at no extra cost to you when you purchase through our links.