Computer

Home Assistant + Node-RED: Build Insane Smart Home Automations

πŸ“… Updated: December 2025 ⏱️ 12 min read 🏠 Smart Home

Home Assistant's built-in automations are good. Node-RED makes them extraordinary. With Node-RED's visual flow editor, you can create complex multi-condition automations that would be nightmare to write in YAMLβ€”chains of "if this AND that BUT NOT when X, THEN do A, B, and C with delays."

This is how power users build truly intelligent smart homes.

What is Node-RED?

Node-RED is a visual programming tool where you connect "nodes" (triggers, conditions, actions) by dragging wires between them. It's like flowcharting, but the flowchart actually runs your home.

Benefits over Home Assistant's native automations:

  • Visual representation of complex logic
  • Easier debugging (see exactly where flows break)
  • More powerful conditional logic
  • Function nodes for custom JavaScript logic
  • Better handling of delays, loops, and sequences

Installing Node-RED in Home Assistant

  1. Add the Add-on Repository

    Go to Settings > Add-ons > Add-on Store. Click the three dots and select "Repositories." Add: https://github.com/hassio-addons/repository

  2. Install Node-RED

    Search for "Node-RED" in the add-on store and install it. Enable "Show in sidebar" for easy access.

  3. Configure Credentials

    In the add-on configuration, set your Home Assistant credentials (or use a long-lived access token).

  4. Start and Open

    Start the add-on and click "Open Web UI" to access the Node-RED editor.

Node-RED Basics

Key Node Types

  • Events: state (trigger): Fires when a Home Assistant entity changes state
  • Current state: Checks the current state of an entity
  • Call service: Calls a Home Assistant service (turn on lights, send notifications, etc.)
  • Switch: Routes messages based on conditions
  • Delay: Adds a time delay between actions
  • Function: Custom JavaScript for complex logic

Basic Flow Structure

[Trigger] β†’ [Condition] β†’ [Action]

Example:
[Motion Detected] β†’ [Is it dark?] β†’ [Turn on lights]

Automation Examples

Example 1: Smart Kitchen Light

"If motion in kitchen AND time is after sunset AND fridge door has been open for 5 minutes, send notification 'Close the fridge!'"

Flow:
[Motion sensor: state changed to 'on']
    ↓
[Current state: sun.sun = 'below_horizon'?] β†’ Yes
    ↓
[Current state: fridge door = 'on'?] β†’ Yes
    ↓
[Delay: 5 minutes]
    ↓
[Current state: fridge door still 'on'?] β†’ Yes
    ↓
[Call service: notify.mobile_app "Close the fridge!"]

Example 2: Morning Routine

"When alarm is dismissed, slowly brighten bedroom lights, start coffee maker, and read weather forecast."

Flow:
[Phone alarm dismissed]
    ↓
[Call service: light.turn_on bedroom, brightness 10%]
    ↓
[Delay: 1 minute]
    ↓
[Call service: light.turn_on bedroom, brightness 50%]
    ↓
[Call service: switch.turn_on coffee_maker]
    ↓
[Get weather data] β†’ [TTS: Read weather aloud]

Example 3: Presence-Based HVAC

"If everyone leaves home, set thermostat to away mode. When first person returns, restore comfort settingsβ€”but only if we've been away for more than 30 minutes."

πŸ’‘ Pro Tip: Use Subflows

For repeated logic patterns, create subflows (reusable flow components). For example, a "notify all phones" subflow can be used across multiple automations without duplicating nodes.

Advanced Techniques

Function Nodes for Custom Logic

When visual nodes aren't enough, use JavaScript:

// Only proceed if entity has been in state for 10+ minutes
const lastChanged = new Date(msg.data.old_state.last_changed);
const now = new Date();
const minutesInState = (now - lastChanged) / 60000;

if (minutesInState >= 10) {
    return msg;
}
return null;  // Don't continue flow

Rate Limiting

Prevent notification spam with the "delay" node in rate-limit mode. Example: Only send one motion alert per 10 minutes.

Context Storage

Store values between flow runs using flow or global context:

// Store a value
flow.set('lastMotionTime', Date.now());

// Retrieve it later
const lastMotion = flow.get('lastMotionTime');

Debugging Flows

  • Debug nodes: Add debug nodes to see what data is flowing through
  • Status indicators: Nodes show green/blue dots when triggered
  • Console: View errors and logs in the sidebar debug panel
  • Inject nodes: Manually trigger flows for testing

⚠️ Avoid Infinite Loops

Be careful with automations that trigger on state changes they cause. "When light turns on, set brightness" can loop forever if you're not careful. Use conditions to break potential loops.

Learning Resources

  • Node-RED Documentation: Official docs cover all node types
  • Home Assistant Community: Node-RED subforum has example flows
  • YouTube: Search "Node-RED Home Assistant" for visual tutorials
  • Import flows: Community-shared flows can be imported directly

Conclusion

Node-RED transforms Home Assistant from a smart home platform into a truly programmable home. The visual interface makes complex logic accessible, and the debugging tools make troubleshooting far easier than traditional YAML automations.

Start with one complex automation that frustrated you in native HA, rebuild it in Node-RED, and you'll quickly see why power users swear by this combination.