Get object params value

When I say an instruction to the google assistant, ("set roomterm thermostat 25"), I get a response in node red. :

Roomterm : msg.payload : Object
object
command: "action.devices.commands.ThermostatTemperatureSetpoint"
params: object
thermostatTemperatureSetpoint: 18
online: true

I want to compare the value (18) of this response with the data from the dht11 thermometer sensor. If it is smaller, it is ON, if it is larger it is OFF

That sounds like a typical simple control system with two inputs and one output.
e.g. dht11 and thermostat and I assume a signal to control a boiler/heater/cooler.

Can you post your flow so we can see what you have created so far ?

[
    {
        "id": "680004bc8e5431d1",
        "type": "tab",
        "label": "Flow 12",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "5e4c5dbb52e00e21",
        "type": "http request",
        "z": "680004bc8e5431d1",
        "name": "HƐMÉRSÉKLET",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://192.168.5.240/cm?cmnd=cmnd/temp/GlobalTemp",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "basic",
        "senderr": false,
        "x": 510,
        "y": 260,
        "wires": [
            [
                "b3f95ac789145f94"
            ]
        ]
    },
    {
        "id": "49907e55c23a0256",
        "type": "inject",
        "z": "680004bc8e5431d1",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 220,
        "y": 160,
        "wires": [
            [
                "5e4c5dbb52e00e21",
                "ebb9967a342bbcb0"
            ]
        ]
    },
    {
        "id": "b3f95ac789145f94",
        "type": "change",
        "z": "680004bc8e5431d1",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$substring(payload,14,4)",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 760,
        "y": 260,
        "wires": [
            [
                "47771fc32d80208f",
                "50d6787ab46254f3"
            ]
        ]
    },
    {
        "id": "ebb9967a342bbcb0",
        "type": "http request",
        "z": "680004bc8e5431d1",
        "name": "PÁRATARTALOM",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://192.168.5.240/cm?cmnd=cmnd/temp/GlobalHum",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "basic",
        "senderr": false,
        "x": 510,
        "y": 100,
        "wires": [
            [
                "da9d633199d4fa97"
            ]
        ]
    },
    {
        "id": "da9d633199d4fa97",
        "type": "change",
        "z": "680004bc8e5431d1",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$substring(payload,13,4)",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1000,
        "y": 100,
        "wires": [
            [
                "cbc09ed8712eaa55",
                "df3861bf43df16b5"
            ]
        ]
    },
    {
        "id": "3ad8f862a2ac967c",
        "type": "ui_gauge",
        "z": "680004bc8e5431d1",
        "name": "",
        "group": "9fd3364b.b2963",
        "order": 1,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "HƑmĂ©rsĂ©klet",
        "label": "°C",
        "format": "{{value}}",
        "min": "-20",
        "max": "50",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "className": "",
        "x": 1230,
        "y": 200,
        "wires": []
    },
    {
        "id": "cbc09ed8712eaa55",
        "type": "ui_gauge",
        "z": "680004bc8e5431d1",
        "name": "",
        "group": "9fd3364b.b2963",
        "order": 3,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "PĂĄratartalom ",
        "label": "%",
        "format": "{{value}}",
        "min": 0,
        "max": "100",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "className": "",
        "x": 1230,
        "y": 60,
        "wires": []
    },
    {
        "id": "5c74b25146f681ca",
        "type": "ui_chart",
        "z": "680004bc8e5431d1",
        "name": "",
        "group": "9fd3364b.b2963",
        "order": 2,
        "width": 0,
        "height": 0,
        "label": "HƑmĂ©rsĂ©klet",
        "chartType": "line",
        "legend": "false",
        "xformat": "auto",
        "interpolate": "linear",
        "nodata": "",
        "dot": true,
        "ymin": "-20",
        "ymax": "50",
        "removeOlder": "3",
        "removeOlderPoints": "",
        "removeOlderUnit": "86400",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 1230,
        "y": 260,
        "wires": [
            []
        ]
    },
    {
        "id": "df3861bf43df16b5",
        "type": "ui_chart",
        "z": "680004bc8e5431d1",
        "name": "",
        "group": "9fd3364b.b2963",
        "order": 3,
        "width": 0,
        "height": 0,
        "label": "PĂĄratartalom ",
        "chartType": "line",
        "legend": "false",
        "xformat": "auto",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "15",
        "ymax": "100",
        "removeOlder": "3",
        "removeOlderPoints": "",
        "removeOlderUnit": "86400",
        "cutout": 0,
        "useOneColor": false,
        "useUTC": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "outputs": 1,
        "useDifferentColor": false,
        "className": "",
        "x": 1230,
        "y": 120,
        "wires": [
            []
        ]
    },
    {
        "id": "47771fc32d80208f",
        "type": "change",
        "z": "680004bc8e5431d1",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "$szobatemp := $number(payload) - $number(10)",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1000,
        "y": 260,
        "wires": [
            [
                "51ffc3075efd5824",
                "3ad8f862a2ac967c",
                "5c74b25146f681ca"
            ]
        ]
    },
    {
        "id": "51ffc3075efd5824",
        "type": "debug",
        "z": "680004bc8e5431d1",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1230,
        "y": 320,
        "wires": []
    },
    {
        "id": "50d6787ab46254f3",
        "type": "function",
        "z": "680004bc8e5431d1",
        "name": "",
        "func": "let myValue = msg.payload.params.thermostatTemperatureSetPoint;\n//msg.payload = Number(msg.payload)-10; \nif (Number(msg.payload)-10 < myValue) \n{msg.payload = \"on\";}\nelse {\n  {msg.payload = \"off\"}\n}\nreturn [msg, msg.myValue];",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1020,
        "y": 440,
        "wires": [
            [
                "c5910488841ea14b",
                "9b75d20a60b2194f"
            ]
        ]
    },
    {
        "id": "c5910488841ea14b",
        "type": "debug",
        "z": "680004bc8e5431d1",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1230,
        "y": 480,
        "wires": []
    },
    {
        "id": "9b75d20a60b2194f",
        "type": "mqtt out",
        "z": "680004bc8e5431d1",
        "name": "",
        "topic": "cmnd/temper/POWER",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "814b9bd3b9b0f4fd",
        "x": 1260,
        "y": 400,
        "wires": []
    },
    {
        "id": "3fe05a340decb10b",
        "type": "google-home",
        "z": "680004bc8e5431d1",
        "conf": "ea2a8cbe09dae149",
        "device": "20986",
        "acknowledge": false,
        "name": "Roomterm",
        "topic": "Roomterm",
        "x": 420,
        "y": 460,
        "wires": [
            [
                "50d6787ab46254f3",
                "c5910488841ea14b"
            ]
        ]
    },
    {
        "id": "9fd3364b.b2963",
        "type": "ui_group",
        "name": "DHT11",
        "tab": "c8c249f2.8df858",
        "order": 5,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "814b9bd3b9b0f4fd",
        "type": "mqtt-broker",
        "name": "RPI-MQTT",
        "broker": "127.0.0.1",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "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": "ea2a8cbe09dae149",
        "type": "google-home-conf",
        "username": "azxo1"
    },
    {
        "id": "c8c249f2.8df858",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

The DHT11 is a tasmota device ? You can get the value in JSON without the need for substrings and it is easier to get the value via mqtt, but ok http request works too.

You will need to store the temperature into a flow/global/node context variable and compare the google value against it. The function node acts on the message that arrives on the node, one by one, so you cannot send 2 values and compare, it requires the value to be stored.

rough example (so you don't have to connect the change node to the function node):

function node:

let googleInput = parseInt(msg.payload)
msg.payload = (googleInput > flow.get("temperature")) ? "on" : "off"

return msg;
1 Like

When I asked for your flow and input, your reply was

You still have not given inputs, why?

If you had shown your flow earlier when asked, we could have seen that the message is infact two messages. These will need to be stored (@bakman2 reply) or joined as in the example below

[{"id":"233abfc.c8ab34","type":"inject","z":"680004bc8e5431d1","name":"google","props":[{"p":"payload.params.thermostatTemperatureSetpoint","v":"20","vt":"num"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"google","x":660,"y":440,"wires":[["4bfcbe29.2f294"]]},{"id":"4bfcbe29.2f294","type":"join","z":"680004bc8e5431d1","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":860,"y":420,"wires":[["50d6787ab46254f3"]]},{"id":"49907e55c23a0256","type":"inject","z":"680004bc8e5431d1","name":"dht11","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"dht11","payload":"24","payloadType":"num","x":650,"y":360,"wires":[["4bfcbe29.2f294"]]},{"id":"50d6787ab46254f3","type":"function","z":"680004bc8e5431d1","name":"","func":"let myValue = msg.payload.google.params.thermostatTemperatureSetpoint;\nmsg.payload = Number(msg.payload.dht11)-10; \nif (msg.payload < myValue) \n{msg.payload = \"on\";}\nelse {\n  {msg.payload = \"off\"}\n}\nreturn [msg, msg.myValue];","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1010,"y":420,"wires":[["c5910488841ea14b"]]},{"id":"c5910488841ea14b","type":"debug","z":"680004bc8e5431d1","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1190,"y":420,"wires":[]}]

notice the two messages have distinctive topics, for the join, and how they are referenced later in the function.
I have had to guess the incoming dht11 message as still you have not shown an example of it.

p.s. you still are referncing msg.payload.params.thermostatTemperatureSetPoint wrong it should be msg.payload.params.thermostatTemperatureSetpoint small p

That would be the question:
Hi! Please help!
How to get any object params value?
params

We strayed a little from the original question. And I misinterpreted your answer. Thank you very much! Of course it works. I can already compare this value with the DHT11 Tasmota thermometer data and perform various operations with it. I'm sorry, I still don't speak English. (Google translator)
:slight_smile:

Why do you keep repeating the same (previously answered) question over and over ?

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