# Need help to output sensor's temperature value on demand

**URL:** <https://discourse.nodered.org/t/need-help-to-output-sensors-temperature-value-on-demand/59625>\
**Category:** General\
**Tags:** http-request, mqtt\
**Created:** [10 March 2022 00:31 UTC](https://discourse.nodered.org/t/need-help-to-output-sensors-temperature-value-on-demand/59625 "2022-03-10T00:31:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Solid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/solid/32/57285_2.png) [@Solid](https://discourse.nodered.org/u/Solid)\
**Post date:** [10 March 2022 00:31 UTC](https://discourse.nodered.org/t/need-help-to-output-sensors-temperature-value-on-demand/59625/1 "2022-03-10T00:31:05Z")

</div>

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?

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

```

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 March 2022 08:37 UTC](https://discourse.nodered.org/t/need-help-to-output-sensors-temperature-value-on-demand/59625/2 "2022-03-10T08:37:41Z")

</div>

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...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/f/0f32a6bb1043fba65e5ca227a13178d33a9e9c8a.png)

PS, you can view what is in context using the sidebar (prss the refresh to get latest values)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/5/753b1650b7a25312d4c891c5b91c653c4634d61c.png)  
e

---

<div class="post-metadata">

**Author:** ![Solid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/solid/32/57285_2.png) [@Solid](https://discourse.nodered.org/u/Solid)\
**Post date:** [13 March 2022 20:19 UTC](https://discourse.nodered.org/t/need-help-to-output-sensors-temperature-value-on-demand/59625/3 "2022-03-13T20:19:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 May 2022 20:19 UTC](https://discourse.nodered.org/t/need-help-to-output-sensors-temperature-value-on-demand/59625/4 "2022-05-12T20:19:23Z")

</div>

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