Visual Automation in Home Assistant: Why Use Node-RED?

Visual Automation in Home Assistant: Why Use Node-RED?

When building smart home automations, one of the biggest challenges is: how do you actually implement the logic? While Home Assistant's automation.yaml scripting is powerful, it can be intimidating for beginners.

That’s where Node-RED comes in. This visual programming tool, fully compatible with Home Assistant, allows users to create automations by connecting blocks instead of writing code. It’s a game-changer for those who want a more intuitive way to manage smart home logic.

What makes Node-RED especially powerful is its built-in support for protocols like HTTP, MQTT, and WebSocket—allowing seamless integration with external systems. In this post, we’ll walk through an example of using an external HTTP webhook to control a virtual presence sensor in Home Assistant using Node-RED.



Step 1: Installing Node-RED (Add-on Method)

  1. Go to Home Assistant's Supervisor menu > Add-on Store.
  2. Search for Node-RED and install it.
  3. Set a credential_secret in the Configuration tab.
  4. Click Start to run the add-on.

Access the editor via: http://<your_home_assistant_ip>:1880

Step 2: Port Forwarding for External Webhook Access

To call the webhook from outside your home network, you’ll need to configure port forwarding on your router:

  • External Port: 18800
  • Internal IP: IP address of the Node-RED add-on
  • Internal Port: 1880

Once set, you can trigger presence ON via a URL like:
http://your.public.ip:18800/webhook_presence_on?key=redchupa

Step 3: Example Flow – Controlling Presence via Webhook



This Node-RED flow demonstrates how to control input_boolean.presence_virtual_1 externally via HTTP GET requests.

Authentication is handled using the query key: ?key=redchupakey

🔁 Flow Overview

  1. Receive GET requests at /webhook_presence_on or /webhook_presence_off using an HTTP In node.
  2. Verify the key parameter in the query string.
  3. If the key is valid, turn the presence input boolean ON or OFF.
  4. Return a JSON response with the result.

✔ Webhook ON Example

GET http://your.public.ip:18800/webhook_presence_on?key=redchupakey

Effect: Turns ON input_boolean.presence_virtual_1
Response: { "success": true, "message": "Webhook OK - Presence ON" }

✔ Webhook OFF Example

GET http://your.public.ip:18800/webhook_presence_off?key=redchupakey

Effect: Turns OFF input_boolean.presence_virtual_1
Response: { "success": true, "message": "Webhook OK - Presence OFF" }

❌ Invalid Key Example

GET http://your.public.ip:18800/webhook_presence_on?key=wrongkey

Status Code: 401 Unauthorized
Response: { "error": "Unauthorized" }

Why Node-RED Makes External Integration Easy

With Node-RED, you’re not limited to Home Assistant’s internal automation. You can easily integrate external APIs, third-party systems, or devices using a visual, drag-and-drop interface.

The webhook example above can be used with access logs, Tasker on smartphones, Arduino triggers, or remote servers—essentially anything that can make an HTTP request.

Node-RED is an excellent tool for users who want to scale their smart home setups with flexibility and control. And once you understand the basics like the flow above, it opens the door to complex automations without needing to touch a line of YAML.

Conclusion

If you're looking to build visual, powerful, and extensible automations in Home Assistant—Node-RED is a must-try tool. It empowers you to go beyond the basics and connect your smart home to the world, with full control and clarity.

Questions? Comments? Share your experience below and let’s automate smartly—together!

댓글