Pure fun with Alexa and Alexa Skills

Now the authentication problem with various Alexa nodes has been sorted I thought I'd try something new.
I used BluePrints to create a Q&A skill called 'Give me a status report' then linked that in the flow below.
I've arranged for various devices around my home to report their status to a database that is accessed from the flow and sent to the appropriate Alexa device. Here's an example of capturing feedback from Sonoff-S20 switches and writing the status to a dB.

Screen Shot 06-08-21 at 04.29 PM

The whole thing turned out easier than I thought it would - and works really well.
So now I can say... "Alexa... give me a status report" and guess what she says???

10 Likes

"playing Status Quo"

1 Like

A "6 Echo" houshold. Respect! :slight_smile:

OMG - this is so much fun.
I've expanded my flow so I can hear a report for my home, my infrared sensors or my weather stations.
When I have some spare time I'll write a tutorial on this for my IoT students.
Also made the flow more modular - so hopefully it's easier to understand.

10 Likes

If you preserve the msg.name parameter for device activity then it will automatically respond to the requesting device. In my case I have multiple node-red controllers in my motorhome, so I use MQTT and let the appropriate node-red controller act on the request.

I would really like to see a chat skill where node-red could prompt via Alex for information.

Another quick update and an idea...
I've added a function node to check the core temperature of my Raspberry Pi and if it above a certain value send an alarm message to my Alexa-Speak flow. Works really well.


As I have a cluster of four RPi-4Bs and four RPi-3Bs running 24 * 7, my next idea is for each Pi-server to send a MQTT message to my main server if their CPU temp goes above 'x' degrees.

Like... MQTT topic is... alexaspeak/xxxx/yyyy
Where xxxx is the RPi reference number of the device that is getting "hot".
And yyyy is the name of the alexa device to broadcast the alarm, or the word ALL (for all alexa devices).
Payload is the CPU temperature.

This means I could just have a MQTT-In node on my Alexa-Speak flow that collects any alarms and sends them to my Alexa devices.

2 Likes

A further update on the idea I posted this morning.
I've simplified the MQTT topic to just... "alexaspeak" and put all the details in a json string in the payload.

Here's a screen-shot of the flow that goes in each RPi server to monitor the core's temperature.

Here's what the contents of the function node 'Format JSON string' looks like.
Screen Shot 06-17-21 at 05.56 PM

Here's the tiny flow that goes in my Alexa-Speak flow.
Screen Shot 06-17-21 at 04.53 PM

Here's what the contents of the function node 'System Alarm' looks like.

2 Likes

Hi @dynamicdave,
You mentioned auth problem has been sorted, I am still having problems with the routine speak node as most of the time I have to reinitialise. The funny thing is that it works evey time for the alexa smarthome node with no problems apart from the speak node.
I am using node-red-contrib-alexa-remote2-v2. As you know there are so many forks and variants of alexa-remotes out there now that is getting confusing as which is the best one to use and works with the speak routine. It would be good if someone can definitively clarify this.
btw, what alexa node are you using?
Thanks,
Ken

I'm using... node-red-contrib-alexa-remote-fork
I edited line 797 in the .js file as detailed below, and since then the node has worked really well.

I think most of the alexa nodes have had this 'fix' applied to them. I couldn't be bothered to swap back to the original when this one was working.

I've written a number of flows to send 'verbal reports' to Alexa, that work well.

hey @dynamicdave

I'm still brand new to nodered. I use Home Assistant for my smarthome and have just connected nodered and alexa here. I would like to be able to ask Alexa about entity states. Something like "what is the temperature of the pool" and get a status back from Alexa. Your solution looks very good - did you publish the flow code somewhere? I would like to understand better how you proceeded.

Thanks

Here's the flow for this part.
Screen Shot 06-25-21 at 04.32 PM

