Pure fun with Alexa and Alexa Skills

I think something is wrong with the path for the variable "state.sensor........"

Try removing that and use a simple TEXT only message and see if that works.

Oops - just noticed, your 'Devices' entry is incorrect. It should be the name of your Alexa, like this...
Screen Shot 06-26-21 at 08.56 AM
I've not tried doing it the way you have it set in YOUR screen-shot.

EDIT: I've just tried selecting a device using 'msg.payload.name' and that seems to work.

Here's a flow that collects the details of your Raspberry Pi and sends that to Alexa.

You will need to create a Q&A Skill. "Alexa... Give me a report on my Raspberry Pi"

[{"id":"1d132390.ad4104","type":"group","z":"95c6d0af.f40018","name":"","style":{"fill":"#e3f3d3","label":true},"nodes":["c2b48076.998258","8f2ab094.0a94f8","e0ac0a53.86ac68","93791eb3.c6e3","bd72bd8c.27897","ccfb66f0.88068","b77344d2.d6439","328022db.63141e","10bd6506.54d153","5cf3daba.be39e4","cc61ba3e.287248","fd25ffe9.ce945","efaafaeb.bfe86","758b14dc.609fdc"],"x":1794,"y":559,"w":732,"h":322},{"id":"c2b48076.998258","type":"link in","z":"95c6d0af.f40018","g":"1d132390.ad4104","name":"R100_IN","links":["53fef701.fcede"],"x":1855,"y":840,"wires":[["bd72bd8c.27897"]]},{"id":"8f2ab094.0a94f8","type":"inject","z":"95c6d0af.f40018","g":"1d132390.ad4104","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"3","topic":"","payload":"1","payloadType":"num","x":1910,"y":660,"wires":[["e0ac0a53.86ac68","328022db.63141e"]]},{"id":"e0ac0a53.86ac68","type":"exec","z":"95c6d0af.f40018","g":"1d132390.ad4104","command":"hostname","addpay":"","append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":2060,"y":660,"wires":[["93791eb3.c6e3"],[],[]]},{"id":"93791eb3.c6e3","type":"change","z":"95c6d0af.f40018","g":"1d132390.ad4104","name":"Capture Hostname","rules":[{"t":"move","p":"payload","pt":"msg","to":"hostname","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":2270,"y":640,"wires":[[]]},{"id":"bd72bd8c.27897","type":"change","z":"95c6d0af.f40018","g":"1d132390.ad4104","name":"","rules":[{"t":"set","p":"destination","pt":"msg","to":"payload.name","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2010,"y":840,"wires":[["ccfb66f0.88068"]]},{"id":"ccfb66f0.88068","type":"function","z":"95c6d0af.f40018","g":"1d132390.ad4104","name":"Format response","func":"var hostname = flow.get(\"hostname\");\nvar ip_address = flow.get(\"ip_address\");\nvar cpu_temperature = flow.get(\"cpu_temperature\");\n\nvar message = \"<break time='0.25s'/> Here's your report on your raspberry pie<break time='0.5s'/>\";\n    \nmessage += \"hostname is <break time='0.1s'/>\"+hostname+ \"<break time='0.25s'/>\";\nmessage += \"IP address is <break time='0.1s'/>\"+ip_address+ \"<break time='0.25s'/>\";\nmessage += \"CPU core temperature is <break time='0.1s'/>\"+cpu_temperature+ \"degrees sea <break time='0.25s'/>\";\n\n// This the footer for the message\nmessage += \"<break time='0.75s'/> that's the end of the report\";\n\nmsg.payload = message;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2250,"y":840,"wires":[["b77344d2.d6439"]]},{"id":"b77344d2.d6439","type":"link out","z":"95c6d0af.f40018","g":"1d132390.ad4104","name":"R100_OUT","links":["8995fe0c.77fac8"],"x":2395,"y":840,"wires":[]},{"id":"328022db.63141e","type":"ip","z":"95c6d0af.f40018","g":"1d132390.ad4104","name":"ip","https":false,"timeout":"5000","internalIPv4":true,"internalIPv6":false,"publicIPv4":false,"publicIPv6":false,"x":2050,"y":720,"wires":[["10bd6506.54d153"]]},{"id":"10bd6506.54d153","type":"change","z":"95c6d0af.f40018","g":"1d132390.ad4104","name":"Capture IP address","rules":[{"t":"move","p":"payload.internalIPv4","pt":"msg","to":"ip_address","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":2270,"y":720,"wires":[[]]},{"id":"5cf3daba.be39e4","type":"comment","z":"95c6d0af.f40018","g":"1d132390.ad4104","name":"Alexa... Give me a report on my Raspberry Pi","info":"","x":1990,"y":600,"wires":[]},{"id":"cc61ba3e.287248","type":"inject","z":"95c6d0af.f40018","g":"1d132390.ad4104","name":"","props":[{"p":"payload"}],"repeat":"60","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":1910,"y":780,"wires":[["fd25ffe9.ce945"]]},{"id":"fd25ffe9.ce945","type":"exec","z":"95c6d0af.f40018","g":"1d132390.ad4104","command":"vcgencmd","addpay":false,"append":"measure_temp","useSpawn":"false","timer":"","oldrc":false,"name":"CPU temp","x":2060,"y":780,"wires":[["efaafaeb.bfe86"],[],[]]},{"id":"efaafaeb.bfe86","type":"function","z":"95c6d0af.f40018","g":"1d132390.ad4104","name":"","func":"let parts = msg.payload.split(\"'C\");\nlet temp = parts[0].split(\"=\");\n\nmsg.payload = temp[1];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2240,"y":760,"wires":[["758b14dc.609fdc"]]},{"id":"758b14dc.609fdc","type":"change","z":"95c6d0af.f40018","g":"1d132390.ad4104","name":"Capture CPU temp","rules":[{"t":"move","p":"payload","pt":"msg","to":"cpu_temperature","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":2410,"y":760,"wires":[[]]}]

I'll write this up as a step-by-step Tutorial Guide (for my IoT students) when I have some spare time.

Now it's working correctly :slight_smile: :smiling_face_with_three_hearts:

I'm sure there is an easier way ... but it works for now :slight_smile:

Any ideas on why I'm not getting any output when I give any command to Alexa?

[{"id":"4fe273a0.9cc69c","type":"alexa-remote-event","z":"b79c527b.0a36e","name":"","account":"e80c1f74.2a7fd","event":"ws-device-activity","x":330,"y":256,"wires":[["c5d535f0.bad588"]]},{"id":"c5d535f0.bad588","type":"debug","z":"b79c527b.0a36e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":576,"y":256,"wires":[]},{"id":"e80c1f74.2a7fd","type":"alexa-remote-account","name":"Echo","authMethod":"proxy","proxyOwnIp":"10.10.1.27","proxyPort":"3456","cookieFile":"/data/cookie.txt","refreshInterval":"3","alexaServiceHost":"alexa.amazon.co.uk","amazonPage":"amazon.co.uk","acceptLanguage":"en-UK","userAgent":"","useWsMqtt":"on","autoInit":"on"}]

I think the setup is correct as this flow gets her to speak the message written in the inject node.

image

I've never had much luck with Echo's and Nodered, but the node does seem more stable now (It was constantly asking for reauthorisation).
Thanks

Hey Dougle,

i have yesterday the same problem ...
I deinstalled all Alexa Packages in NodeRed. (Before I Save my Flows and Delete them)
Than I restarted Node Red.
I Installed fresh Alexa Package: node-red-contrib-alexa-remote2-applestrudel
(I'm not sure if i have before the same package or another remote2 ...)

Then i import my Flows and the Listenig on Device Activity still works ...

1 Like

I've found the 'alexa-remote-event' node labelled as 'On Device Activity' can be used to capture the questions you give to Alexa. This means you could use this flow as the basis to decode and react to YOUR questions (and have a lot of "fun" along the way).

Here's a very simple flow if anyone wants to try it out.
Screen Shot 06-27-21 at 01.10 PM
Screen Shot 06-27-21 at 01.11 PM

[{"id":"59079664.dbada","type":"alexa-remote-event","z":"95c6d0af.f40018","name":"","account":"57e78a27.bf542c","event":"ws-device-activity","x":130,"y":280,"wires":[["5ff65be9.f845c4","2c68ef53.23d3f8","8a9936f2.1e3748"]]},{"id":"1e9a427a.1f34be","type":"debug","z":"95c6d0af.f40018","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":550,"y":280,"wires":[]},{"id":"2c68ef53.23d3f8","type":"function","z":"95c6d0af.f40018","name":"Capture question","func":"var device_name = msg.payload.name;\nvar summary = msg.payload.description.summary;\n\n if ((summary != \"alexa\") && (summary != \"\")) {\n     \n    msg.payload = {};\n\n    msg = {\n        topic: \"Alexa_response\",\n        device_name: device_name,\n        payload: {\n            \"summary\": summary\n        }\n}\n    node.status({text:\"Device_name is \"+ device_name + \" Summary = \" + summary});\n    return msg;\n}\nelse {\n    return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":280,"wires":[["1e9a427a.1f34be"]]},{"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've tried it with some simple questions and it seems to work really well.
Screen Shot 06-27-21 at 01.17 PM

2 Likes

How about the rest of us? Beta test the tutorial here, please.

Well spotted Steve. I meant to say I'll published it on 'Share your projects' as that's what I usually do.

Can you please message me when it's online? Thanks

1 Like

Hallo, ich habe das hier alles versucht, aber es gelingt nicht. Ich verwende Home Assistant, also keinen "richtigen IO-Broker"...
Ich habe auch den NodeRed-Skill versicht, nichts funktioniert....
Ich habe per MQTT Sensoren und Schalter, aber habe keine Ahnung, wie ich diese mit Alexa verbinden soll?
Bitte um Hilfe!
Danke

Willkommen ins Forum.
Du wirdst viel mehr Antworten bekommen wenn du Englisch verwenden wuerdest.

Es gibts einige Beispiele hier im Forum, versuche es mit dem "Search" Werkzeug oben rechts.

1 Like

Hallo,
ich glaube das Ganze scheitert bei mir eben wegen "Google-Trans".......
Nööööööööö, das mit Englisch funktioniert zu 100% nicht....

Ich habe Win auf DE und auch alle meine andere Geräte, und selbst wenn ich etwas im Menü suchen sollte, finde ich dann nicht mehr.....

Habe unzählige Einträge gelesen, aber ich glaube, das Problem liegt schon am Anfang...... In NodeRed gibt es viele Installationsvarianten bezw. Amazon.... Egal ist es jedoch nicht, welche man installiert...... (Alexa, oder Amazon)
Ich habe auch Konto bei NodeRed wegen Skill, alles zwar eingerichtet, (Weboberfläche) auch im NodeRed taucht es auf, ("Alexa-home") aber die per MQTT im Home Assistant befindliche Werte/Daten werden an Alexa nicht weitergegeben (zu mal weiß ich nicht mal so genau, was ich alles verbinden soll)

Aber du kannst Englisch lesen oder?

nööööööööööööööööööööööö

ich habe nie englisch gelernt (bin eigentlich Ungarin, aber Deutsch kann ich mittelweile besser, als Ungarisch)

Schwierig, Ich habe leider kein Zeit dir zu helfen, aber es gibt andere Deutsch sprechender hier im Forum.

Danke für die Mühe...... Ich sehe jedoch alles in Deutsch, auch wenn es aus Englisch stammt.......
Es gibt eine Funktion "import"....
Die Flow´s; welche ich fand, waren leider nicht für Home-Assistant geeignet, sondern sonstige Pi-Installation, deshalb konnte ich mit denen nichts anfangen....

In der Suche (rechts oben) habe auch schon einige Male die Suche probiert, aber wahrscheinlich hat es mit Übersetzung zu tun, "nichts gefunden".....
Alexa ist ja nicht glein Alexa....... (also in NodeRed nicht) ist nicht egal, ob es mit Skill, oder ohne bearbeitet wird (mir ist zwar egal, hauptsache, es funktioniert)

Die Beschreibung von "Alexa-home" ist auch ziemlich knapp......

Was muss zu dem Knote verbunden werden??? MQTT in? oder MQTT out? oder gleich ein "msg.payload"?

Thank you for the inspiration to do something similar. :+1:

I created an Alexa Q&A Blueprint to respond to questions like:

Tell me about the garage.
Tell me about kitchen.

The blueprint simply responds with the room's name which is received by the Device Activity node.

The flow confirms the payload is one of the monitored rooms and then repackages some of the received information (source echo and target room) and passes it as JSON to a Home Assistant script.

The script is responsible for all of the data massaging (because it has access to the states of various entities in the desired room) and cranks out an announcement suitable for TTS.

The script published the TTS message and is received by a Routine Node which directs it to the originating echo.

Here's a sample announcement for "Tell me about garage" if the garage is occupied, a light is on, and doors are open and/or unlocked.

Garage (pause) is occupied. Temperature is 19 degrees. Garage light is on. Entry door is unlocked. Entry and garage doors are open.

If the garage is unoccupied and everything is locked/closed/off it simply replies with the temperature.

Hi, I'm trying to get Alexa to respond only to the requesting device, and I'm putting msg.name, but it gives me an error.

I have seen that David @dynamicdave has also achieved it (Publication 21 of this post) (Pure fun with Alexa and Alexa Skills - #21 by dynamicdave)

Me, I can't. I always make the request in one and it answers me in all the devices.

Can you please help me??

Thank you.

(I upload the Json, because the text block cannot be uploaded. (I'm going to try to upload it in text, in case it works like that))

flows.json (5.6 KB)

[{"id":"5d5dcf8fde0931dc","type":"debug","z":"a2037a02d7c8a9f4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":710,"y":2160,"wires":[]},{"id":"975e96c65785e0d1","type":"api-current-state","z":"a2037a02d7c8a9f4","name":"Temperatura ACS","server":"e810789.76b1f88","version":3,"outputs":1,"halt_if":"","halt_if_type":"num","halt_if_compare":"is","entity_id":"sensor.ecodan_geranios_tank_temperature","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":490,"y":2220,"wires":[["5d5dcf8fde0931dc","6b8137f03f664cc0"]],"icon":"font-awesome/fa-sun-o"},{"id":"80ffa811b4e15710","type":"switch","z":"a2037a02d7c8a9f4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":345,"y":2260,"wires":[["975e96c65785e0d1"],["a92064ce76696fb5","34022b1944a6b9e7"]],"l":false},{"id":"6b8137f03f664cc0","type":"template","z":"a2037a02d7c8a9f4","name":"Mensaje","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"La temperatura del agua caliente es {{payload}} grados","output":"str","x":700,"y":2220,"wires":[["832e2dab12f82e22"]],"icon":"font-awesome/fa-sticky-note"},{"id":"34022b1944a6b9e7","type":"template","z":"a2037a02d7c8a9f4","name":"Mensaje","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Vale, te caliento el agua.\n\n\n","output":"str","x":540,"y":2440,"wires":[["6316f01b59970fd0"]],"icon":"font-awesome/fa-sticky-note"},{"id":"a92064ce76696fb5","type":"delay","z":"a2037a02d7c8a9f4","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"45","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":true,"outputs":1,"x":540,"y":2360,"wires":[["fe28aa5631e6b69a"]]},{"id":"0386fa43f7f1806f","type":"delay","z":"a2037a02d7c8a9f4","name":"","pauseType":"delay","timeout":"75","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":940,"y":2360,"wires":[["9ce94a39293a4f7b"]]},{"id":"fe28aa5631e6b69a","type":"api-call-service","z":"a2037a02d7c8a9f4","name":"Recircula ACS ON","server":"e810789.76b1f88","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_on","entityId":"switch.switch_acs_sala_de_maquinas_l2","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":750,"y":2360,"wires":[["0386fa43f7f1806f"]]},{"id":"9ce94a39293a4f7b","type":"api-call-service","z":"a2037a02d7c8a9f4","name":"Recircula ACS OFF","server":"e810789.76b1f88","version":3,"debugenabled":false,"service_domain":"switch","service":"turn_off","entityId":"switch.switch_acs_sala_de_maquinas_l2","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1130,"y":2360,"wires":[["b3b4fd82ce9c3a40"]]},{"id":"b3b4fd82ce9c3a40","type":"template","z":"a2037a02d7c8a9f4","name":"Mensaje","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Venga, ya tienes el agua calentita.\n\n\n","output":"str","x":1340,"y":2360,"wires":[["886c284fde5b9f69"]],"icon":"font-awesome/fa-sticky-note"},{"id":"b50ecd5d6cdb53d7","type":"alexa-home","z":"a2037a02d7c8a9f4","conf":"3bbb4856c7954dc2","device":"173965","acknoledge":false,"name":"Agua Caliente","topic":"","x":210,"y":2260,"wires":[["80ffa811b4e15710"]]},{"id":"832e2dab12f82e22","type":"alexa-remote-routine","z":"a2037a02d7c8a9f4","name":"Alexa Juan NR","account":"88f7f6673abb5ac7","routineNode":{"type":"speakAtVolume","payload":{"type":"regular","text":{"type":"msg","value":"payload.name"},"volume":{"type":"num","value":"30"},"mode":"set","devices":["a9158957cedd4bb09c26e7a22abcdcba"]}},"x":940,"y":2220,"wires":[[]]},{"id":"6316f01b59970fd0","type":"alexa-remote-routine","z":"a2037a02d7c8a9f4","name":"Alexa Juan NR","account":"88f7f6673abb5ac7","routineNode":{"type":"speakAtVolume","payload":{"type":"regular","text":{"type":"msg","value":"payload.name"},"volume":{"type":"num","value":"30"},"mode":"set","devices":["a9158957cedd4bb09c26e7a22abcdcba"]}},"x":760,"y":2440,"wires":[[]]},{"id":"886c284fde5b9f69","type":"alexa-remote-routine","z":"a2037a02d7c8a9f4","name":"Alexa Juan NR","account":"88f7f6673abb5ac7","routineNode":{"type":"speakAtVolume","payload":{"type":"regular","text":{"type":"msg","value":"payload.name"},"volume":{"type":"num","value":"30"},"mode":"set","devices":["a9158957cedd4bb09c26e7a22abcdcba"]}},"x":1540,"y":2360,"wires":[[]]},{"id":"e810789.76b1f88","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30},{"id":"3bbb4856c7954dc2","type":"alexa-home-conf","username":"Mengi"},{"id":"88f7f6673abb5ac7","type":"alexa-remote-account","name":"Alexa NR","authMethod":"proxy","proxyOwnIp":"192.168.2.15","proxyPort":"3456","cookieFile":"","refreshInterval":"3","alexaServiceHost":"alexa.amazon.es","amazonPage":"amazon.es","acceptLanguage":"es-ES","onKeywordInLanguage":"on","userAgent":"","useWsMqtt":"on","autoInit":"on"}]

I get this error when I use msg.payload.name

image