Optimizing Smart Lighting with Room-Aware Alexa Commands

Hey everyone! I’ve been diving into the world of smart lighting and wanted to share a fantastic setup I’ve been working on using Node-RED and Alexa. The goal was to create a seamless experience where lights adjust automatically based on which room I’m in, without needing to specify the room in my voice command. Here’s how I made it happen!

First, I set up an input boolean in Home Assistant called input_boolean.room_aware. This acts as a signal to other flows, letting them know that the currently listening Alexa device has been identified. I used Node-RED to listen for state changes in the Alexa Media Player component. Whenever a device is actively listening, it triggers the room_aware boolean to turn on. After a short delay, it turns off again, ensuring that only the most recent device is considered.

Next, I created a flow that listens for voice commands like “Alexa, turn on the lights” or “Alexa, dim the lights”. When a command is detected, the flow checks which device was last active (stored in a flow variable) and maps it to the corresponding light entities. For example, if I say “Alexa, turn on the lights” in the living room, the flow knows to target the living room lights without me having to specify it.

I also expanded this concept to fans and thermostats, making sure each room’s devices are controlled based on the Alexa device’s location. It’s been a game-changer for how I interact with my smart home!

One thing I struggled with initially was ensuring the room_aware boolean updated quickly enough. There were a few false triggers, but tweaking the delay and ensuring the flows were optimized solved that. I’d recommend testing thoroughly in different scenarios to iron out any kinks.

If anyone has tips on improving this setup or suggestions for other devices to integrate, I’d love to hear them! It’s been amazing to see how much smoother my home automation has become with this approach.