Node-RED has replaced my complex Home Assistant automations, and it does them so much better

1 month ago 3

The self-hosting ecosystem is rife with cool and quirky apps designed to automate every facet of your life. There’s the holy Terraform and Ansible combo for home lab enthusiasts who love watching VMs come to life without pressing a single button, while n8n can handle all software-based automations. On the smart home side, you’ll often find Home Assistant as the most recommended utility for creating schematics to control your IoT gadgets. And well, HASS can serve you well with its trigger-action workflows.

For YAML experts, you can even design long scripts to automate your smart home. But once you get into complicated workflows involving multiple sensors, actuators, and if-else statements, HASS starts to become rather unintuitive. While I still rely on Home Assistant for quick automations, Node-RED is my preferred platform for creating extended automation workflows spanning several smart devices in my living space.

Pulling data from Frigate into Home Assistant

Related

It pairs well with my Home Assistant devices

But HASS isn’t the only data server for my Node-RED instance

I consider Home Assistant the centerpiece of my rat’s nest of an apartment and have mapped most smart devices, IoT gadgets, and even home lab equipment (via HACS integrations) to my HASS hub. As such, it acts as a data-gathering terminal in addition to its role as a control center.

Since my Node-RED instance is connected to my HASS server, it can directly grab statistics from my devices and push any message payloads I define in my custom workflows. I use a standalone Node-RED container instead of running it on top of Home Assistant, so I don’t have to rely on just HASS for my smart home automation.

On that subject, I’ve already connected my Node-RED server to a Raspberry Pi-based MQTT broker, so I can automate MQTT communication with just these services. Heck, it even integrates with external APIs and webhooks, making it perfect for the times when I want to use the VMs and containers from my Proxmox server for my home automation projects.

Amazing for automation chains

The node-based workflow makes everything easier

The Node-RED web UI

Upon first glance, a Node-RED canvas filled to the brim with node chains, functions, and variables can seem intimidating. However, the ability to represent every device as a node makes it easy to organize everything, and I can import multiple IoT products inside a single workflow.

On Home Assistant, I’d have to cycle between the Entities, Helpers, Scripts, and Events tabs every time I want to create a multi-device automation chain. Besides the added advantage of accessing my smart devices from a single page, Node-RED lets me reuse the function nodes as many times as I want, which is a godsend for projects requiring complex if-else logic with branching instructions.

No more YAML shenanigans

Although YAML syntax is nowhere near as complex as a mainstream programming language’s coding rules, it’s a pain to design complicated workflows with it. Home Assistant makes YAML scripting somewhat easy with the Developer Tools tab, but it’s far from the most intuitive option, especially since I can just use Node-RED.

That’s because Node-RED has a minimal coding approach, as even the most complicated automation can be arranged in a node-based workflow. This visual aspect makes it easier to add nested logic, chains of loops, and long branches in a Node-RED canvas. As if that’s not enough, I can install custom modules and libraries for most communication protocols and external APIs in Node-RED.

Solid troubleshooting provisions

Automating window blinds with Node-RED

Finally, Node-RED makes finding errors in my workflow a cinch. It’s a lot easier to detect errors in a Node-RED-based flow than a huge YAML file, where I can have several indentation errors because of accidentally pressing the Spacebar or Enter keys. In contrast, my mistakes are infinitely easier to catch on Node-RED’s canvas, as I can see how the different gadgets affect each other.

That said, HASS is better for simple automation projects

So far, I’ve only discussed why Node-RED suits my smart home projects. But I’d be biased if I didn’t talk about its drawbacks. Despite providing easier methods for automating complex projects, Node-RED has a steeper learning curve than Home Assistant. Plus, community-created blueprints are a neat utility in Home Assistant for casual users who want to quick put together motion-controlled lights.

However, if you’re looking to build something as convoluted as a surveillance system that automatically turns on the lights and sets the right thermostat temperature when it detects your presence, it’s a good idea to go with Node-RED as your automation platform.

Arduino Uno and some other microcontrollers

Related

Here’s how you can connect your microcontrollers with Home Assistant

Want to inject some microcontroller magic into your smart home? You've come to the right place!

Read Entire Article