Node Red Room aware Alexa voice commands

This is an example with lights. This way you will just have to say ‘Turn the light on’ (or whichever sentence Alexa understands to turn a light on) and the appropriate light will turn on depending on the area you are in. That applies to any device: fans, tvs, curtains, ‘the mirror’ and so on… just one word for them all and no need to create a dozen routines to cover all kinds of requests.

you will need: node-red-contrib-alexa-remote2

First section, ‘Setting currently listening device’:

https://paste.ubuntu.com/p/CJKb6pNWpX/

You need to create an input_boolean

First node listens to Alexa’s events, acknowledges which device you’re talking to and sets a flow.echodevice containing the name of the listening device (the name of your device is stored as it shows up in your Alexa up, case sensitive). You needn’t change anything in the nodes without a label, leave them as they are. In fact you only need to add your account details in the first node and set an input boolean of your choice in the two blue “Input X” nodes. Don’t worry about having several devices listening nearby, the flow picks up the right device.

Alexa Event node config:

In fact, if you already have some way of creating devices in Alexa, this is all you need, you can skip the section below. Use ‘flow.echodevice’ as a condition to group your devices and actions by rooms. If you go this route, don’t forget to add the two input nodes (a ‘wait until input is on’ with timeout, and an ‘input turn off’) from the second section right after every device node, it acts as a switch to ensure the flow is picking up the right room and triggering when it should.

However the Alexa Home node recommended here is really flexible and, even though it relies on the cloud, it’s powerfull enough to emulate the majority of devices and their use cases.

Second section, ‘Turn light on according to which device listened’:

https://paste.ubuntu.com/p/QmwJhYDFD8/

You will need: node-red-contrib-alexa-home-skill

Again, fill the two blue “Input X” nodes with your input_boolean.

You have to create an account and an alexa device called ‘Light’ or ‘The light’ or both (it’s alwats better to create both to increase compatibility) in: https://alexa-node-red.bm.hardill.me.uk/docs

after creating the device ‘Light’, go to your Alexa app and install the Node Red Skill, which will allow Alexa to discover the device ‘Light’

Once discovered, you must read the documentation to understand how to make requests. It allows turning on/off, changing color and white temperature, increasing and setting brightness percentages.

Alexa home node config:

In the node ‘Echo Device’, you must set the name of your devices as they show in your Alexa app, case sensitive.

for the Action Node, read the documentation

---------------------------------------------------------- UPDATE ------------------------------------------------------------------

EXAMPLE WITH FANS.

---------------------------------------------------------- UPDATE ------------------------------------------------------------------

EXAMPLE WITH THERMOSTAT.

This is just what I’m looking for! Unfortunately I know nothing about Node-Red but this project is giving the motivation to dive in. I have a couple quick questions, I have several bedrooms with a ceiling fan that I currently have routines setup for in Alexa. Unfortunately it doesn’t pass the “Guest Test” when someone comes over and just says: Alexa, turn the fan on. Your solution would allow me to create identical flows and turn on the appropriate devices based on the room/alexa they are talking to. I tried creating groups in the Alexa app but I’ve never been able to get them functioning the way I hoped.

You mention that an input_boolean needs to be created. Do I need a separate boolean for every flow?

I know I’ll have a lot more questions over the next couple days as I attempt to get this working and dabble in Node-Red. Thanks again!

Does this not replicate the Alexa app grouping features (turn on lights turns on lights for the group that device is in?)

Some say it does, some others say it doesn’t. For lights it does work, but not for every device… What if you want to say “Alexa, turn off the room”?, being “the room” the one where you’re in at that moment. Or what if you had a broadlink in every room with a tv and would like to be able to say, “Alexa, turn on Eurosport”, expecting the appropriate Broadlink to act?

For lights it does work, however, if you manage to get it to work with, for example, fans, please post it because several people are after this feature.

1 Like

Just dive in Node Red, you won’t regret it. Not only for this, you’ll very likely end up moving several of your automations to Node Red, and it is begginers proof. Ask as much as you like, I’ll help if I can, no problem with that.

You’ll need just one input boolean for them all, repeat the same pattern right after every device (wait until + turn off)

1 Like

I copied from this thread to create room aware alexa commands
https://community.home-assistant.io/t/approaches-to-room-aware-voice-commands-for-alexa-with-node-red/165399

His example is for fans. I use it for lights, but no reason it won’t work for fans.
I’ll take a look at this logic when I’m at home tonight, curious how it works and what the differences are.

@randytsuch that’s a beautiful approach. By looking at it I believe the results might be very similar. He creates a device Fan to avoid Alexa complaining about not finding such device and analyzes the summary with regex filters. Thanks for sharing.

His device ‘Fan’ doesn’t depend on the cloud, which is great. Mine is apparently more compact, and I’m not sure how regex works so I can’t really tell whether the available request sentences you can use are more flexible in my flow or equally flexible.

