Trying to get Alexa to read out a temperature

Hi Des,
Just had a few spare minutes to extend your flow to include a personalised message for your Alexa device.
Hope this works for you? Please let me know how you get on with it.

[{"id":"fdedac607f20a384","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"d9cef3911a340322","type":"alexa-remote-event","z":"fdedac607f20a384","name":"","account":"f5c58b4876dbd6b3","event":"ws-device-activity","x":170,"y":280,"wires":[["d9dd3578e3584bfa"]]},{"id":"c596f864e8ddf6d2","type":"mqtt in","z":"fdedac607f20a384","name":"Room temp","topic":"tele/garage/SENSOR","qos":"2","datatype":"json","broker":"22f544be.780a3c","nl":false,"rap":false,"inputs":0,"x":150,"y":120,"wires":[["23949a4c8a9421e3","48d81bc5f11542c5"]]},{"id":"d9dd3578e3584bfa","type":"switch","z":"fdedac607f20a384","name":"Filter","property":"payload.alexaResponse","propertyType":"msg","rules":[{"t":"cont","v":"temperature is","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":370,"y":280,"wires":[["fa4ad52f77a3a689","138e818ddc1d6dd3"]]},{"id":"64da3017d499a99a","type":"alexa-remote-routine","z":"fdedac607f20a384","name":"","account":"f5c58b4876dbd6b3","routineNode":{"type":"speak","payload":{"type":"announcement","text":{"type":"msg","value":"payload"},"devices":["G090LF1173660KCR"]}},"x":980,"y":280,"wires":[[]]},{"id":"138e818ddc1d6dd3","type":"function","z":"fdedac607f20a384","name":"Read variable(s) and format message for Alexa","func":"// Get the flow variable(s) to be used in the message\nvar temperature = flow.get(\"temperature\") || 0;\n\n// Convert them to a string\ntemperature = temperature.toString();\n\n// Start building the message\nvar message = \"<break time='0.25s'/> Hi Des here's your report on your tasmota device<break time='0.5s'/>\";\n\nmessage += \"temperature of the unit is <break time='0.1s'/>\"+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;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":660,"y":280,"wires":[["64da3017d499a99a","92381d845bdd0256"]]},{"id":"23949a4c8a9421e3","type":"debug","z":"fdedac607f20a384","name":"6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":130,"y":80,"wires":[]},{"id":"fa4ad52f77a3a689","type":"debug","z":"fdedac607f20a384","name":"7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":370,"y":340,"wires":[]},{"id":"92381d845bdd0256","type":"debug","z":"fdedac607f20a384","name":"11","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":530,"y":340,"wires":[]},{"id":"48d81bc5f11542c5","type":"function","z":"fdedac607f20a384","name":"","func":"// Save the reading(s) in a flow variable\n\nflow.set(\"temperature\",msg.payload.SI7021.Temperature);\n\nreturn null;\n","outputs":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":120,"wires":[]},{"id":"dd868057aab722b3","type":"function","z":"fdedac607f20a384","name":"Test setting temperature to 21","func":"flow.set(\"temperature\",msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":180,"wires":[[]]},{"id":"fcb0cd6fa3135761","type":"inject","z":"fdedac607f20a384","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"21","payloadType":"num","x":150,"y":180,"wires":[["dd868057aab722b3"]]},{"id":"0335514a2b601c42","type":"inject","z":"fdedac607f20a384","name":"Click to test the text sent to Alexa","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":230,"y":240,"wires":[["138e818ddc1d6dd3"]]},{"id":"f5c58b4876dbd6b3","type":"alexa-remote-account","name":"opt","authMethod":"proxy","proxyOwnIp":"192.168.1.147","proxyPort":"3456","cookieFile":"authFile","refreshInterval":"3","alexaServiceHost":"alexa.amazon.co.uk","amazonPage":"amazon.co.uk","acceptLanguage":"en-UK","userAgent":"","useWsMqtt":"on","autoInit":"on"},{"id":"22f544be.780a3c","type":"mqtt-broker","name":"Mosquitto","broker":"192.168.1.147","port":"1883","clientid":"","usetls":false,"compatmode":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""}]
1 Like

I like that Dave, will have a play with it today. Thanks.

Slightly off topic, but during my experimentation with this whole topic of getting Alexa to announce my sensor temperatures, I have been using my raspberry Pi 4. My heating system runs on a Pi zero W2. My attempts at transferring everything from Pi4 to Pi zero have been unsuccessful so far. I'm sure it's something to do with blueprints accounts and MQTT and IP addresses. Also my pi 4 is on version V2.1.4 but my Pi zero is on V1.3.4. I had a bad experience upgrading my Pi 4 to V2.1.4 and it took me a while to get it working satisfactorily again. I'm a bit reluctant to upgrade the Pi zero just yet as it's doing a good job of running my heating system and the little lady will not be best pleased if the heating is off for too long. I may continue prototyping on the Pi 4 until the better weather arrives and it's not so critical to have the heating running. Thanks again for your help and everyone else who contributed.

2 posts were merged into an existing topic: How can I split a MQTT string

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