Read outdoor temperature with alexa

good morning,
i use NodeRED3.0.2 on docker
i installed node-red-contrib-alexa-cakebaked
i have mosquitto and domoticz

How do I make an alexa logger, that is, make alexa upon receiving the word 'external', activate the (working) procedure below?

Summary
[
    {
        "id": "fdedac607f20a384",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "5253a127667fc9a5",
        "type": "alexa-remote-event",
        "z": "fdedac607f20a384",
        "name": "",
        "account": "47f699050b265e92",
        "event": "ws-device-activity",
        "x": 630,
        "y": 660,
        "wires": [
            [
                "11bffad747f3f612"
            ]
        ]
    },
    {
        "id": "f8efa717343628cc",
        "type": "mqtt in",
        "z": "fdedac607f20a384",
        "name": "temperatura esterna",
        "topic": "tele/wemos/SENSOR",
        "qos": "2",
        "datatype": "json",
        "broker": "22f544be.780a3c",
        "nl": false,
        "rap": false,
        "inputs": 0,
        "x": 630,
        "y": 500,
        "wires": [
            [
                "baf5fe3e71a1b2fc",
                "d3a282d36b3d0d32"
            ]
        ]
    },
    {
        "id": "11bffad747f3f612",
        "type": "switch",
        "z": "fdedac607f20a384",
        "name": "Filter",
        "property": "payload.alexaResponse",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "temperatura è",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 830,
        "y": 660,
        "wires": [
            [
                "59a455c2845c1f98",
                "e56b1b4bfdd3e432"
            ]
        ]
    },
    {
        "id": "f3af5c6c1ae94823",
        "type": "alexa-remote-routine",
        "z": "fdedac607f20a384",
        "name": "",
        "account": "47f699050b265e92",
        "routineNode": {
            "type": "speak",
            "payload": {
                "type": "announcement",
                "text": {
                    "type": "msg",
                    "value": "payload"
                },
                "devices": [
                    "G090XG07936518WL"
                ]
            }
        },
        "x": 1440,
        "y": 660,
        "wires": [
            []
        ]
    },
    {
        "id": "e56b1b4bfdd3e432",
        "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'/>Ciao,<break time='0.5s'/>\";\n\nmessage += \"la temperatura esterna è di <break time='0.1s'/>\"+temperature+ \"gradi celsius <break time='0.25s'/>\";\n\n// This the footer for the message\nmessage += \"<break time='0.75s'/> timeout tra un minuto \";\n\nmsg.payload = message;\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1120,
        "y": 660,
        "wires": [
            [
                "f3af5c6c1ae94823",
                "7f88b08aed61d571"
            ]
        ]
    },
    {
        "id": "baf5fe3e71a1b2fc",
        "type": "debug",
        "z": "fdedac607f20a384",
        "name": "6",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 590,
        "y": 460,
        "wires": []
    },
    {
        "id": "59a455c2845c1f98",
        "type": "debug",
        "z": "fdedac607f20a384",
        "name": "7",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 830,
        "y": 720,
        "wires": []
    },
    {
        "id": "7f88b08aed61d571",
        "type": "debug",
        "z": "fdedac607f20a384",
        "name": "11",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1090,
        "y": 720,
        "wires": []
    },
    {
        "id": "d3a282d36b3d0d32",
        "type": "function",
        "z": "fdedac607f20a384",
        "name": "",
        "func": "// Save the reading(s) in a flow variable\n\nflow.set(\"temperature\",msg.payload.BMP280.Temperature);\n\nreturn null;\n",
        "outputs": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 800,
        "y": 500,
        "wires": []
    },
    {
        "id": "08b43918836be61e",
        "type": "function",
        "z": "fdedac607f20a384",
        "name": "Prova di impostazione della temperatura a 21",
        "func": "flow.set(\"temperature\",msg.payload);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 910,
        "y": 560,
        "wires": [
            []
        ]
    },
    {
        "id": "84d618598d0b0934",
        "type": "inject",
        "z": "fdedac607f20a384",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "21",
        "payloadType": "num",
        "x": 610,
        "y": 560,
        "wires": [
            [
                "08b43918836be61e"
            ]
        ]
    },
    {
        "id": "c9173e06c5b4a993",
        "type": "inject",
        "z": "fdedac607f20a384",
        "name": "Fare clic per verificare il testo inviato ad Alexa",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 730,
        "y": 620,
        "wires": [
            [
                "e56b1b4bfdd3e432"
            ]
        ]
    },
    {
        "id": "47f699050b265e92",
        "type": "alexa-remote-account",
        "name": "opt",
        "authMethod": "proxy",
        "proxyOwnIp": "10.0.0.202",
        "proxyPort": "3456",
        "cookieFile": "authFile",
        "refreshInterval": "3",
        "alexaServiceHost": "alexa.amazon.it",
        "amazonPage": "amazon.it",
        "acceptLanguage": "it-IT",
        "userAgent": "",
        "useWsMqtt": "on",
        "autoInit": "on"
    },
    {
        "id": "22f544be.780a3c",
        "type": "mqtt-broker",
        "name": "Mosquitto",
        "broker": "10.0.0.202",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "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": {},
        "userProps": "",
        "sessionExpiry": ""
    }
]

