Get Alexa to control specific devices in each room (not just lights)

You can set up groups in Alexa for each room, and it will be able to control the specific lights in that group. E.g. If an Echo belongs to the Kitchen group, and you say “Alexa, turn on the lights” to that Echo, then it will just turn on the kitchen lights. Unfortunately this can’t be extended to TVs, heat pumps, or any other types of devices.

For example, you need to say “turn on the bedroom TV” in the bedroom, “turn on the living room TV”, etc. I wanted to just be able to say “turn on the TV” and turn on whichever TV is closest to that Echo.

I was able to get a proof of concept working. I used the alexa_media_player add-on. This sets up a media.*** entity for each Echo, and the attributes include a last_called boolean value. This is only true for the Echo that was most recently activated.

I set up this flow in Node-RED to iterate over each Echo and find the one where last_called is true.

I set up a script in Home Assistant to trigger this Node-RED entity (nodered.trigger), and then this was available to Alexa as a Scene. (Not sure why scripts get set up as scenes in Alexa but it works!)

I made a test routine to send a notification to my phone and went around the house trying each Echo:



So now I’ve got all the building blocks I need to set up routines for “turn on the TV”, “turn on the heater”, “open the blinds”, etc.

The only issue is that I need to wait around 2 seconds for the Echo state to be reliably updated, so it’s a little bit slower, but still pretty convenient.


Please let me know if there’s an easier way to do this! I’d be interested to know if Alexa sends any information about the current Echo device along with their API call. If so, then it could be interesting to create a home assistant add-on to do this properly. Would be nice if there an easier way to set up virtual entities (“TV”, “Heat Pump”, etc.) and assign them to different Echo devices.

Actually here’s a better way to do this. I can just set a global variable whenever an Echo state changes.

I could also check the last_called_timestamp attribute and wait until this has been updated recently.

This was actually pretty tricky to figure out! It turns out that I did need to add a loop and wait for a recent Echo update.

The flow is usually triggered seconds before the Echo update comes through, so I need to wait until last_called_echo_timestamp has been updated recently, then move on and stop the loop timer.

Was a fun puzzle to solve on the weekend!