I’ve been diving into the world of home automation, and I must say, it’s been an incredible journey! One of the most satisfying projects I’ve undertaken is setting up an automated lighting system using Node-RED within Home Assistant. I wanted to share my experience in case anyone else is looking to achieve similar functionality without diving deep into YAML files.
Initially, I was trying to figure out how to create a single automation that would turn a light on when motion is detected and then turn it off after five minutes of no motion. I stumbled upon several forums and guides, but the solutions often involved creating two separate automations—one for turning the light on and another for turning it off. While this works, I was curious if there was a more streamlined approach, especially since I wanted to explore the capabilities of Node-RED.
After some research and experimentation, I discovered that Node-RED offers a powerful way to handle such scenarios. By using the node-red-contrib-home-assistant-websocket package, I was able to create a single flow that monitors motion sensor events and controls the light accordingly. Here’s a quick breakdown of how I set it up:
- Input Node: I started with a
home-assistantinput node configured to watch for state changes on my motion sensor. - Switch Node: I added a switch node to check if the motion sensor state is
on. If it is, the light turns on immediately. - Timer Node: For the
offcondition, I introduced a timer node set to 5 minutes. This delay ensures the light remains on long enough before turning off. - Output Node: Finally, I used a
home-assistantoutput node to control the light switch based on the conditions set in the flow.
This setup has been running smoothly for a couple of weeks now, and I couldn’t be happier with the results. It’s amazing how Node-RED simplifies complex automation tasks and allows for a lot of creativity.
If anyone has questions or needs help setting up something similar, feel free to reach out! Happy automating! ![]()