To do this you need to either create a "virtual" thermostat device, or make use of the Q&A Skill, so that Alexa knows what you are asking it for.

I see your flow comes from this post trying-to-get-alexa-to-read-out-a-temperature

Did you read it all ?

It provides solutions and also links to another thread about the Q&A skill pure-fun-with-alexa-and-alexa-skills

ok thanks for the info. i solved it with the directions in this post Trying to get Alexa to read out a temperature - #41 by dynamicdave . Basically , it reads the mqtt info from the sensor, turns it into a voice command for alexa which announces it from echo device you are querying it from. I would also like to make it work from smartphone but I am not able to do that.

I have this problem ie, when the temperature is below zero , alexa does not read the

indication - (ex: -3.3grades) I think there is some problem in the function node:

// Get the flow variable(s) to be used in the message
var temperature = flow.get("temperature") || 0;

// Convert them to a string
temperature = temperature.toString();

//whisper message
var k, l;
if (msg.payload.Quiet == "On") {
  k = '   <amazon:effect name="whispered">'
  l = '   </amazon:effect>'
}
else {
  k = ""
  l = ""
}

var message = k+"la temperatura esterna è di <break time='0.5s'/>"+ temperature + "gradi celsius <break time='0.25s'/>"+l;


msg.payload = message;
return msg;

the debug output is correct and reports the minus sign but alexa does not pronounce it .

payload: "la temperatura esterna è di <break time='0.5s'/>-2.7gradi celsius <break time='0.25s'/>"
_msgid: "dd4492cd56ff7d98"

Does it need the word rather than the symbol?

in the way I wrote above the temperature announced by alexa is always positive, this morning for example we were the thermometer read -5 degrees but alexa announced 5 degrees above zero. I tried to write just so: var message = temperature ; and alexa correctly announces the temperature.
Of course , I would also like it to announce all the part of the message "the temperature is of " but it doesn't seem to work adding it.

Just tried this out and can agree with you it ignores 'saying' the minus.

If you insert a 'space' after temperature and before " gradi celsius........"
I think you will find it works correctly and says the word 'minus'.

I've modified the statement at the top of this post, so you can cut-n-paste it in to your code.

Please let me know if it works for you?

1 Like

thanks dave ; i modified as you said so it seems to work:

var temperature = flow.get("temperature") || 0;
temperature = temperature.toString();

var a = " la temperatura esterna è di <break time='0.1s'/>";
var b = " gradi celsius <break time='0.25s'/>";

//whisper message
var k, l;
if (msg.payload.Quiet == "On") {
    k = '   <amazon:effect name="whispered">'
    l = '   </amazon:effect>'
}
else {
    k = ""
    l = ""
}

var message = k+a+temperature+b+l;
msg.payload = message;
return msg;

here we are below zero and now alexa announces the temperature correctly !! :muscle:

1 Like

To read the daily power consumption always with a flow similar to the one above I had to round the today variable like this below.

Function
var today = flow.get("today") || 0;

var today = (today).toFixed(2);

today = today.toString();

var message = " i consumi giornalieri sono di <break time='0.5s'/> "+ today + " kilovattora <break time='0.25s'/> ";

msg.payload = message;
return msg;

This is because if alexa is given a variable with three decimal places it announces a number without the decimal point (ex: 5.436----> 5436) .It seems to work ,I would like to find information about it.

I'm continuing to refine the flow of external temperatures of Dave, I made alarm flow, which based on a certain temperature sends a voice alert with alexa and a telegram message, it all works. But I have an annoying effect, that is timing the 'iniect every 2 seconds, when I do a deploy or reboot the raspberry triggers the alarm; I've seen examples that use link in and link out but how can I use it if I'm using input values taken via MQTT ?

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