Hey everyone, I wanted to share my journey in setting up a smart bathroom lighting system using Node-RED. I’ve been tinkering with Home Assistant for a while now, and I’m always looking for ways to make my home more efficient and user-friendly. Today, I’ll walk you through how I achieved a specific lighting scenario that I thought was a bit tricky at first, but turned out to be quite manageable with some Node-RED magic.
The Goal
I wanted my bathroom lights to automatically dim to 50% brightness when turned on. Additionally, if the lights were turned off and then on again within 15 seconds, they should return to full brightness (100%). This feature was something I thought would be perfect for nighttime use, ensuring a gentle transition from darkness without being too harsh on my eyes.
The Challenge
At first glance, this seemed straightforward, but I quickly realized that implementing it required a bit more finesse. I had to consider factors like timing, state monitoring, and ensuring the system was reliable and consistent. I wasn’t entirely sure where to start, so I decided to break it down into smaller, manageable tasks.
The Solution
After some research and experimentation, I found that Node-RED was the perfect tool for this job. Here’s a step-by-step overview of how I approached it:
-
Monitoring Light State: I set up a state monitor to keep track of the bathroom lights. This allowed me to detect when the lights were turned on or off, which was crucial for triggering the desired actions.
-
Setting Initial States: I configured the system to recognize the initial states of the lights. This meant distinguishing between the lights being turned on for the first time versus being turned on after a recent off cycle.
-
Implementing the 15-Second Timer: To achieve the 15-second window for the brightness adjustment, I used a timer function within Node-RED. This timer counted down each time the lights were turned off, ensuring that if they were turned back on within that timeframe, the system knew to adjust the brightness accordingly.
-
Adjusting Brightness Levels: Finally, I programmed the system to adjust the brightness based on the detected state. If the lights were turned on for the first time, they dimmed to 50%. If turned on within 15 seconds of being off, they reverted to 100% brightness.
The Outcome
After some trial and error, the system worked perfectly! It was a great feeling to see everything come together. The bathroom lights now behave exactly as I envisioned, providing the perfect amount of light depending on the situation. This setup has significantly improved my nighttime routine, making it more comfortable and convenient.
Lessons Learned
This project taught me a few valuable lessons. First, breaking down a problem into smaller parts makes it much more manageable. Second, Node-RED is an incredibly powerful tool for creating custom automation solutions, even for seemingly complex tasks. Lastly, the Home Assistant community is amazing—without the resources and guidance available online, I wouldn’t have been able to pull this off so smoothly.
If anyone has questions or needs help with similar projects, feel free to reach out! I’d be happy to share more details or troubleshoot any issues you might encounter. Happy automating! ![]()