Need help to output sensor's temperature value on demand

he flow that I have the problem is called TextToSpeech

As you can see value of payload.SI7021.Temperature is from the mqtt node
tele/tasmota_D7C816/SENSOR and when the sensor outputs the value(every 5 min) the text to speech api I use is working but I want to do that on demand.

When an intent is recognized the value of Temperature to be outputed into the flow.Tried connecting the mqtt out with the template node but nothing changed. What can I do?

[
    {
        "id": "2fdcfb6ff631c8a6",
        "type": "tab",
        "label": "Text to Speech-Speech to Text",
        "disabled": false,
        "info": ""
    },
    {
        "id": "22cce0801d07e859",
        "type": "websocket in",
        "z": "2fdcfb6ff631c8a6",
        "name": "Προτάσεις",
        "server": "",
        "client": "be111083.116b5",
        "x": 120,
        "y": 220,
        "wires": [
            [
                "be6c65fc7a64212d"
            ]
        ]
    },
    {
        "id": "be6c65fc7a64212d",
        "type": "switch",
        "z": "2fdcfb6ff631c8a6",
        "name": "διαχωρισμός",
        "property": "intent.name",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "GetTime",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "ChangeLightState",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "GetTemperature",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 330,
        "y": 220,
        "wires": [
            [
                "0d4881177991f65a"
            ],
            [
                "2ce419e57abd905e"
            ],
            [
                "58d7f622e62daf0a"
            ]
        ]
    },
    {
        "id": "d0ea8afef9040e6c",
        "type": "http request",
        "z": "2fdcfb6ff631c8a6",
        "name": "Ομιλία",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://192.168.1.14:12101/api/text-to-speech",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "basic",
        "senderr": false,
        "x": 750,
        "y": 220,
        "wires": [
            [
                "1561442e0ce9bb92"
            ]
        ]
    },
    {
        "id": "2ce419e57abd905e",
        "type": "template",
        "z": "2fdcfb6ff631c8a6",
        "name": "light text",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "Το  φως του {{ slots.name }} {{ slots.state }}.",
        "output": "str",
        "x": 560,
        "y": 280,
        "wires": [
            [
                "d0ea8afef9040e6c"
            ]
        ]
    },
    {
        "id": "0d4881177991f65a",
        "type": "function",
        "z": "2fdcfb6ff631c8a6",
        "name": "time text",
        "func": "var timeString = new Date().toLocaleTimeString([],\n{\n    hour: \"2-digit\", \n    minute: \"2-digit\",\n    hour12: true\n})\n\nreturn {\n    payload: \"Η ώρα είναι \" + timeString\n}",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 560,
        "y": 160,
        "wires": [
            [
                "d0ea8afef9040e6c"
            ]
        ]
    },
    {
        "id": "1561442e0ce9bb92",
        "type": "debug",
        "z": "2fdcfb6ff631c8a6",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 950,
        "y": 260,
        "wires": []
    },
    {
        "id": "58d7f622e62daf0a",
        "type": "template",
        "z": "2fdcfb6ff631c8a6",
        "name": "",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "Η θερμοκρασία είναι: {{payload.SI7021.Temperature}}.\n\n",
        "output": "str",
        "x": 560,
        "y": 360,
        "wires": [
            [
                "d0ea8afef9040e6c"
            ]
        ]
    },
    {
        "id": "8681a9dfc275864b",
        "type": "mqtt in",
        "z": "2fdcfb6ff631c8a6",
        "name": "",
        "topic": "tele/tasmota_D7C816/SENSOR",
        "qos": "2",
        "datatype": "json",
        "broker": "403eda9f.2bcee4",
        "nl": false,
        "rap": false,
        "inputs": 0,
        "x": 170,
        "y": 340,
        "wires": [
            [
                "58d7f622e62daf0a"
            ]
        ]
    },
    {
        "id": "be111083.116b5",
        "type": "websocket-client",
        "path": "ws://192.168.1.14:12101/api/events/intent",
        "tls": "",
        "wholemsg": "true",
        "hb": "0",
        "subprotocol": ""
    },
    {
        "id": "403eda9f.2bcee4",
        "type": "mqtt-broker",
        "name": "Home thesis",
        "broker": "192.168.1.14",
        "port": "1883",
        "clientid": "node-red",
        "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": {},
        "sessionExpiry": ""
    }
]

One the MQTT msg has passed through the template it is gone. So you need to store the MQTT value somewhere for later use. Thats where FLOW and GLOBAL context come in handy.

Here is some notes for you...

PS, you can view what is in context using the sidebar (prss the refresh to get latest values)
image
e

That really solved my problem and helped with my diploma thesis.Thank you very much

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