[{"id":"bf92bd58.6c46d","type":"comment","z":"95c6d0af.f40018","name":"https://blueprints.amazon.co.uk/","info":"\nhttps://blueprints.amazon.co.uk/","x":170,"y":300,"wires":[]},{"id":"ad741d71.75985","type":"group","z":"95c6d0af.f40018","name":"","style":{"fill":"#e3f3d3","label":true},"nodes":["59079664.dbada","5ff65be9.f845c4","7c27cb0d.57206c","1ff5666d.7d00b2","c7afddd4.224f8","7657022a.50cdfc","455defd6.641d88","53fef701.fcede"],"x":34,"y":19,"w":602,"h":242},{"id":"59079664.dbada","type":"alexa-remote-event","z":"95c6d0af.f40018","g":"ad741d71.75985","name":"","account":"57e78a27.bf542c","event":"ws-device-activity","x":150,"y":140,"wires":[["5ff65be9.f845c4"]]},{"id":"5ff65be9.f845c4","type":"switch","z":"95c6d0af.f40018","g":"ad741d71.75985","name":"Filter on Alexa Response","property":"payload.alexaResponse","propertyType":"msg","rules":[{"t":"cont","v":"Please wait while I check the database","vt":"str"},{"t":"cont","v":"Please wait while I get the figures for you","vt":"str"},{"t":"cont","v":"Please wait while I get the readings for you","vt":"str"},{"t":"cont","v":"Please wait while I check the meter for you","vt":"str"},{"t":"cont","v":"ID is R100","vt":"str"}],"checkall":"false","repair":false,"outputs":5,"x":410,"y":140,"wires":[["7c27cb0d.57206c"],["1ff5666d.7d00b2"],["c7afddd4.224f8"],["455defd6.641d88"],["53fef701.fcede"]]},{"id":"7c27cb0d.57206c","type":"link out","z":"95c6d0af.f40018","g":"ad741d71.75985","name":"Status","links":["4a68d3db.b35d9c","dbe66b7c.4a932"],"x":595,"y":60,"wires":[]},{"id":"1ff5666d.7d00b2","type":"link out","z":"95c6d0af.f40018","g":"ad741d71.75985","name":"Temperature","links":["bbe8f15.018db9"],"x":595,"y":100,"wires":[]},{"id":"c7afddd4.224f8","type":"link out","z":"95c6d0af.f40018","g":"ad741d71.75985","name":"weather","links":["4a4fe3bd.8ce31c","c633acdf.99d5f"],"x":595,"y":140,"wires":[]},{"id":"7657022a.50cdfc","type":"comment","z":"95c6d0af.f40018","g":"ad741d71.75985","name":"Direct to one of the five outputs depending on the Alexa Response","info":"","x":300,"y":60,"wires":[]},{"id":"455defd6.641d88","type":"link out","z":"95c6d0af.f40018","g":"ad741d71.75985","name":"Energy","links":["8dbdbaea.91775"],"x":595,"y":180,"wires":[]},{"id":"53fef701.fcede","type":"link out","z":"95c6d0af.f40018","g":"ad741d71.75985","name":"R100","links":["c2b48076.998258"],"x":595,"y":220,"wires":[]},{"id":"57e78a27.bf542c","type":"alexa-remote-account","name":"Amazon-Alexa","authMethod":"proxy","proxyOwnIp":"192.168.1.152","proxyPort":"3456","cookieFile":"/home/pi/amazon_alexa.txt","refreshInterval":"3","alexaServiceHost":"alexa.amazon.co.uk","amazonPage":"amazon.co.uk","acceptLanguage":"en-UK","userAgent":"","useWsMqtt":"on","autoInit":"off"}]

I suggest you use 'blueprints' to set-up a Q&A skill for your pool.
Some thing like... "Alexa give me a report on my pool".
You'll need to specify a response in 'blueprints' that you can capture in the 'Switch' node.

Let me know once you have got that piece working.

thanks :slight_smile:

ich create 2 Q&A Skills for Battery Status of the Car and the Temperature of my Pool.
I will try it.

How you send the Answer to the correct Alexa Device?

Edit:
Update :slight_smile:

Q&A works.

Alexa answers correctly.

I also built a simple flow:

The Alexa answers are in the Alexa filter.

the two functions are kept simple:

msg.payload =

"The temperature is" +
"{{states.sensor.hottub_temperature.state}}"

return msg

Routine speak is just msg.payload with a fixed echo device.

Unfortunately, I don't get the temperature output; (Alexa says nothing after the Q&A answer.)
Have you a Idea @dynamicdave ?

Have a look at the complete msg.payload from the 'On Device Activity' node and use... msg.payload.name.
In my flow I capture it and place it in msg.destination then use that in my routing flow.
Screen Shot 06-25-21 at 05.32 PM

