Node-RED + Home Assistant: When Visual Flows Beat YAML
- What Node-RED Actually Does
- When YAML Beats Node-RED
- When Node-RED Beats YAML
- Installing Node-RED for Home Assistant
- The Five Node Types You'll Use 90% of the Time
- A Real Flow I Run: Hallway Motion With Cooldown
- Sharing Flows Between Installs
- Common Pitfalls That Trip Up Beginners
- Backup, Version Control, and Recovery
- When to Migrate Existing Automations from YAML to Node-RED
- A Quick Reference Guide to Node Naming Conventions
This post may contain affiliate links. As an Amazon Associate we earn from qualifying purchases. Disclosure.
Home Assistant YAML automations get hard to read past 30 lines. Once conditions and templates start nesting three levels deep, the file becomes a write-only artefact -- impossible to debug at 11 PM when the hallway lights stop working. Node-RED replaces that with a visual graph anyone can read in 30 seconds.
Home Assistant YAML automations get hard to read past 30 lines. Once conditions and templates start nesting three levels deep, the file becomes a write-only artefact -- impossible to debug at 11 PM when the hallway lights stop working. Node-RED replaces that with a visual graph anyone can read in 30 seconds.
I started using Node-RED for Home Assistant in 2020 after a single 120-line YAML automation took me four hours to debug. Six years later the install runs roughly 60% of automations in YAML and 40% in Node-RED. The split matters; both tools have their lane.
What Node-RED Actually Does
Node-RED is a visual flow editor where each automation is a graph of nodes connected by wires. Each node performs one operation: listen for an event, evaluate a condition, call a service, send a notification. The wires define the flow of execution.
The visual representation produces three immediate benefits. First, you can read a 50-node flow faster than a 50-line YAML file because the graph shows branching and dependencies explicitly. Second, debugging is direct -- you see exactly which nodes fired in the last execution and which branches were taken. Third, modifying flows feels safer because the graph reveals which other parts of the automation depend on the node you're editing.
The cost is the additional layer. Node-RED runs as a separate process talking to Home Assistant over WebSocket. That adds 100-200 MB of memory use and a small dependency surface. Whether that cost is worth it depends on how complex your automations get.
When YAML Beats Node-RED
For honesty, most automations are better in YAML. Five examples:
- "When the front door opens, turn on the hallway light" -- 6 lines of YAML, 4 nodes in Node-RED, YAML wins on simplicity
- "Run the morning routine at 6:45 AM" -- 8 lines of YAML with a time trigger, marginally clearer in Node-RED but not enough to justify the switch
- "When the temperature goes above 25 degrees, turn on the fan" -- 10 lines of YAML, basic state-and-service flow, YAML wins
- "Notify me if the freezer goes above -10" -- 12 lines of YAML with an alert template, YAML wins
- "Sync two switches together" -- 15 lines of YAML with an automation pair, YAML wins
The rule of thumb is that any automation expressible in under 20 lines of YAML stays in YAML. Going to Node-RED for these adds friction without benefit.
When Node-RED Beats YAML
The wins come on complex flows. Five examples where Node-RED is clearly better:
- Motion automation with separate day/night branches plus cooldown plus notification escalation
- Security automation that detects glass break, correlates with motion within 10 seconds, fires multi-channel notifications, and runs an action layer with retry logic
- Morning routine that checks five conditions (day of week, away mode, partner's calendar, weather, sunrise time) before deciding which sub-routine to run
- Heating optimisation that combines outdoor temperature, indoor humidity, room presence, time of day, and energy tariff into a per-room setpoint
- Voice assistant intent handler that interprets the spoken phrase and dispatches to different services based on extracted entities
Each of these as YAML runs 100+ lines with nested conditions, template sensors, and helper automations. The Node-RED version is 15-40 nodes in a graph that anyone can follow.
Installing Node-RED for Home Assistant
The official Node-RED add-on is the right install path for Home Assistant OS and Supervised installs. The Node-RED add-on documentation walks through the install. Five minutes total.
After install, configure the Home Assistant Companion integration in Node-RED with the long-lived access token. Once paired, the Home Assistant nodes appear in the left palette: events:state, current_state, call_service, notify, and similar.
The first flow to build is something boringly simple to validate the connection. Drag an events:state node listening to your front door sensor, wire it to a call_service node calling notify.mobile_app_yourphone. Deploy. Open the door. Phone notification arrives within a second. That confirms the WebSocket pairing is working end to end.
The Five Node Types You'll Use 90% of the Time
Node-RED ships with thousands of nodes. The Home Assistant ecosystem adds another 40. In practice, five do the heavy lifting.
The events:state node fires when a Home Assistant entity's state changes. Use it as the primary trigger for state-based automations. Filter on specific from-state and to-state values to avoid spurious triggers.
The current_state node reads the current value of any entity without waiting for a change. Use it inside a flow to check related state -- "the motion sensor fired, but is the person home?" reads home/away state through current_state.
The switch node branches based on a property of the message. Most flows have at least one switch -- time of day, presence state, or sensor value driving a decision. Set up explicit cases plus an "otherwise" default branch.
The call_service node fires Home Assistant service calls. The most common: light.turn_on, light.turn_off, climate.set_temperature, notify.mobile_app, switch.toggle. The node accepts JSON data payloads for service parameters.
The function node runs arbitrary JavaScript on the message. Use sparingly -- function nodes are powerful but hide logic that would be visible if expressed as separate nodes. Reserve for genuinely custom transformations.
A Real Flow I Run: Hallway Motion With Cooldown
The hallway motion automation in my flat runs entirely in Node-RED because it has three time-of-day branches and a cooldown layer. The flow has 12 nodes:
The trigger is an events:state node watching the PIR sensor. The first switch branches on time of day (before 11 PM, between 11 PM and 6 AM, after 6 AM). Each branch flows to a call_service node configuring brightness appropriately -- 100% during day, 5% at night, 50% in evening transition.
After the service call, a delay node waits 60 seconds. A second events:state node checks whether motion is still detected; if not, a turn-off service fires. A final cooldown node prevents the entire flow from re-running for 5 minutes after the most recent trigger.
The same logic in YAML is roughly 80 lines with nested conditions and helper template sensors. The Node-RED version reads top-to-bottom in the graph and is genuinely understandable to anyone who knows what a state change looks like.
Sharing Flows Between Installs
One of Node-RED's underused features is flow export and import. Each flow has a JSON representation; copy it from the Export menu, paste it into another install, and the same flow runs there. This is how I keep development and production HA installs in sync.
A few caveats. Entity names baked into flows need replacement on import (the source install might call the sensor binary_sensor.hallway_motion while the destination calls it binary_sensor.entryway_pir). The HA Companion integration must be set up on the destination before import. Otherwise the flow JSON is portable.
The community shares useful flow templates on the Node-RED official site and various GitHub repos. Browse them for ideas rather than direct copy because everyone's entity names differ, but the patterns transfer.
Common Pitfalls That Trip Up Beginners
Three errors I see repeatedly in newcomer Node-RED setups:
The first is missing the "Deploy" button. Node-RED holds changes in memory until you click Deploy. Edit a flow, save, walk away, come back tomorrow -- the changes are lost. Always deploy after each meaningful change.
The second is forgetting to add cooldown to motion or state-change flows. A door sensor that flips on/off rapidly during installation causes a Node-RED flow to fire dozens of times in a few seconds. Build in a delay or cooldown from the first version, not the third.
The third is putting too much logic in function nodes. A function node with 100 lines of JavaScript defeats the visual nature of Node-RED. If you find yourself writing long function code, split into multiple smaller nodes that show the logic flow visually, or move that logic into a Home Assistant template sensor and reference it via current_state.
Backup, Version Control, and Recovery
Flows live in a single JSON file at the Node-RED data path. Back this up alongside Home Assistant snapshots; otherwise a Node-RED reinstall loses all your flows.
For serious installs, keep the flows file in a Git repository. Manual commits after each significant change provide version history -- when something breaks you can diff against last week's version and find what changed.
Recovery from a corrupted flows file is painful because Node-RED writes the file actively. Stop Node-RED before restoring a backed-up flows file; otherwise the running instance overwrites your restoration. Test the recovery procedure on a non-production install before you need it.
Node-RED is not the answer to every Home Assistant automation, but for the 5-15 complex automations every serious install eventually accumulates, it transforms maintenance burden from "rewrite the YAML" to "rearrange a few wires". That difference is what justifies the small additional install footprint and the brief learning curve.
When to Migrate Existing Automations from YAML to Node-RED
The honest answer is "rarely, all at once". Migrating working YAML automations to Node-RED takes longer than writing the same logic fresh and produces no benefit if the original YAML already works. Three situations justify a migration regardless.
The first is when the YAML automation is genuinely broken and you cannot debug it. A migration to Node-RED turns the YAML branching into visible nodes; the bug usually becomes obvious within the migration itself because the visual structure surfaces logic gaps that were hidden in nested conditions.
The second is when the automation needs to grow. A YAML automation that currently fits in 30 lines but is about to gain three more conditions is right at the breaking point. Migrating before adding the new conditions is easier than migrating after they're tangled into the existing logic.
The third is when a non-technical household member needs to understand the automation. A Node-RED flow is enough of a visual diagram that a partner or housemate can follow the logic. A 50-line YAML file with nested templates is opaque to anyone who doesn't write code daily. This is the soft-power case for Node-RED -- making smart home logic understandable to everyone living in the house.
The other 95% of the time, leave working YAML alone and use Node-RED for new complex automations going forward. The combined system stays manageable that way; trying to convert everything at once is a multi-day project with no functional payoff.
A Quick Reference Guide to Node Naming Conventions
To close, the naming conventions I follow on every flow:
Trigger nodes get a descriptive name -- "Motion: hallway PIR" rather than the default "events:state". The name appears in the editor and in execution logs, so meaningful names speed up debugging.
Switch nodes get the property they're switching on in the name -- "Switch: time of day" rather than the default. When you see eight switch nodes in a complex flow, the names tell you which one to inspect.
Service call nodes get the action they perform -- "Light: hallway 5% night" rather than the default "call_service". This makes the flow read like instructions rather than infrastructure.
The naming discipline is small but the cumulative effect on long-term maintainability is dramatic. Future-you opening a year-old flow can read what each node does without clicking into the config. That alone justifies the few extra seconds per node.
Frequently Asked Questions
When should I pick Node-RED over Home Assistant YAML automations?
Pick Node-RED for automations with three or more conditions, multiple action branches, or anything you'll need to debug months later. Stick with YAML for simple state-change triggers, scheduled tasks, and any automation that fits in 15 lines. The two systems coexist fine in one install -- use each for what it does best rather than committing entirely to one.
Does Node-RED replace Home Assistant automation YAML completely?
No. They coexist. Most production HA installs use YAML for the majority of simple automations and Node-RED for the 5-15 complex ones. Node-RED is better for branching logic and harder to use for simple "state X triggers service Y" cases that YAML handles in 4 lines. Use whichever lets you express the automation more clearly per case.
How does Node-RED talk to Home Assistant?
The Node-RED Companion integration plus the node-red-contrib-home-assistant-websocket palette opens a WebSocket connection from Node-RED to Home Assistant Core. Node-RED listens to state changes, calls services, reads sensor values, and updates entities through that channel. Latency between Node-RED action and HA state change is typically under 100ms on a local install.
What is the learning curve to start with Node-RED?
One evening to install and build a first flow. One weekend to build five real automations and understand the common nodes (events:state, switch, function, current_state, call_service, notify). Two months to internalise patterns and develop personal conventions. The visual nature shortens the learning curve compared to YAML, particularly for users coming from non-developer backgrounds.
Does Node-RED use more resources than YAML automations?
Yes, but not dramatically. Node-RED runs as a separate process using roughly 100-200 MB of RAM on top of Home Assistant. A Raspberry Pi 5 with 8 GB handles both easily. On smaller hardware (Pi 4 with 4 GB) Node-RED is noticeable but still manageable. The CPU overhead per flow execution is negligible compared to the actual service calls.