Alexa read data when requested

Hello all,

I've been working with NodeRed since yesterday and I'm excited about the functionality. After some initial difficulties I managed to query a variable (temperature) of my heating boiler. The whole heating system works with a wood boiler.

You can find the previous post about the solution of the "value request problem" here:

Now I want Alexa to read out the value when I ask for it and when it falls below a certain value.

Can someone help me with the necessary flow?

I want to be able to ask alexa: "What is the temperature of ......." and I want to get the answer: "the temperature is "payload.eta.value[0].$.strValue!".

As another flow I want:

IF temperature
of payload.eta.value[0].$.strValue! < 40°
THEN voice output Alexa (every 30minutes):
"Temperature of heating boiler is "payload.eta.value[0].$.strValue!" Please make fire."

I hope I was able to describe my issue and I am looking forward to your messages.

Best regards Hendrik
(from Germany)

Perhaps this testbed flow for text to voice from node red to Alexa over bluetooth as well as limited speech input control from Alexa to node red will be helpful.

The node node-red-contrib-play-audio allows you to hear the output on the browser if you are using vnc, while node-red-contrib-wemo-emulator basically emulates a wifi plug controlled through Alexa.

The TTS uses google translate which outputs in mp3, however there is a delay in output. For fastest response the mp3 is converted on the fly to a wav file which is then output to Alexa echo connected to the raspberry pi as a bluetooth speaker.

[{"id":"e273b97f.97c148","type":"tab","label":"Pi_2_bleSPEAKER","disabled":false,"info":""},{"id":"866572cd.1cabb","type":"comment","z":"e273b97f.97c148","name":"https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=Hello+World","info":"https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=Hello+World","x":480,"y":120,"wires":[]},{"id":"a58a79e3.5db398","type":"comment","z":"e273b97f.97c148","name":"Voice communication between e.g.Alexa and RPI","info":"# Output Delay to Bluetooth Speaker\n## **ffplay**\n    5-6 seconds\n## **cvlc**\n    less than 3 seconds\n## **aplay**\n    less than 1 second\n    \n# Therefore best to convert mp3 to wav for use\n","x":540,"y":40,"wires":[]},{"id":"5ccbf570.ecdf9c","type":"wemo-emulator","z":"e273b97f.97c148","name":"","friendlyName":"My Pi","serial":"1","port":"34087","onTopic":"Hello Pi Zero","onPayload":"Hello, Pi Zero is now ON","offTopic":"Good Bye Pi Zero","offPayload":"Goodbye My Pi","x":200,"y":380,"wires":[["597a0b09.032f54"]]},{"id":"4d138d69.57e704","type":"comment","z":"e273b97f.97c148","name":"tell Alexa: Turn off My pi","info":"","x":200,"y":440,"wires":[]},{"id":"4a1502b.eda03fc","type":"comment","z":"e273b97f.97c148","name":"tell Alexa: Turn on My pi","info":"","x":200,"y":340,"wires":[]},{"id":"b1e32597.2c78a8","type":"inject","z":"e273b97f.97c148","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Goodbye","payloadType":"str","x":180,"y":280,"wires":[["597a0b09.032f54"]]},{"id":"67bd15e7.7e05cc","type":"inject","z":"e273b97f.97c148","name":"","repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Hello","payloadType":"str","x":190,"y":220,"wires":[["597a0b09.032f54"]]},{"id":"bae924d9.b41608","type":"play audio","z":"e273b97f.97c148","name":"","voice":"0","x":850,"y":240,"wires":[]},{"id":"597a0b09.032f54","type":"function","z":"e273b97f.97c148","name":"TTS","func":"msg.url =\"https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=\"+msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":240,"wires":[["1a67f7f4.ceebf8","30704c6d15cd1368"]]},{"id":"1a67f7f4.ceebf8","type":"http request","z":"e273b97f.97c148","name":"Download mp3","method":"GET","ret":"bin","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":560,"y":240,"wires":[["fb043dc9.03987","bae924d9.b41608"]]},{"id":"5aa18234.1e1cfc","type":"exec","z":"e273b97f.97c148","command":"DISPLAY=:0 ffplay ","addpay":"payload","append":"  >/dev/null 2>&1 -vn -autoexit -nodisp","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":850,"y":340,"wires":[[],[],["fcb0628317c8900a"]]},{"id":"fb043dc9.03987","type":"file","z":"e273b97f.97c148","name":"File write to Buffer","filename":"/home/pi/Desktop/audio.mp3","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":570,"y":280,"wires":[["8f1d43cfb19b69bf"]]},{"id":"819b3cfeb9606e49","type":"comment","z":"e273b97f.97c148","name":"Output on Browser","info":"","x":870,"y":200,"wires":[]},{"id":"bc3fe0386551d616","type":"comment","z":"e273b97f.97c148","name":"Output mp3 to Bluetooth Speaker","info":"","x":870,"y":300,"wires":[]},{"id":"a1f9ee40e25fa20d","type":"comment","z":"e273b97f.97c148","name":"ffplay Desktop/audio.mp3 >/dev/null 2>&1 -vn -autoexit -nodisp","info":"So by specifying > /dev/null 2>&1 you tell the system that you want to redirect the command's standard output into /dev/null, then redirect standard error into standard output (which in turn is redirected into /dev/null). This has the effect of silencing the command by throwing away all of its output that is sent to either stdout or stderr.","x":940,"y":380,"wires":[]},{"id":"6dd3fddb77516621","type":"exec","z":"e273b97f.97c148","command":"DISPLAY=:0 aplay","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":590,"y":700,"wires":[[],[],["b8f719b643171b25"]]},{"id":"9739b27be27bd415","type":"exec","z":"e273b97f.97c148","command":"DISPLAY=:0 ffplay","addpay":"payload","append":">/dev/null 2>&1 -vn -autoexit -nodisp -infbuf","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":590,"y":820,"wires":[[],[],["5ebc114217dbbe28"]]},{"id":"f67bc7636a06da18","type":"inject","z":"e273b97f.97c148","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Desktop/audio.mp3 ","payloadType":"str","x":230,"y":820,"wires":[["7b5a966485e2598e"]]},{"id":"7f7b33f409c4ec51","type":"inject","z":"e273b97f.97c148","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Desktop/audio.wav","payloadType":"str","x":230,"y":700,"wires":[["3b00b443ab48f4fd"]]},{"id":"e618a1223a958607","type":"exec","z":"e273b97f.97c148","command":"DISPLAY=:0 cvlc  ","addpay":"payload","append":">/dev/null 2>&1 --play-and-exit","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":590,"y":760,"wires":[[],[],["9910a669ea46f618"]]},{"id":"8724b2a3ad73cd8c","type":"inject","z":"e273b97f.97c148","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Desktop/audio.mp3 ","payloadType":"str","x":230,"y":760,"wires":[["c21cc4ef3ea5342f"]]},{"id":"3b00b443ab48f4fd","type":"ui_button","z":"e273b97f.97c148","name":"","group":"0e9c5f30215bb24c","order":2,"width":0,"height":0,"passthru":true,"label":"aplay wav","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"Desktop/audio.wav","payloadType":"str","topic":"topic","topicType":"msg","x":400,"y":700,"wires":[["6dd3fddb77516621"]]},{"id":"c21cc4ef3ea5342f","type":"ui_button","z":"e273b97f.97c148","name":"","group":"0e9c5f30215bb24c","order":3,"width":0,"height":0,"passthru":true,"label":"cvlc mp3","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"Desktop/audio.mp3 ","payloadType":"str","topic":"topic","topicType":"msg","x":400,"y":760,"wires":[["e618a1223a958607"]]},{"id":"7b5a966485e2598e","type":"ui_button","z":"e273b97f.97c148","name":"","group":"0e9c5f30215bb24c","order":4,"width":0,"height":0,"passthru":true,"label":"ffplay mp3","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"Desktop/audio.mp3 ","payloadType":"str","topic":"topic","topicType":"msg","x":410,"y":820,"wires":[["9739b27be27bd415"]]},{"id":"69f00d4149f72637","type":"ui_text_input","z":"e273b97f.97c148","name":"Saved to mp3","label":"Saved to mp3","tooltip":"","group":"0e9c5f30215bb24c","order":1,"width":0,"height":0,"passthru":false,"mode":"text","delay":"0","topic":"topic","sendOnBlur":false,"className":"","topicType":"msg","x":200,"y":160,"wires":[["597a0b09.032f54"]]},{"id":"be8dde74a6affb79","type":"comment","z":"e273b97f.97c148","name":"and Convert to wav","info":"","x":550,"y":400,"wires":[]},{"id":"fb642b1de20d7af0","type":"exec","z":"e273b97f.97c148","command":"ffmpeg -y -i","addpay":"payload","append":"Desktop/audio.wav","useSpawn":"false","timer":"","winHide":true,"oldrc":false,"name":"","x":550,"y":440,"wires":[["bbdb135076df91fd"],[],[]]},{"id":"8f1d43cfb19b69bf","type":"change","z":"e273b97f.97c148","name":"Set msg.payload \\n to Buffer file","rules":[{"t":"set","p":"payload","pt":"msg","to":"Desktop/audio.mp3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":340,"wires":[["fb642b1de20d7af0","5aa18234.1e1cfc"]]},{"id":"bbdb135076df91fd","type":"exec","z":"e273b97f.97c148","command":"DISPLAY=:0 aplay","addpay":"","append":"Desktop/audio.wav","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":570,"y":520,"wires":[[],[],["00ef3f60401554dd"]]},{"id":"f14fac21b4f26f8b","type":"comment","z":"e273b97f.97c148","name":"aplay Desktop/audio.wav to Bluetooth Speaker","info":"","x":570,"y":580,"wires":[]},{"id":"36a4798f455775ce","type":"ui_text_input","z":"e273b97f.97c148","name":"Dynamic","label":"Dynamic:  APLAY as wav after saving as mp3","tooltip":"","group":"0e9c5f30215bb24c","order":6,"width":0,"height":0,"passthru":true,"mode":"text","delay":"0","topic":"topic","sendOnBlur":false,"className":"","topicType":"msg","x":180,"y":1000,"wires":[["ecd390911b63923d"]]},{"id":"ecd390911b63923d","type":"function","z":"e273b97f.97c148","name":"TTS","func":"msg.url =\"https://translate.google.com/translate_tts?ie=UTF-8&client=tw-ob&tl=en&q=\"+msg.payload;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":1000,"wires":[["d346e0ad93496732"]]},{"id":"d346e0ad93496732","type":"http request","z":"e273b97f.97c148","name":"Download mp3","method":"GET","ret":"bin","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":520,"y":1000,"wires":[["e84b49c4b011db9a","bc3cdad30a0078cb"]]},{"id":"e84b49c4b011db9a","type":"play audio","z":"e273b97f.97c148","name":"","voice":"0","x":750,"y":1000,"wires":[]},{"id":"2a47f84eb772d07f","type":"exec","z":"e273b97f.97c148","command":"ffmpeg -i ","addpay":"payload","append":" -f wav - | DISPLAY=:0 aplay - ","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":500,"y":1160,"wires":[[],[],[]]},{"id":"f247a50823a43ed1","type":"change","z":"e273b97f.97c148","name":"Set msg.payload \\n to Buffer file","rules":[{"t":"set","p":"payload","pt":"msg","to":"Desktop/audio.mp3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":1100,"wires":[["2a47f84eb772d07f"]]},{"id":"59b4a592c39a0f2f","type":"comment","z":"e273b97f.97c148","name":"Save Text to file, EXEC converts and outputs as wav by aplay","info":"ffmpeg -y -i Desktop/audio.mp3 -f wav - | aplay - \n","x":280,"y":940,"wires":[]},{"id":"bc3cdad30a0078cb","type":"file","z":"e273b97f.97c148","name":"File write to Buffer","filename":"/home/pi/Desktop/audio.mp3","appendNewline":false,"createDir":false,"overwriteFile":"true","encoding":"none","x":530,"y":1040,"wires":[["f247a50823a43ed1"]]},{"id":"b8f719b643171b25","type":"debug","z":"e273b97f.97c148","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":700,"wires":[]},{"id":"9910a669ea46f618","type":"debug","z":"e273b97f.97c148","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":760,"wires":[]},{"id":"5ebc114217dbbe28","type":"debug","z":"e273b97f.97c148","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":820,"wires":[]},{"id":"fcb0628317c8900a","type":"debug","z":"e273b97f.97c148","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1050,"y":340,"wires":[]},{"id":"00ef3f60401554dd","type":"debug","z":"e273b97f.97c148","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":520,"wires":[]},{"id":"30704c6d15cd1368","type":"debug","z":"e273b97f.97c148","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":550,"y":180,"wires":[]},{"id":"510fd79235320044","type":"inject","z":"e273b97f.97c148","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Dynamic Output","payloadType":"str","x":150,"y":1080,"wires":[["36a4798f455775ce"]]},{"id":"21e367111b96ca4f","type":"ui_spacer","z":"e273b97f.97c148","name":"spacer","group":"0e9c5f30215bb24c","order":5,"width":1,"height":1},{"id":"261ed9809d91b303","type":"ui_spacer","z":"e273b97f.97c148","name":"spacer","group":"0e9c5f30215bb24c","order":1,"width":1,"height":1},{"id":"0e9c5f30215bb24c","type":"ui_group","name":"Text to Sound via Google Translate","tab":"b6152d595c55a32b","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"b6152d595c55a32b","type":"ui_tab","name":"Pi_2_bleSPEAKER","icon":"dashboard","disabled":false,"hidden":false}]
1 Like

you can use node-red-contrib-virtual-smart-home or node-red-contrib-amazon-echo to create virtual lights/devices in alexa. You can then set up a routine in alexa for "What is the temperature of .......", to trigger your virtual device and start the flow. You can then use node-red-contrib-alexa-remote2-applestrudel to make alexa speak your "the temperature is "payload.eta.value[0].$.strValue!".

1 Like

Hi, thanks for your description! Everything works great so far. At least the triggering of the routine.

I can not get the "node-red-contrib-alexa-remote2-applestrudel" activated. The login with proxi doesn't work, because I can't get a port forwarding set up on my Synology VM. Logging in with email and password doesn't work for some reason. And the cookie.. I do not know how it works or how to get the cookie. Maybe you could help me with this.

Another question relatet to the virtual Device (node-red-contrib-virtual-smart-home)...
I can select that the device is a termostat. so it is also displayed in the Alexa app... but only 0.0°C
Can I also directly display the correct value and avoid the way with "applestrudel"?

I use Proxy to Initalise the nodes, I save that Authorization to a context variable.
I set auto initialise to off, and use the init node to Initialise the nodes. I do not use any Docker type container, so can not help there. I will add that you do not need to use port 3456, you can set it to any other.

The VSH node can take an input to feed back changes to alexa. From the help notes

The node also accepts inbound messages that can be used to inform Alexa about local device changes, which will then be reflected in the Alexa app. If the passthrough option is enabled, this will also trigger an outbound message, just like when the node gets invoked via Alexa

These would be the same as the out bound messages you get when you invoke the devices from alexa.
From the info help details section

Temperature Sensor

payload.temperature float
    Temperature
payload.scale string
    Scale / unit of temperature. Allowed values: 'CELSIUS', 'FAHRENHEIT', 'KELVIN' 

Thermostat

payload.powerState string
    'ON' or 'OFF'
payload.scale string
    Scale / unit of temperature. Allowed values: 'CELSIUS', 'FAHRENHEIT', 'KELVIN' 
payload.targetScale string
    Scale / unit of targetTemperature. Allowed values: 'CELSIUS', 'FAHRENHEIT', 'KELVIN' 
payload.targetTemperature float
    Target temperature
payload.temperature float
    Measured temperature
payload.thermostatMode string
    'AUTO', 'HEAT', 'COOL', 'ECO', 'OFF'

Thanks, i have now extracted and inserted a cookie with DevTools from Alexa.amazon.com. It works for now. So i dont need the output with the the VSH node. (I didn't manage it anyway)

When I ask Alexa for "buffer temperature" it starts a routine. The routine "switches" Pufferspeicher (the virtual device in NodeRed) that triggers the flow and asks for the current temp.
At the end, the "Routine speak" element is triggered and Alexa says the current temp.

Now it's a matter of a few more details: I want the routine to read out not only the variable, but a text before and after it.

".........." payload.eta.value[0].$.strValue "................."

How can I write this?

The second flow regularly requests the values and shows them to me in the HomeAssistant. If the temperature is <40 ° C Alexa should inform me. Also works so far without problems.

Only I would like to customize the announcement (text before and after the variable).
Can I possibly just rewrite my own "msg. payload xy" variable and then use it? So basically link the text and the variable in a new variable?
Thank you for your patience with all of my questions..!

You can use Javascript in a function node var = "some text " + variable + " some text"

example

[{"id":"6eb15d69.e29e04","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"24","payloadType":"num","x":160,"y":980,"wires":[["15f57278.602dee"]]},{"id":"15f57278.602dee","type":"function","z":"c791cbc0.84f648","name":"","func":"msg.payload = \"the temerature is \" + msg.payload + \" degrees\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":330,"y":980,"wires":[["cdd3f304.e56e5"]]},{"id":"cdd3f304.e56e5","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":520,"y":980,"wires":[]}]

or you can use a template node
example

[{"id":"6eb15d69.e29e04","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"24","payloadType":"num","x":160,"y":980,"wires":[["644e8f4c.4912a"]]},{"id":"644e8f4c.4912a","type":"template","z":"c791cbc0.84f648","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"the temerature is {{payload}} degrees","output":"str","x":320,"y":980,"wires":[["cdd3f304.e56e5"]]},{"id":"cdd3f304.e56e5","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":520,"y":980,"wires":[]}]
1 Like

Hello all

I'm new on home assistant / node red and need help pls

I want to write the name of the music on home assistant

i have a node that change state on node-red and send to alexa to play that music.

Is that possible?

Thank you

I have a input.text helper on home assistant

Hi Sylviu,

please open a new topic to ask your question. you should get answers faster that way. You should also describe your question in more detail. So you could attach your flow or add pictures to the new Topic.

Best regards Hendrik

thk you for yr reply

Hi E1cid
I have another question regarding proxi authenification. I now also use this method and for this purpose have used an open port of the VM. Also worked great. However, I have to log on again every second day (open 192.168.178........ on you browser and so on..).

Now I tried to enter some data in the field "File Path". However, this does not really work! What exactly do I have to do to bypass or avoid the manual login?

Best regards Hendrik

What i do is this

[{"id":"e63c03b3.745b48","type":"inject","z":"d629013b.18a518","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"86400","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"alexa","payloadType":"flow","x":100,"y":1460,"wires":[["89e02d64.da77c8"]]},{"id":"89e02d64.da77c8","type":"alexa-remote-init","z":"d629013b.18a518","name":"","account":"c8738129.d902c","option":"initialise","x":290,"y":1460,"wires":[["fc0183e2.5e7c2"]]},{"id":"fc0183e2.5e7c2","type":"change","z":"d629013b.18a518","name":"","rules":[{"t":"set","p":"alexa","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":1460,"wires":[["421c02e9.68fdec"]]},{"id":"c8738129.d902c","type":"alexa-remote-account","name":"alexa remote 2","authMethod":"proxy","proxyOwnIp":"localhost","proxyPort":"3456","cookieFile":"","refreshInterval":"14","alexaServiceHost":"layla.amazon.co.uk","amazonPage":"amazon.co.uk","acceptLanguage":"en-GB","userAgent":"","useWsMqtt":"on","autoInit":"off"}]

and set auto int to off, as below

Also make sure your context store is persistant
https://nodered.org/docs/user-guide/context#context-stores

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.