[OUTDATED -> MOVED & UPDATED] Easy Node Red Room aware Alexa voice commands

The information from this post has become outdated. For a newer operative version go to:

2 Likes

A far simpler way is to use the Alexa app to tell your echo devices which devices are in the same room as them.

For sure, in fact I have it that way and I’m gonna leave it that way… But for some people that need more complex actions when they say ‘Turn on’ or whatever, this is a great solution

for example, when I say turn on the light, if it’s dark, turn it on white and at 100%, however, if I’m watching a movie, turn it on blue and at 20%… you just can’t do that with the Alexa app, unless you don’t mind recalling various different sentences, one for each state

But that’s not relevant to the room.

“Alexa, turn on the light” > Alexa knows which light to turn on because it’s grouped in the Alexa app > Homeassistant/node red receives the command to turn on the light > applies the correct parameters based on whether or not you’re watching a movie.

At no point in that flow did homeassistant need to know which Alexa device was used, and in fact it would be counterintuitive as I could just as easily used a different echo device in the house to turn on the same light - “Alexa, turn on the living room light” to the bedroom echo device.

you might be right

There was a mistake in the previous flow, everything has been updated in the first post

Do alexa groups work the same way when you say, for example, ‘Alexa, turn off the fan’? or ‘Turn off the TV’… Cause I don’t think so…

Of course. You tell Alexa what’s in the same room as the device, and then when you say turn on X it turns on that room’s X. Or you can say turn on bedroom X and it will turn that one on instead.

you can’t have two smart switches with the same name ‘Fan’, can you? It would work for that.

Another advantage is that when you turn off a light, lifx for example, home assistant can take up to 15 seconds to realize it’s been turned off. If you have any automation that triggers when that light changes its state, this is a great thing to have.

Or for example let’s say you have 3 mirror spread over your house in 3 different locations, and you want to be able to say ‘turn on the mirror’… it would be useful in that scenario too.

another advantage is probably with DIY projects?

but hey, no problem my man, if you don’t find it useful, just ignore it. I might just be a silly guy who likes to overwork

I would appreciate if you could send me a flow or some code to completely understand what you mean when you say you can do the exact same thing using only the Alexa app, cause I don’t see that

I’m using node-red-contrib-amazon-echo (node) - Node-RED, controlling all devices I need and everything local.

Alexa controlled Node-Red nodes supporting latest Amazon Echo devices

NO Alexa Skills required.

NO cloud dependencies.

What I don’t like about that one is that when you say ‘Turn on X light at Y%’, if the light was turned off previously, or something of the like, it’ll send two consecutive messages, one with the previous brightness % and another with the new brightness%. I have 95% of my devices using node-red-contrib-amazon-echo (node) - Node-RED for plain on/off commands

if you work with light transitions, they get crippled… flows are triggered twice and I ended up using a throttle to avoid that

but yeah, it’s great for on/off commands, one less dependency

No need to get defensive about it.

I can’t send you the internal workings of the Alexa app, because it’s proprietary, but I can assure you that you can add devices to groups in the app to group them with a particular echo device. It’s not that complicated a concept and it works really well.

The mirror example you gave:

Put the bedroom mirror in a group with the bedroom echo, kitchen mirror with kitchen echo, living room mirror with living room echo.

“Alexa, turn on the mirror” will turn on the mirror in the room that the echo device is in.

I didn’t know that could be done. I believe you can’t put several devices with the exact same name, you can’t put 3 devices with the name ‘mirror’. What you are saying is that if you set 3 different devices to ‘mirror A’, ‘mirror B’ and ‘mirror C’ in different groups,by saying ‘turn on the mirror’, Alexa will turn the mirror of the group containing both the echo device and the mirror X. I didn’t know that. Are you 100% positive about it? I believed that if you put Mirror A, B and C and said ‘turn on the mirror’, Alexa would complain: ‘You have several devices called mirror, which one do you want to turn on?’. At least that’s my experience.

By code I meant, how do you get your device to turn on according to some HA conditions?

It works fine. I use it for multiple lights in rooms, heaters, all sorts.

It seems to work on a sort of hierarchy, so if you have a mirror in the room and you say ‘turn on mirror’ it will turn that one on. If you don’t, but have 3 in other rooms of the house it will ask you which one.

As for the homeassistant conditions, you just trigger on the device changing state and then perform the action, same as any other automation.

how do you get your device to turn on according to some HA conditions?

Lights to come on white, unless watching movie (at which point make them blue)

“Alexa, turn the light on”

trigger:
  platform: state 
  entity_id: light.led
  to: 'on'
action:
  service: light.turn_on
  data:
    entity_id: light.led
    color_name: "{{ 'blue' if is_state('binary_sensor.movie', 'on') else 'white' }}" 

Yep, I have a few automations like that one… that’s probably one of the few things where this flow is an advantage over using the Alexa app… At least with lifx, there can be a great delay. It can take up to 15 seconds before HA notices the light has changed its state so… it gets ugly you know

anyways with update_entity polling every second I managed to solve that…

I’ll leave the flow here just in case somebody finds it useful. I actually made it at request of a friend who needed it, but yeah, the Alexa app is powerful enough to avoid the hassle

1 Like

Did you send the flow, I like what you are saying.

all you need to know is in the first post

Even with that automation, the flow can do things alexa can’t… if you want your light to turn on with a fade, for example, you can’t rely on that kind of automation to achieve that…

I would use that just if there was no other way or if I were ok with how Alexa performed the action