Ok well that didn’t take long…I have the flow deployed and listening is working, but the Alexa Home node shows disconnected. I tried putting my Alexa login and password in the account but that didn’t seem to work? What am I missing

cap2

Try restarting Node Red under Supervisor/Dashboard/Node-Red/restart.

If it still isn’t working… have you followed the instructions here?:

https://alexa-node-red.bm.hardill.me.uk/docs

try following everything from the beginning step by step. That shouldn’t be too difficult, perhaps you missed something

This is correct and to add to this click the pencil icon on the wrong Alexa Account and then “Delete” so you clean it up and remove it

Bah. This requires you to sign up for an account with a third party website.

check out that one, you might like it more

Surely there is a reason you are using this third party service? Similarly, perhaps you know why is it required that if I do not use the Alexa Other node and use other builtin HA nodes I need to clear the payload so as to not create API errors (e.g. extra keys in ‘data’ - ‘_disambiguationId’)?

I use it because it has great flexibility with the sentences you can use to make requests and when you send a, for example, set% request it creates an entirely different message than when you make a turn on request, so it’s really easy to work with. Other nodes when you send a “turn on” command with Alexa, they send the turn on attribute plus all the color, percentage, etc… attributes from the last state, which makes it more difficult to work with. One clear example is the Room Aware setup from the guy from post above. He was aware of this issue so he ended up regexing everything in order to achieve this goal, and I believe that even that way, it’s not as flexible as the Alexa Home node.

I dunno why you are reluctant to use a third party integration, all I can say about this one is that I’ve been using it for a year now and it’s been down maybe a few hours a couple of times during this period. No big deal.

Regarding the API error, I don’t know why it happens, but as you said, deleting the payload solves the issue. That ‘_disambiguationId’ is located in the original message, perhaps you could solve it by just deleting that attribute and not the entire payload

I’m not against it so much as trying to understand the compelling reasons away from trying to stay as natively as possible - also sending my requests to another 3rd party like you said is a dependency but also raises some privacy concerns a bit although I’m a pretty boring person to look in on :wink:

heheheee… checking out zkniebel approach you can read what happens from the section "Overall Cons:" in his thread and down. They’ve been tinkering to get it to work. That one’s Cons is this one’s Pros and the other way around too…

Me pretty boring too :smiley:

Ok, I think I’ve made some progress on getting the initial setup completed on my system. I’ve created an account and device on the Alexa Home Skill Bridge website and linked them in the flow…I’m still a bit confused where I tell this script which entity (light) I’m referring to when prompted to: “Alexa, turn off the lights”. I see placeholders for entity_id in the four yellow “Edit change nodes” and the five “Edit Service Call nodes”. Do I need to add a specific entity to each of those or just one set or the other?

I used the cloud based hardill node-red-contrib-alexa-home-skill pallette for many years, it works fine. In fact I still have a few flows with it.

A few months ago, I moved most of my alexa voice command flows to node-red-contrib-amazon-echo.

Amazon-echo is local, so I get a faster response from it, where home-skill might have a few second longer delay.

I’m pretty sure anything you can do with one, you can do with the other. With amazon-echo you make a node with the device word/phrase you want to use, you don’t need to define it at a website, so one less step.

The disadvantage for me was I could never get amazon-echo to run from my NR pi3 correctly. I had to install NR on a PC I have running 24/7. From the PC, it works fine. Means I have 2 instances of NR running. I use MQTT when I need to send something from one to the other.

I looked at this a little last night, but need some more time to understand it.

BTW, if you haven’t used node-red-contrib-alexa-home-skill pallette before, it might be easier to get that working first, to a point where you can say “Alexa turn on kitchen light” and it turns on your light.
Then implement this flow to make it room aware.

Randy

@randytsuch advice is not bad, but if you want to get it to work first and get to understand it later, take a look at this little example. To get this one particular flow to work you need to do the following. Imagine you have in your house just an “Echo Studio” and an “Echo Dot”, so you should modify the “Echo Device?” node as in the picture (remember to put the name of your devices exactly as they show in your Alexa app, case sensitive). You can add more lines if you have more Echo Devices by clicking ‘add’ in the bottom left or you can delete lines by clicking the ‘x’ button from every line. Put the name, not the model. If you have called your Echo Studio “Living room speaker”, put “Living room speaker” in the “Echo Device?” node:

Now, going to the second step, you should accomplish this:


I put two titles (“Echo Dot devices” and “Echo Studio devices”) so it is more visual for you, but that is irrelevant, you only need to worry about filling the nodes properly. Add all light devices that are in the same room as every of your echoes. You can either set a group in HA and put the group, you can put a comma separated string of entities, like in the picture above, or, if it’s just one light, put that single entity right there. Don’t change anything else, just put your echo devices and the lights related to each device. If you create a group or make any change in your config files, don’t forget to restart Node Red.

1 Like

@obaldius Thank you! This is VERY helpful. I will tinker with it more tonight when I get home and keep you posted. Much appreciated!