Hi Dave,

i Try a few more things ...

i think, that the "Filter on Alexa Response" don't work at the moment correctly ;(
no matter what I set there, the options after that are ignored.

if I grab the objects behind a switch after the filter, Alexa starts talking when switching ... (even if she doesn't read the sensor yet but reads it -.-)

So either "on Device Activity" or "Filter on Alexa Response" are currently not working correctly for me ...

My Alexa account is set up correctly .. otherwise Routine Speak would not work.

I just don't know where the error could be; (

  1. Have you tried just sending a simple msg.payload to the 'alexa-remote-routine' node ??
    You need to get that working before trying to do anything else.

Screen Shot 06-25-21 at 07.39 PM

[{"id":"240b5d28.740d1a","type":"alexa-remote-routine","z":"3c310437.4aee8c","name":"","account":"57e78a27.bf542c","routineNode":{"type":"speak","payload":{"type":"announcement","text":{"type":"msg","value":"payload"},"devices":["G0014C0600360JR2"]}},"x":1240,"y":320,"wires":[[]]},{"id":"5c218cdb.4326cc","type":"inject","z":"3c310437.4aee8c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello in the kitchen <break time='0.25s'/> hope you are having a nice day","payloadType":"str","x":990,"y":320,"wires":[["240b5d28.740d1a"]]},{"id":"57e78a27.bf542c","type":"alexa-remote-account","name":"Amazon-Alexa","authMethod":"proxy","proxyOwnIp":"192.168.1.152","proxyPort":"3456","cookieFile":"/home/pi/amazon_alexa.txt","refreshInterval":"3","alexaServiceHost":"alexa.amazon.co.uk","amazonPage":"amazon.co.uk","acceptLanguage":"en-UK","userAgent":"","useWsMqtt":"on","autoInit":"off"}]

You will need to change the credentials to match your set-up.

  1. Can you post your flow and I'll take a look at it for you??

  2. Another thing you can do is insert 'debug' nodes in your flow so you can see what is happening.

Hi Dave,

yes - inject with routine Speak works: (also with yours)
image

here is my flow:

[{"id":"f97b033.bcc97","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"ad741d71.75985","type":"group","z":"f97b033.bcc97","name":"","style":{"fill":"#e3f3d3","label":true},"nodes":["59079664.dbada","5ff65be9.f845c4","7657022a.50cdfc","264f785d.fcf8c8"],"x":214,"y":239,"w":532,"h":182},{"id":"bf92bd58.6c46d","type":"comment","z":"f97b033.bcc97","name":"https://blueprints.amazon.co.uk/","info":"\nhttps://blueprints.amazon.co.uk/","x":350,"y":520,"wires":[]},{"id":"59079664.dbada","type":"alexa-remote-event","z":"f97b033.bcc97","g":"ad741d71.75985","name":"","account":"27b37742.597478","event":"ws-device-activity","x":330,"y":360,"wires":[["5ff65be9.f845c4","264f785d.fcf8c8"]]},{"id":"5ff65be9.f845c4","type":"switch","z":"f97b033.bcc97","g":"ad741d71.75985","name":"Filter on Alexa Response","property":"payload.alexaResponse","propertyType":"msg","rules":[{"t":"cont","v":"Ladestand vom Auto","vt":"str"},{"t":"cont","v":"Temperatur vom Pool","vt":"str"}],"checkall":"false","repair":false,"outputs":2,"x":590,"y":340,"wires":[["42493568.6841dc","49025047.2e434"],["acf385e2.5bf4f8"]]},{"id":"7657022a.50cdfc","type":"comment","z":"f97b033.bcc97","g":"ad741d71.75985","name":"Direct to one of the five outputs depending on the Alexa Response","info":"","x":480,"y":280,"wires":[]},{"id":"acf385e2.5bf4f8","type":"alexa-remote-routine","z":"f97b033.bcc97","name":"","account":"27b37742.597478","routineNode":{"type":"speak","payload":{"type":"regular","text":{"type":"str","value":"Hallo"},"devices":["G091AA0811370CU0"]}},"x":880,"y":380,"wires":[[]]},{"id":"bf7ed97e.b73438","type":"function","z":"f97b033.bcc97","name":"Akkuladestand","func":"msg.payload =\n\n\"Der Akkuladestand vom e Up ist: \"+\n\"{{states.sensor.eup_battery_level.state}}\"+ \", \" +\n\n\"% \"\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1100,"y":300,"wires":[["3723a59.338795a"]]},{"id":"42493568.6841dc","type":"change","z":"f97b033.bcc97","name":"","rules":[{"t":"set","p":"destination","pt":"msg","to":"payload.name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":300,"wires":[["bf7ed97e.b73438"]]},{"id":"3723a59.338795a","type":"alexa-remote-routine","z":"f97b033.bcc97","name":"","account":"27b37742.597478","routineNode":{"type":"speak","payload":{"type":"regular","text":{"type":"msg","value":"payload"},"devices":{"type":"msg","value":"payload.name"}}},"x":1280,"y":300,"wires":[[]]},{"id":"49025047.2e434","type":"alexa-remote-routine","z":"f97b033.bcc97","name":"","account":"27b37742.597478","routineNode":{"type":"speak","payload":{"type":"regular","text":{"type":"str","value":"Hello World"},"devices":["G091AA0811370CU0"]}},"x":880,"y":220,"wires":[[]]},{"id":"264f785d.fcf8c8","type":"debug","z":"f97b033.bcc97","g":"ad741d71.75985","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":550,"y":380,"wires":[]},{"id":"dd3088e9.c7f918","type":"inject","z":"f97b033.bcc97","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":310,"y":640,"wires":[["8d0fc34c.c1965"]]},{"id":"8d0fc34c.c1965","type":"alexa-remote-routine","z":"f97b033.bcc97","name":"","account":"27b37742.597478","routineNode":{"type":"speak","payload":{"type":"regular","text":{"type":"str","value":"Hello"},"devices":["G091AA0811370CU0"]}},"x":540,"y":640,"wires":[[]]},{"id":"27b37742.597478","type":"alexa-remote-account","name":"Andre-Alexa","authMethod":"proxy","proxyOwnIp":"192.168.178.37","proxyPort":"3456","cookieFile":"authFile","refreshInterval":"3","alexaServiceHost":"layla.amazon.de","amazonPage":"amazon.de","acceptLanguage":"de-DE","userAgent":"","useWsMqtt":"on","autoInit":"on"}]

I Add a Debug node to the On Device Activity - here comes nothing ...

sry the Alexa Filter is with German Words ..
the Alexa Answers are:

  • einen Moment, ich prüfe den Ladestand vom Auto
  • einen Moment, ich prüfe die Temperatur vom Pool

so I wanted to check the answer for the last 3 words "Ladestand vom Auto" and "Temperatur vom Pool"

This section of your flow will probably create an error. I would delete it.
Screen Shot 06-25-21 at 10.20 PM
Can you post the contents of the debug node.

You could also try putting the whole of the response string in the Switch node.
Also put a debug node on the two outputs of the Switch node and see what comes out of there.

Hi Dave,

i think my "On Device Activity" is the Problem ...

i try this:
image

When I press the button, my Alexa says: "Hello in the kitchen [pause] hope you are having a nice day"

but nothing arrives in the debug of the On Device Activity.

When I connect the Debug Nodes with Routine Speak, I get the text displayed in the Debug ...

I think my "on device activity" is not receiving any information from Alexa.
Do I have to accept / activate something somewhere so that the whole thing works or do you have another idea?

Have you got an alexa-remote-init node somewhere in your flow, even on another flow?
I assumed you did as the alexa-remote-event node labelled On Device Activity looks as if it is listening.

If you say... "Alexa, what's my name"
The grey dot should change colour to green and the text "event fired" should briefly appear.
Also the debug node should show something like this.
Screen Shot 06-26-21 at 04.44 AM
Can you confirm if that happens?

Now it's working ...
I deinstalled the Alexa package, restart nodered and reinstalled the packet ... imported the same flow again - now it works.

I get the Alexa answers via "On Device Activity" and also the switch with "Charge level from the car" / "Temperature from the pool"

Two things don't work yet:
in my function:
image
Alexa says "state.sensor ...." and not the content of the sensor - such as 80%

  • It does not yet work that Alexa answers on the device on which I asked the question:
    image
    image

I have marked both problems in the flow: