# Alexa what is the tank level?

**URL:** <https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914>\
**Category:** General\
**Created:** [9 December 2021 08:34 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914 "2021-12-09T08:34:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![camo200sx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/camo200sx/32/6248_2.png) [@camo200sx](https://discourse.nodered.org/u/camo200sx)\
**Post date:** [9 December 2021 08:34 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/1 "2021-12-09T08:34:48Z")

</div>

Any help would be appreciated. I have an ESP8266 that logs a volume in liters (going to change to a percentage but that irrelevant) to an mqtt broker. I have this value in node red and would like to ask Alexa to retrieve it for me.

Any directions on where to start?  
Regards

---

<div class="post-metadata">

**Author:** ![haegar33](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haegar33/32/38805_2.png) [@haegar33](https://discourse.nodered.org/u/haegar33)\
**Post date:** [9 December 2021 08:52 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/2 "2021-12-09T08:52:23Z")

</div>

Look at this thread for a start:

> [@Pure fun with Alexa and Alexa Skills](https://discourse.nodered.org/t/pure-fun-with-alexa-and-alexa-skills/46867):
>
> Now the authentication problem with various Alexa nodes has been sorted I thought I'd try something new. I used [BluePrints](https://blueprints.amazon.co.uk/home) 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.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [9 December 2021 08:52 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/3 "2021-12-09T08:52:29Z")

</div>

Have a look at this thread for some ideas.

> [@Pure fun with Alexa and Alexa Skills](https://discourse.nodered.org/t/pure-fun-with-alexa-and-alexa-skills/46867/3):
>
> A "6 Echo" houshold. Respect! slight_smile

I get my ESP8266-based sensors to report their readings, via MQTT, to Node-RED where they are stored either in a database or a global variable. Then using Blueprints I can ask questions like... "Alexa, give me a temperature report" which triggers a corresponding flow. Be careful - this can become ADDICTIVE.

---

<div class="post-metadata">

**Author:** ![camo200sx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/camo200sx/32/6248_2.png) [@camo200sx](https://discourse.nodered.org/u/camo200sx)\
**Post date:** [10 December 2021 06:40 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/4 "2021-12-10T06:40:26Z")

</div>

Thanks for the link guys. I've got this far but seem to be stuck getting a response. I've set up the blueprint skill and Alexa responds as per my blueprint but I get nothing on any of my debug nodes. I can inject into routine and she will say it. Authorization seems fine. Any quick insight would be great.

`[{"id":"f95a9733d0a01e91","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"1346201638117967","type":"change","z":"f95a9733d0a01e91","name":"Set level","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number(payload)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":260,"wires":[["d845628143fb2d16"]]},{"id":"bf5de66a2cc442ad","type":"mqtt in","z":"f95a9733d0a01e91","name":"","topic":"home/tank/level","qos":"0","datatype":"auto","broker":"51f194ce1591908f","nl":false,"rap":true,"rh":0,"x":340,"y":200,"wires":[["1346201638117967","abea4b4340799cb0"]]},{"id":"097b5e552b807802","type":"debug","z":"f95a9733d0a01e91","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":160,"wires":[]},{"id":"d845628143fb2d16","type":"debug","z":"f95a9733d0a01e91","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":790,"y":260,"wires":[]},{"id":"abea4b4340799cb0","type":"change","z":"f95a9733d0a01e91","name":"Set level","rules":[{"t":"set","p":"level","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":160,"wires":[["097b5e552b807802"]]},{"id":"bf44407a.c20d4","type":"alexa-remote-init","z":"f95a9733d0a01e91","name":"","account":"57e78a27.bf542c","option":"initialise","x":480,"y":380,"wires":[["123e6678.5acbaa"]]},{"id":"c7f04444.fed188","type":"inject","z":"f95a9733d0a01e91","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 12 * * 3,4,0","once":false,"onceDelay":0.1,"topic":"","payload":"alexa","payloadType":"flow","x":330,"y":380,"wires":[["bf44407a.c20d4"]]},{"id":"123e6678.5acbaa","type":"change","z":"f95a9733d0a01e91","name":"","rules":[{"t":"set","p":"alexa","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":380,"wires":[[]]},{"id":"43e7076457cce46f","type":"alexa-remote-event","z":"f95a9733d0a01e91","name":"","account":"57e78a27.bf542c","event":"ws-device-activity","x":330,"y":520,"wires":[["7182437ec92bea9b","768e6c9cf20d4104"]]},{"id":"7182437ec92bea9b","type":"switch","z":"f95a9733d0a01e91","name":"","property":"payload.alexaResponse","propertyType":"msg","rules":[{"t":"cont","v":"You have","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":530,"y":520,"wires":[["68e373e443361ed1"]]},{"id":"68e373e443361ed1","type":"alexa-remote-routine","z":"f95a9733d0a01e91","name":"","account":"57e78a27.bf542c","routineNode":{"type":"speakAtVolume","payload":{"type":"regular","text":{"type":"flow","value":"level"},"volume":{"type":"num","value":"50"},"mode":"set","devices":{"type":"msg","value":"payload.name"}}},"x":750,"y":520,"wires":[["858641443cf844e6"]]},{"id":"858641443cf844e6","type":"debug","z":"f95a9733d0a01e91","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":580,"wires":[]},{"id":"768e6c9cf20d4104","type":"debug","z":"f95a9733d0a01e91","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":530,"y":580,"wires":[]},{"id":"51f194ce1591908f","type":"mqtt-broker","name":"Home-Assistant-Mosquitto","broker":"192.168.1.202","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"57e78a27.bf542c","type":"alexa-remote-account","name":"Amazon-Alexa","authMethod":"proxy","proxyOwnIp":"192.168.1.202","proxyPort":"3456","cookieFile":"Alexa_init","refreshInterval":"3","alexaServiceHost":"alexa.amazon.com.au","amazonPage":"amazon.com.au","acceptLanguage":"en-US","userAgent":"","useWsMqtt":"on","autoInit":"on"}]`

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [10 December 2021 07:27 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/5 "2021-12-10T07:27:50Z")

</div>

Try this simple flow to get you started.

 ![Screen Shot 12-10-21 at 07.23 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8debd86dd795b6ce5c2369ca764047cf94478f7b.gif)  
It should capture your question and the device\_name  
You'll need to adjust the credentials in the 'initialise' node to match your geographical location, IP, etc..

```auto
[{"id":"9d5de8e11c041b38","type":"alexa-remote-init","z":"fc2ffed5c7a37e1d","name":"","account":"65fc5fb4b8d06bdd","option":"initialise","x":140,"y":560,"wires":[[]]},{"id":"5154915a06305640","type":"alexa-remote-event","z":"fc2ffed5c7a37e1d","name":"","account":"65fc5fb4b8d06bdd","event":"ws-device-activity","x":170,"y":620,"wires":[["2c68ef53.23d3f8","b0ba2ae16f1145bf"]]},{"id":"919a026a168f7e5f","type":"debug","z":"fc2ffed5c7a37e1d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":620,"wires":[]},{"id":"2c68ef53.23d3f8","type":"function","z":"fc2ffed5c7a37e1d","name":"Capture question","func":"var alexa_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: alexa_device_name,\n payload: {\n \"summary\": summary\n }\n }\n flow.set(\"alexa_device_name\",alexa_device_name);\n node.status({text:\"Device_name is \"+ alexa_device_name + \" Summary = \" + summary});\n return msg;\n}\nelse {\n return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":620,"wires":[["962a99e7.3a24d","919a026a168f7e5f","0b32c2a7297d89cc","5b9f3f09a10285ab","da9a0917d09f933d"]]},{"id":"b0ba2ae16f1145bf","type":"debug","z":"fc2ffed5c7a37e1d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":350,"y":560,"wires":[]},{"id":"1e3f9d93f42df6b8","type":"inject","z":"fc2ffed5c7a37e1d","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":140,"y":500,"wires":[["9d5de8e11c041b38","d0cb70a27ade1f8e"]]},{"id":"65fc5fb4b8d06bdd","type":"alexa-remote-account","name":"Amazon acct","authMethod":"proxy","proxyOwnIp":"192.168.1.158","proxyPort":"3456","cookieFile":"/home/pi/amazon_alexa.txt","refreshInterval":"3","alexaServiceHost":"alexa.amazon.co.uk","amazonPage":"amazon.co.uk","acceptLanguage":"en-GB","onKeywordInLanguage":"","userAgent":"","useWsMqtt":"on","autoInit":"on"}]

```

---

<div class="post-metadata">

**Author:** ![camo200sx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/camo200sx/32/6248_2.png) [@camo200sx](https://discourse.nodered.org/u/camo200sx)\
**Post date:** [11 December 2021 07:50 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/6 "2021-12-11T07:50:53Z")

</div>

Awesome, Thanks Dave. From that I have got it to work and can probably expand on from there.

Quick question. I can't seem to set a file path to save the authentication to. I have created a new file at /home/alexa\_init.txt but it still complains about no such file. Any tips?

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [11 December 2021 08:42 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/7 "2021-12-11T08:42:35Z")

</div>

Does that file actually exist?? If you are running on a RPi, have you done a 'touch' to create it??

The path you are using is owned by root so..  
Probably a better path for the file would be.. **/home/pi/alexa\_init.txt**

Here's some code to help you start formatting a report-message. I've taken it from a flow I have that reports the temperature of a set of four Raspberry Pi(es) if one of them goes above a certain value. You could adapt it and insert your flow variables. Notice the use of `<break time='0.25s'>` to create pauses in the message which makes it sound more natural. Have fun.

```auto
var hostname = flow.get("hostname");
var ip_address = flow.get("ip_address");
var cpu_temperature = flow.get("cpu_temperature");

var message = "<break time='0.25s'/> Here's your report on your raspberry pie<break time='0.5s'/>";
    
message += "hostname is <break time='0.1s'/>"+hostname+ "<break time='0.25s'/>";
message += "IP address is <break time='0.1s'/>"+ip_address+ "<break time='0.25s'/>";
message += "CPU core temperature is <break time='0.1s'/>"+cpu_temperature+ "degrees sea <break time='0.25s'/>";

// This the footer for the message
message += "<break time='0.75s'/> that's the end of the report";

msg.payload = message;
return msg;

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [11 December 2021 09:49 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/8 "2021-12-11T09:49:34Z")

</div>

You do not have to save the authorization to file you can save to context storage, you can retrieve it from context in an inject node and feed it back into the init node to restore authorization  
e.g.

```auto
[{"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"}]

```

---

<div class="post-metadata">

**Author:** ![camo200sx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/camo200sx/32/6248_2.png) [@camo200sx](https://discourse.nodered.org/u/camo200sx)\
**Post date:** [12 December 2021 01:18 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/9 "2021-12-12T01:18:58Z")

</div>

Awesome, that helps. I can now ask Alexa either what percentage or how many liters there are in the tank. However I have an issue with the whole thing when HA or Node-Red restarts. Seems it requires me to go through the whole, open a webpage and sign in process which is not ideal. Unsure if this will happen after a length of time either.

I'll throw what I've got working here incase anyone feels like taking a quick look  
Thanks again

```auto
[{"id":"0b6dc4faf464f97f","type":"tab","label":"ALEXA","disabled":false,"info":""},{"id":"412ab35f50a0b24f","type":"alexa-remote-event","z":"0b6dc4faf464f97f","name":"","account":"0df2185d1ca3e00b","event":"ws-device-activity","x":150,"y":580,"wires":[["e218999550953731"]]},{"id":"e218999550953731","type":"function","z":"0b6dc4faf464f97f","name":"Capture question","func":"var alexa_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: alexa_device_name,\n payload: {\n \"summary\": summary\n }\n }\n flow.set(\"alexa_device_name\",alexa_device_name);\n node.status({text:\"Device_name is \"+ alexa_device_name + \" Summary = \" + summary});\n return msg;\n}\nelse {\n return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":580,"wires":[["3e7965049a6580fc"]]},{"id":"3e7965049a6580fc","type":"switch","z":"0b6dc4faf464f97f","name":"","property":"payload.summary","propertyType":"msg","rules":[{"t":"cont","v":"how many liters do we have","vt":"str"},{"t":"cont","v":"how much water do we have","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":570,"y":580,"wires":[["b23a25fa8eeb625b"],["51ea62eb5d649fd5"]],"info":"Setup a question in BLUEPRINTS with a response. Use that response to format a reply with correct information"},{"id":"ba285db584768ea3","type":"alexa-remote-routine","z":"0b6dc4faf464f97f","name":"","account":"0df2185d1ca3e00b","routineNode":{"type":"speak","payload":{"type":"regular","text":{"type":"msg","value":"payload"},"devices":{"type":"flow","value":"alexa_device_name"}}},"x":1000,"y":580,"wires":[[]]},{"id":"51ea62eb5d649fd5","type":"function","z":"0b6dc4faf464f97f","name":"Format response","func":"var percent = flow.get(\"percent\");\n\nvar message = \"<break time='0.25s'/>\" +percent+ \"remaining\"\n \nmsg.payload = message;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":600,"wires":[["ba285db584768ea3"]]},{"id":"b903a663bb1c75f2","type":"comment","z":"0b6dc4faf464f97f","name":"RESPOND TO QUESTION","info":"","x":170,"y":520,"wires":[]},{"id":"349d58c7eeb8ba50","type":"comment","z":"0b6dc4faf464f97f","name":"GRAB MQTT VALUES AND SET TO FLOW VARIABLES","info":"","x":270,"y":320,"wires":[]},{"id":"814bf0f99bc9a9c2","type":"inject","z":"0b6dc4faf464f97f","name":"Refresh once an hour","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"3600","crontab":"","once":true,"onceDelay":"7","topic":"","payloadType":"date","x":200,"y":160,"wires":[["9388f745d62a36df"]]},{"id":"9388f745d62a36df","type":"alexa-remote-init","z":"0b6dc4faf464f97f","name":"","account":"0df2185d1ca3e00b","option":"refresh","x":440,"y":160,"wires":[[]]},{"id":"e63c03b3.745b48","type":"inject","z":"0b6dc4faf464f97f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"86400","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"alexa","payloadType":"flow","x":170,"y":80,"wires":[["89e02d64.da77c8"]]},{"id":"89e02d64.da77c8","type":"alexa-remote-init","z":"0b6dc4faf464f97f","name":"","account":"0df2185d1ca3e00b","option":"initialise","x":360,"y":80,"wires":[["fc0183e2.5e7c2"]]},{"id":"fc0183e2.5e7c2","type":"change","z":"0b6dc4faf464f97f","name":"","rules":[{"t":"set","p":"alexa","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":80,"wires":[[]]},{"id":"2099fc69d9302d9b","type":"mqtt in","z":"0b6dc4faf464f97f","name":"","topic":"home/tank/percent","qos":"2","datatype":"auto","broker":"51f194ce1591908f","nl":false,"rap":true,"rh":0,"inputs":0,"x":150,"y":440,"wires":[["950925ea0ce4095a"]]},{"id":"730193bdf1f7300a","type":"debug","z":"0b6dc4faf464f97f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":490,"y":440,"wires":[]},{"id":"950925ea0ce4095a","type":"change","z":"0b6dc4faf464f97f","name":"Set percent","rules":[{"t":"set","p":"percent","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":440,"wires":[["730193bdf1f7300a"]]},{"id":"b23a25fa8eeb625b","type":"function","z":"0b6dc4faf464f97f","name":"Format response","func":"var level = flow.get(\"level\");\n\nvar message = \"<break time='0.25s'/>\" +level+ \"remaining\"\n \nmsg.payload = message;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":560,"wires":[["ba285db584768ea3"]]},{"id":"4556313d8ed51dc5","type":"mqtt in","z":"0b6dc4faf464f97f","name":"","topic":"home/tank/level","qos":"2","datatype":"auto","broker":"51f194ce1591908f","nl":false,"rap":true,"rh":0,"inputs":0,"x":140,"y":380,"wires":[["df14265ee07a12dc"]]},{"id":"448d7b7b259f0fe8","type":"debug","z":"0b6dc4faf464f97f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":490,"y":380,"wires":[]},{"id":"df14265ee07a12dc","type":"change","z":"0b6dc4faf464f97f","name":"Set level","rules":[{"t":"set","p":"level","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":380,"wires":[["448d7b7b259f0fe8"]]},{"id":"0df2185d1ca3e00b","type":"alexa-remote-account","name":"Amazon-Alexa","authMethod":"proxy","proxyOwnIp":"192.168.1.202","proxyPort":"3456","cookieFile":"","refreshInterval":"3","alexaServiceHost":"alexa.amazon.com.au","amazonPage":"amazon.com.au","acceptLanguage":"en-US","onKeywordInLanguage":"","userAgent":"","useWsMqtt":"on","autoInit":"on"},{"id":"51f194ce1591908f","type":"mqtt-broker","name":"Home-Assistant-Mosquitto","broker":"192.168.1.202","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]

```

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [12 December 2021 01:44 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/10 "2021-12-12T01:44:50Z")

</div>

Turn Auto Init off in your remote2 config. The inject nodes with the saved authentication will do that for you.

> Auto Init  
> on to initialise the account everytime the node starts or has changed

But you are not saving to file so it should be Off.

---

<div class="post-metadata">

**Author:** ![camo200sx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/camo200sx/32/6248_2.png) [@camo200sx](https://discourse.nodered.org/u/camo200sx)\
**Post date:** [12 December 2021 03:05 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/11 "2021-12-12T03:05:24Z")

</div>

Thanks! 😀

I'll give that a shot

---

<div class="post-metadata">

**Author:** ![camo200sx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/camo200sx/32/6248_2.png) [@camo200sx](https://discourse.nodered.org/u/camo200sx)\
**Post date:** [12 December 2021 05:42 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/12 "2021-12-12T05:42:42Z")

</div>

Damn. Seems it just reverts to wanting me to sign in 😪  
Do I need the refresh cookie part? As soon as I inject that, it asks me to sign in. Will remove it and see what happens overnight. Seeing as I'm running this all on a pi with HA, do I need to visit the login on the pi itself? I have just been going to the webpage and signing in on my PC...

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [12 December 2021 08:26 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/13 "2021-12-12T08:26:37Z")

</div>

Have you edited your settings json and made your context store persistent? [Working with context : Node-RED](https://nodered.org/docs/user-guide/context#context-stores)

I login on another device, when i do i enter the ip of the device running node-red.  
I do not refresh cookie.  
I use a catch node to wait for errors, if found i use a change node to load saved authentication and feed that to the initialise node.

First time i initialise i have to enter user and pass at ip:3456, after that all i need to do is press the inject button if the catch fails. Have only had to press inject again once in six months.

---

<div class="post-metadata">

**Author:** ![camo200sx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/camo200sx/32/6248_2.png) [@camo200sx](https://discourse.nodered.org/u/camo200sx)\
**Post date:** [13 December 2021 06:03 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/14 "2021-12-13T06:03:51Z")

</div>

Ahh, no I had not! Thanks again for all the help

---

<div class="post-metadata">

**Author:** ![camo200sx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/camo200sx/32/6248_2.png) [@camo200sx](https://discourse.nodered.org/u/camo200sx)\
**Post date:** [14 December 2021 04:19 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/15 "2021-12-14T04:19:04Z")

</div>

Sorry guys. Thought I had it but am being hung up on one thing it seems. In the 'device name' of the routine speak I cannot pass a flow.variable, in this case flow.alexa\_device\_name which is set in the function node. I press 'done' and it reverts to nothing. It seems this is causing no response.

Anyone know how to get the device name of the Alexa that was to in there so it responds only on that one and not a specific one?

 ![Capture](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/5/056eced21155fcbdcb475a9bb1ce2fdabdd53970.png)

```auto
[{"id":"32e7ac53d12a7210","type":"debug","z":"0b6dc4faf464f97f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":510,"y":640,"wires":[]},{"id":"9f7068ac6505e230","type":"debug","z":"0b6dc4faf464f97f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":800.0094604492188,"y":642.0056762695312,"wires":[]},{"id":"9fee98e14df11b6d","type":"debug","z":"0b6dc4faf464f97f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1050,"y":640,"wires":[]},{"id":"a47e750a0fe3cb96","type":"alexa-remote-event","z":"0b6dc4faf464f97f","name":"","account":"0df2185d1ca3e00b","event":"ws-device-activity","x":150,"y":560,"wires":[["338e7cd4a0ef4763"]]},{"id":"338e7cd4a0ef4763","type":"function","z":"0b6dc4faf464f97f","name":"Capture question","func":"var alexa_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: alexa_device_name,\n payload: {\n \"summary\": summary\n }\n }\n flow.set(\"alexa_device_name\",alexa_device_name);\n node.status({text:\"Device_name is \"+ alexa_device_name + \" Summary = \" + summary});\n return msg;\n}\nelse {\n return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":560,"wires":[["c9ec0913115de891","32e7ac53d12a7210"]]},{"id":"c9ec0913115de891","type":"switch","z":"0b6dc4faf464f97f","name":"","property":"payload.summary","propertyType":"msg","rules":[{"t":"cont","v":"how many liters do we have","vt":"str"},{"t":"cont","v":"tank level","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":570,"y":560,"wires":[["c3c9d2dedf06abbc"],["c869f1a947a5a82b","9f7068ac6505e230"]],"info":"Setup a question in BLUEPRINTS with a response. Use that response to format a reply with correct information"},{"id":"45c47815fd69e3cc","type":"alexa-remote-routine","z":"0b6dc4faf464f97f","name":"","account":"0df2185d1ca3e00b","routineNode":{"type":"speak","payload":{"type":"regular","text":{"type":"msg","value":"payload"},"devices":{"type":"msg","value":"device_name"}}},"x":1020,"y":560,"wires":[["4189151769df9f8d"]]},{"id":"c869f1a947a5a82b","type":"function","z":"0b6dc4faf464f97f","name":"Format response","func":"var percent = flow.get(\"percent\");\n\nvar message = +percent+ \"remaining\"\n \nmsg.payload = message;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":580,"wires":[["45c47815fd69e3cc","9fee98e14df11b6d"]]},{"id":"c3c9d2dedf06abbc","type":"function","z":"0b6dc4faf464f97f","name":"Format response","func":"var level = flow.get(\"level\");\n\nvar message = \"<break time='0.25s'/>\" +level+ \"remaining\"\n \nmsg.payload = message;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":540,"wires":[["45c47815fd69e3cc"]]},{"id":"4189151769df9f8d","type":"debug","z":"0b6dc4faf464f97f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1210,"y":560,"wires":[]},{"id":"0df2185d1ca3e00b","type":"alexa-remote-account","name":"Amazon-Alexa","authMethod":"proxy","proxyOwnIp":"192.168.1.202","proxyPort":"3456","cookieFile":"","refreshInterval":"3","alexaServiceHost":"alexa.amazon.com.au","amazonPage":"amazon.com.au","acceptLanguage":"en-US","onKeywordInLanguage":"","userAgent":"","useWsMqtt":"on","autoInit":"off"}]

```

[EDIT] - Seems it is passed along as 'msg.device\_name' ..... I think. Not so great at node-red

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [14 December 2021 08:45 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/16 "2021-12-14T08:45:04Z")

</div>

Why set it to a flow var, use `msg.payload.name` or `msg.payload.data.device.deviceName` directly and pass it along with the message.  
using msg.device\_name works. I have slimmed down the flow to the min and added data to inject node

```auto
[{"id":"ec84cc30.949638","type":"inject","z":"c791cbc0.84f648","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"data\":{\"recordKey\":\"A32#2\",\"recordType\":\"VOICE_HISTORY\",\"timestamp\":1639469977032,\"customerId\":\"AB\",\"device\":{\"deviceName\":\"Lounge\",\"deviceEntityId\":null},\"isBinaryFeedbackProvided\":false,\"isFeedbackPositive\":false,\"utteranceType\":\"GENERAL\",\"domain\":\"Global\",\"intent\":\"WhatTimeIntent\",\"skillName\":\"\",\"voiceHistoryRecordItems\":[{\"recordItemKey\":\"163LF16-0\",\"recordItemType\":\"CUSTOMER_TRANSCRIPT\",\"utteranceId\":\"V.cedfeb90aLPM/0\",\"timestamp\":1639469976366,\"transcriptText\":\"computer what's the time\",\"agentVisualName\":\"\",\"personsInfo\":[]},{\"recordItemKey\":\"163946D#34-2\",\"recordItemType\":\"ALEXA_RESPONSE\",\"utteranceId\":\"A31/12/14/08/DEVICE_UNSPECIFIED/19:36::TNIH_2V.cedfefc2-9dba-4f23-8568-d2bbbc32b90aLPM/0\",\"timestamp\":1639469977034,\"transcriptText\":\"The time is 8:19 am.\",\"agentVisualName\":\"\",\"personsInfo\":[]}],\"personsInfo\":[]},\"conversionDetails\":{\"CUSTOMER_TRANSCRIPT\":[{\"recordItemKey\":\"6-0\",\"recordItemType\":\"CUSTOMER_TRANSCRIPT\",\"utteranceId\":\"21/12/14/08/DEVICE_UNSPECIFIED/19:36::TNIH_2V.cedfefc2-9dba-4f23-8568-d2bbbc32b90aLPM/0\",\"timestamp\":1639469976366,\"transcriptText\":\"computer what's the time\",\"agentVisualName\":\"\",\"personsInfo\":[]}],\"ALEXA_RESPONSE\":[{\"recordItemKey\":\"163469977034-2\",\"recordItemType\":\"ALEXA_RESPONSE\",\"utteranceId\":\"021/12/14/08/DEVICE_UNSPECIFIED/19:36::TNIH_2V.cedfefc2-9dba-4f23-8568-d2bbbc32b90aLPM/0\",\"timestamp\":1639469977034,\"transcriptText\":\"The time is 8:19 am.\",\"agentVisualName\":\"\",\"personsInfo\":[]}]},\"deviceType\":\"F\",\"creationTimestamp\":1639469977032,\"deviceSerialNumber\":\"D\",\"name\":\"Lounge\",\"description\":{\"summary\":\"computer what's the time\"},\"alexaResponse\":\"The time is 8:19 am.\",\"destinationUserId\":\"Q\"}","payloadType":"json","x":210,"y":1020,"wires":[["338e7cd4a0ef4763"]]},{"id":"338e7cd4a0ef4763","type":"function","z":"c791cbc0.84f648","name":"Capture question","func":"var alexa_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: alexa_device_name,\n payload: {\n \"summary\": summary\n }\n }\n flow.set(\"alexa_device_name\",alexa_device_name);\n node.status({text:\"Device_name is \"+ alexa_device_name + \" Summary = \" + summary});\n return msg;\n}\nelse {\n return null;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":1040,"wires":[["32e7ac53d12a7210","c3c9d2dedf06abbc"]]},{"id":"32e7ac53d12a7210","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":450,"y":1140,"wires":[]},{"id":"c3c9d2dedf06abbc","type":"function","z":"c791cbc0.84f648","name":"Format response","func":"var level = flow.get(\"level\");\n\nvar message = \"<break time='0.25s'/> 23 remaining\"\n \nmsg.payload = message;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":710,"y":1040,"wires":[["4189151769df9f8d","45c47815fd69e3cc"]]},{"id":"4189151769df9f8d","type":"debug","z":"c791cbc0.84f648","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1150,"y":1040,"wires":[]},{"id":"45c47815fd69e3cc","type":"alexa-remote-routine","z":"c791cbc0.84f648","name":"","account":"c8738129.d902c","routineNode":{"type":"speak","payload":{"type":"regular","text":{"type":"msg","value":"payload"},"devices":{"type":"msg","value":"device_name"}}},"x":1190,"y":1100,"wires":[[]]},{"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"}]

```

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [14 December 2021 08:57 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/17 "2021-12-14T08:57:58Z")

</div>

This is what I do...  
 ![Screen Shot 12-14-21 at 09.08 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/7/d7ec75c6f41516e93e837709e8b426cfaef27050.gif)

---

<div class="post-metadata">

**Author:** ![camo200sx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/camo200sx/32/6248_2.png) [@camo200sx](https://discourse.nodered.org/u/camo200sx)\
**Post date:** [14 December 2021 17:40 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/18 "2021-12-14T17:40:57Z")

</div>

Thanks again you two 🙂 . After I wrote that I studied it a bit further and worked out 'device\_name' worked. All seems to be robust as of now so will put it to the test.  
Merry Christmas

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [14 December 2021 17:56 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/19 "2021-12-14T17:56:32Z")

</div>

Glad it's working for you.  
Now you can start having some **fun** sending personalised message to Alexa.

Merry Christmas to you too.

---

<div class="post-metadata">

**Author:** ![Sean-McG](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sean-mcg/32/54677_2.png) [@Sean-McG](https://discourse.nodered.org/u/Sean-McG)\
**Post date:** [15 December 2021 15:59 UTC](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914/20 "2021-12-15T15:59:08Z")

</div>

Small potatoes I have 12 echoes 😉 There is no hiding from her!

[Next page](https://discourse.nodered.org/t/alexa-what-is-the-tank-level/54914.md?page=2)
