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

perhaps you have a mis-configuration? I’m using node-red-contrib-amazon-echo and it does not sent 2 consecutive messages.

Try the following sequence with alexa and some device: ‘Alexa, turn on X device at 10%’, ‘Alexa, turn off X device’, ‘Alexa turn on X device at 100%’. In the last command, it will send two consecutive messages, it doesn’t always happen, it happens when you change brightness, turn off, and then set another brightness… check out debug. First message is to turn the light on with the previous brightness, second message is to change the brightness to the requested one.

so i’m using it a bit differently. all of my devices are IN alexa, and the turn on/off / set to x % is handled by the HA alexa integration. where i use the node red part is for group commands.
so i have a node called “netflix in the living room”
so i can say “alexa turn on netflix in the living room” that command will then turn on the tv, stereo and switch to netflix" and i have several like that
I have one called “tv lights” so at night when we watch tv, I don’t like the glare from the certain lights.
so i say “alexa turn on tv lights” and that goes to a group of comands that turn off certain lights and dim others.
so in that context, i have never had that node execute any of those command twice on it’s own.

Then you just add a transition to the automation. The automation fires instantly so it overrides the previous instruction from the Alexa (which was just to turn it on).

It may not work with lifx, as you say, if there is a large delay between the device turning on and homeassistant intervening, but I can only speak for the integrations I use and I don’t have any delays.

Here, all the devices that alexa controls are exposed directly from homeassistant, so turning something on from Alexa is exactly the same as toggling it on in the interface, so homeassistant knows about it straight away because it is homeassistant that is doing it.

what integrations do you have? same happens to me with samsung tv and tuya

Problems arise when you want to use the % in the message to do stuff. Yes, for on/off commands it is a great node to have. The main goal of having room aware commands is to avoid making too many different sentences/routines or whatever which could end up being difficult to remember… Its goal is to minimize that

A load of hue, innr and xiaomi stuff integrated via Zigbee2mqtt, esphome, tp-link, kodi and cca media players and some cameras.

Yup, that’s some great gear right there :). If you can do it that way, it definetely is the easiest.

Same goes when you want to use the color attribute of the message… If you call, for example, “Turn on X light blue”, it sends the right message… However, if you send a “Turn off command” and then a “Turn on command” afterwards, the color attribute is still stored and there’s no easy way to distinguish weather you just want a turn on command or a set color command… with the last turn on command the color attributes are sent either way

Suppose I want the following.

When I say ‘Alexa, turn on the light’, I want it to be turned on white by default.

If the last time the light was turned off it was say, red, when I request that, it’ll turn on red. To fix that you could do an automation like:

trigger:
  platform: state 
  entity_id: light.led
  to: 'on'
condition:
  condition: template
  value_template: "{{ trigger.from_state.state == 'off' }}"
action:
  service: light.turn_on
  data:
    entity_id: light.led
    kelvin: 4000

but in such case you would screw the posibility of requesting ‘Alexa, turn on light blue’, cause your automation would override the requested color… It will always turn on white

thank you I will give it a try.

Of course if you move the ball park, you have to adjust the automation to your requirements. You asked for an example of an automation that would take the turn on from Alexa and set the light up colour based on whether you were watching a movie, and that’s what I provided. Automations can cater for pretty much any situation you can throw at it, so long as you have the logic behind them.

I wish all my devices updated instantly tbh, it’d be much easier. Thanks for sharing it

1 Like

I don’t think the grouping feature works for all devices that are exposable via homeassistant to Alexa. I have a bunch of fans in my house, 7 to be precise. And I want to have a the “turn on the fan”, “increase the fan” etc working based on the room. When I expose the fan via nabucasa, then add to a group in Alexa with the Echo I have no joy. My fans are named Fan. Alexa refuses to turn on the fan and always asks me to clarify my choice by naming the fan, despite having a Group (named after the room) that only has one Fan and one Echo Dot. So far I can only get it to work for Lights, Temp and AC. turning the Fan into a light via template is not an option as then the fan would be considered a light and be turned on when I say “Alexa turn on the lights”.

So I don’t see any other way for unsupported grouped devices then to go this path.

What am I missing plz? You seem to have everything working…did you turn it all in to emulated lights?

1 Like

Unless mf_social can help you, just create a ‘fan’ device using node-red-contrib-alexa-home-skill with on/off, set%, increase and decrease % properties… It allows setting percentages and increasing percentages which works great in this case. I haven’t been able to make it work the way mf_social suggests either

I didn’t know they upgraded this feature. It’s one of the reasons I’ve been most frustrated with Alexa and her telling me I had the wrong room name. I didn’t think I could do it without saying the exact name. Super cool. Thank you for mentioning this.

1 Like

Yeah, I don’t know why people are struggling with this. We have 3 rooms in our house that have an echo dot in them, and they are room aware and turn devices on and off based on the room they’re in if you don’t specify a room in the command.

I can’t imagine I’m just lucky, the whole point of Alexa groups is to make this happen.

Perhaps it depends on the region. For example, when you ask alexa to add something to the shopping list and it’s duplicated, she’ll tell you something like “You already have that item in your shopping list, do you want to add it again?”, right? It doesn’t do that in Spain

1 Like

Yeah quite possibly, although we always seem to get amazon feature type things last in the UK and this has worked for ages here :man_shrugging:

Please list the types of devices you have in Alexa. Screenhost would be great actually.