Approaches to room aware voice commands for Alexa with Node-Red

Tags: #<Tag:0x00007f328a576408> #<Tag:0x00007f328a5762a0>

I found a way to get this working with the sentences: “Set the fan to high”, “Set fan to level medium”, “turn on fan to low”, “Turn fan to 1”, “set the fan to 2”, “Turn fan to level 3”, “Turn fan on to level 2”, “turn the fan on to 1”, “Put fan at 3” etc etc etc… 1 low, 2 medium, 3 high. It should also allow saying set to minimun, maximum, middle, low, medium, high, 1, 2, 3, spelling level or not… pretty flexible I believe, let me know please, I can’t test it out in english.

Alexa won’t complain, at least in Spanish, and you can set colours, white temperatures, increse/drecrease and set%'s of brightness/speed and turn on/off of course

Catch the first section from here:


Get the Fan example from here:

FWIW, this ability was described several posts ago. A function node converts text to numbers. For example, the ‘twenty-five’ in the command ‘Set light to twenty five’ is converted to 25. It uses a map so it’s trivial to add other phrases like high, medium, low or pretty much anything like super bright, extra dim, night time, etc.

Within the received phrase, Alexa reports the brightness level using words , not numbers. The first function node (“Parse”) converts the words to numbers (because the command to set a light’s level requires a numeric value). The conversion is performed using a map. It’s possible to enhance the map by adding words like “low”, “medium”, and “high”, or even “night time”, with corresponding numeric values. Otherwise, there’s no need for the end-user to change anything within the first function node.

oh ok sorry, every time I come across a function node I just don’t read it :smiley:

and when you say, set the light night time, doesn’t alexa complain? Isn’t there any situation where alexa complains?

Been playing around with this flow as well as another one in hope of creating a room aware echo setup…While setting this up I ran into a snag while trying to set my Fan percentage levels in their respective nodes. I use a Homeseer FC200+ switch and although the Alexa app shows the 4 stages of power levels:
off
1
2
3
NR won’t let me add a percentage?! Any thoughts?

https://imgur.com/a/yoV08pB is how I approach it. I also have two Alexa accounts combined, but because they share the same household, it ends up in duplicate messages, unless you use something like dropping a message.

[{"id":"7d72b9e8.14de78","type":"tab","label":"Drop Message","disabled":false,"info":""},{"id":"f073080b.a7cae","type":"change","z":"7d72b9e8.14de78","name":"Strip Wake Word","rules":[{"t":"change","p":"payload.description.summary","pt":"msg","from":"^(alexa )?","fromt":"re","to":"","tot":"str"},{"t":"change","p":"payload.description.summary","pt":"msg","from":"^(amazon )?","fromt":"str","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":945,"y":199,"wires":[[]]},{"id":"7cde2905.64fb2","type":"delay","z":"7d72b9e8.14de78","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":745,"y":139,"wires":[["f073080b.a7cae"]]},{"id":"940bae50.427d4","type":"switch","z":"7d72b9e8.14de78","name":"Alexa hears","property":"payload.description.summary","propertyType":"msg","rules":[{"t":"regex","v":"alexa|amazon","vt":"str","case":true},{"t":"regex","v":"^(?:(?!amazon|alexa).)+$","vt":"str","case":true}],"checkall":"false","repair":false,"outputs":2,"x":525,"y":179,"wires":[["7cde2905.64fb2"],["9d206b72.b9ddd"]],"outputLabels":["Turn on",""]},{"id":"9d206b72.b9ddd","type":"delay","z":"7d72b9e8.14de78","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":745,"y":239,"wires":[["f073080b.a7cae"]]}]

Regarding this, have you tried creating two HUE devices called “Fan to medium” and “Fan on medium”? I believe Alexa would take care of the rest… articles or not, whichever verb… As you said, even one device called “Fan medium” would do it. It might work, I can’t test it out though

As I said here: Approaches to room aware voice commands for Alexa with Node-Red if you use a different skill to emulate the fan properly, you don’t need to mess around with fake routines to avoid the error messages.

1 Like

Didn’t read that, sorry

1 Like

I have a similar reaction when I see a flow with many duplicated nodes.

The reason I used function nodes is because it allows me to do more with less. Those five nodes handle 8 devices (4 lights and 4 fans) in 4 rooms. It supports brightness commands as well as custom phrases and can easily handle more devices.

Without question, Alexa will complain if the phrase contains words it doesn’t support. For example, ‘Set light to medium’ isn’t understood and will result in a reply along the lines of “I don’t know how to do that.”

The solution is explained in the first post:

I have created a routine that responds “OK” when it hears the phrase “Set light to medium”. In addition, I added a key to the dictionary in the Parse node to identify medium as a value of 50:

Screenshot from 2021-01-22 08-52-26

That’s all there is to it. Now when I say “Alexa, set light to medium”, in any of the 4 rooms, Alexa responds “OK” and the light in that room is set to 50% brightness.

1 Like

Yeah, don’t get me wrong, I don’t read function nodes because I don’t still understand them. Hopefully someday I’ll be able to use them. Good job you all did here.