NOd red sonoff temp and humidity sensor

Hello to all.

I have some sonoff digital temp and humidity sensor. How could i make in red node a temp and humidity automation. I am unable to get the real time humidity and temperature.

I’m pretty sure the output of a device event node is a string of letters and so then you need to turn it into an Object. Then you put a change node to move the value you want (copy the link to where it is from a debug node using the copy link icon) to the main msg.payload. Then you will just have a number and can use a switch node to automate what you want.

finaly i got a temp, but is showing with 0,5 C in plus. :frowning:

I got a message that register-device: state should be JSON. how


Where is the problem, i dont know. now i cant see nothing

I don’t think I’ve ever created an only temperature device but I always create a settings or a default text in JSON format as per the eWeLInk API document with if you click the book icon near the debug icon will show you the documents for the selected node and the create device node icon has a link to the API. Sometimes you can get away without writing stuff though and leave it at {}.

What are you trying to achieve? I don’t understand the flow. If possible I avoid Function Nodes and just use the official calculator node to do basic maths. The calculator node is available in the palette manager.

Once you’ve created a device you need to send a particular template to the put-device-state node so just put a template node before it. At the bottom of that node is an option to send output as an object. It needs an object sent to it.

Hy. I wanna create more scenes with temp controling the trzvb. So i have in each room temp sensor and trzvb and i wanna make a temp control scenes.
So please if you can help me.

Warmest regards

If you have a real input device and a real output device you don’t need either the Register Device or the put-device-state node anywhere.

All you need to do is extract the temperature value from the out out of a device event node from the T/H sensor and control the TRV with a control device node.

Use the following nodes:

  1. device event from t/h sensor
  2. JSON node to convert a string to an object
    3 change node [move temperature from subcategory to being main payload]
  3. switch node (eg if above temperature of X output 1]
  4. control device node to control the TRV
    Plus lots of debug nodes to help troubleshoot. You can always turn them off when you’re happy with that node.

You can add a switch node to check the sting of letter contains “temperature” in between 1 and 2, a filter node between 3 and 4 to check it has changed to avoid wasted CPU cycles and a calculator node (multiply by 1 and output rounded to 0 decimal places) to check all changes are atleast 1 degree, but that is all optional. Once it is working you can add them.

So one more try. here is my flow. First event is the temp sensor, the second is the button/switch( virtual). I puted after the temp controller 2 logycal node. Because we have 2 outputs on the temp controller. the appaer is cooling, under is heating. How to do to be enabled this scene, just if the button is on. It is off i wanna turn off all trzvb-s. doesnt work brrrrr

Why is there a trigger node?


without debug nodes here is the node layout

[
    {
        "id": "ce6f29ccdd1ee8b2",
        "type": "control-device",
        "z": "b840efda68ba8fb9",
        "name": "TRV on",
        "server": "",
        "list": "",
        "category": "",
        "device": "",
        "v2Data": "{}",
        "x": 1720,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "b2522dddbbcbf78f",
        "type": "control-device",
        "z": "b840efda68ba8fb9",
        "name": "TRV off",
        "server": "",
        "list": "",
        "category": "",
        "device": "",
        "v2Data": "{}",
        "x": 1720,
        "y": 420,
        "wires": [
            []
        ]
    },
    {
        "id": "4048b889c7b32095",
        "type": "event-state",
        "z": "b840efda68ba8fb9",
        "name": "temperature",
        "server": "",
        "list": "",
        "category": "",
        "device": "",
        "state": "",
        "x": 330,
        "y": 220,
        "wires": [
            [
                "e3771954831180b4"
            ]
        ]
    },
    {
        "id": "b6dbdfd61f24f009",
        "type": "event-state",
        "z": "b840efda68ba8fb9",
        "name": "Switch",
        "server": "",
        "list": "",
        "category": "",
        "device": "",
        "state": "",
        "x": 310,
        "y": 360,
        "wires": [
            [
                "577885503ee09ee8"
            ]
        ]
    },
    {
        "id": "e3771954831180b4",
        "type": "json",
        "z": "b840efda68ba8fb9",
        "name": "",
        "property": "payload",
        "action": "obj",
        "pretty": false,
        "x": 490,
        "y": 220,
        "wires": [
            [
                "814babfb6aac9341"
            ]
        ]
    },
    {
        "id": "814babfb6aac9341",
        "type": "change",
        "z": "b840efda68ba8fb9",
        "name": "",
        "rules": [
            {
                "t": "move",
                "p": "payload.payload.temperature.temperature",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 800,
        "y": 220,
        "wires": [
            [
                "cb12fc19fb96d61d"
            ]
        ]
    },
    {
        "id": "cb12fc19fb96d61d",
        "type": "switch",
        "z": "b840efda68ba8fb9",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lt",
                "v": "25",
                "vt": "str"
            },
            {
                "t": "gte",
                "v": "25",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 1110,
        "y": 220,
        "wires": [
            [
                "8fefdb57b03aacc9"
            ],
            [
                "a4b4d1bd1bab26d5",
                "b2522dddbbcbf78f"
            ]
        ]
    },
    {
        "id": "8fefdb57b03aacc9",
        "type": "change",
        "z": "b840efda68ba8fb9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "temperature",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1280,
        "y": 200,
        "wires": [
            [
                "acf08111488abc0b"
            ]
        ]
    },
    {
        "id": "a4b4d1bd1bab26d5",
        "type": "change",
        "z": "b840efda68ba8fb9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "temperature",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1280,
        "y": 240,
        "wires": [
            [
                "acf08111488abc0b"
            ]
        ]
    },
    {
        "id": "577885503ee09ee8",
        "type": "switch",
        "z": "b840efda68ba8fb9",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "on",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 1110,
        "y": 360,
        "wires": [
            [
                "aad0ac013f2d9c3b"
            ],
            [
                "63584d2690f96a3e",
                "b2522dddbbcbf78f"
            ]
        ]
    },
    {
        "id": "acf08111488abc0b",
        "type": "BooleanLogicUltimate",
        "z": "b840efda68ba8fb9",
        "name": "AND gate",
        "payloadPropName": "payload",
        "filtertrue": "onlytrue",
        "persist": true,
        "sInitializeWith": "WaitForPayload",
        "triggertopic": "trigger",
        "outputtriggeredby": "all",
        "inputCount": 2,
        "topic": "result",
        "restrictinputevaluation": false,
        "delayEvaluation": 0,
        "translatorConfig": "",
        "x": 1530,
        "y": 280,
        "wires": [
            [
                "ce6f29ccdd1ee8b2"
            ],
            [],
            []
        ]
    },
    {
        "id": "aad0ac013f2d9c3b",
        "type": "change",
        "z": "b840efda68ba8fb9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "switch",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1280,
        "y": 340,
        "wires": [
            [
                "acf08111488abc0b"
            ]
        ]
    },
    {
        "id": "63584d2690f96a3e",
        "type": "change",
        "z": "b840efda68ba8fb9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "switch",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1280,
        "y": 380,
        "wires": [
            [
                "acf08111488abc0b"
            ]
        ]
    }
]

just import that code and setup ewelink nodes/add debug nodes

I want to start the messages just if the asociated virtual switch state is on. The controller send automatic messages. Here i can set histersy… How to insert an if, to check if the virtual button is turned on send message if not dont send, stop the flow

Outputs

This node has two outputs for controlling your cooler and heater. Both outputs emits a boolean to determine if your appliance should be turned on (true) or turned off (false). The first output represents the cooler, and the second output represents the heater. Messages are sent with topic cooling-controller and heating-controller respectively so you could merge them in your flow and use topic to distinguish.

who can help for me? :smiley:


How to open the gate node

who know why i got undefined error from this function node. The powerstate is ok, but the temp doesnt go out from function node

[
    {
        "id": "78f6133b785a2d23",
        "type": "tab",
        "label": "Flow 14",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "bdec0404730f3964",
        "type": "register-device",
        "z": "78f6133b785a2d23",
        "name": "At home heating",
        "server": "7220f2b5bd861769",
        "device_id": "0193ca22-9755-7454-842c-aaf61325b777",
        "device_name": "At home heating",
        "category": "switch",
        "capabilities": "null",
        "manufacturer": "SOnoff",
        "model": "Node red",
        "firmware_version": "1.1",
        "service_address": " 192.168.68.58",
        "tags": "{}",
        "state": "{\"power\":{\"powerState\":\"off\"}}",
        "capabilities_v2": "[{\"capability\":\"power\",\"permission\":\"1100\"}]",
        "x": 480,
        "y": 80,
        "wires": [
            [
                "855fb3e28d286371"
            ]
        ]
    },
    {
        "id": "a632d7ce8f8481ab",
        "type": "inject",
        "z": "78f6133b785a2d23",
        "name": "Initialize",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 220,
        "y": 80,
        "wires": [
            [
                "bdec0404730f3964"
            ]
        ]
    },
    {
        "id": "855fb3e28d286371",
        "type": "debug",
        "z": "78f6133b785a2d23",
        "name": "debug 139",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 710,
        "y": 80,
        "wires": []
    },
    {
        "id": "a1d15927aaf75a03",
        "type": "register-device",
        "z": "78f6133b785a2d23",
        "name": "At home cooling",
        "server": "7220f2b5bd861769",
        "device_id": "0193cbe1-a0c1-70f7-a8a9-b2f71426e1be",
        "device_name": "At home cooling",
        "category": "switch",
        "capabilities": "null",
        "manufacturer": "Sonoff",
        "model": "Node red",
        "firmware_version": "1.2",
        "service_address": "192.168.68.58",
        "tags": "{}",
        "state": "{\"power\":{\"powerState\":\"off\"}}",
        "capabilities_v2": "[{\"capability\":\"power\",\"permission\":\"1100\"}]",
        "x": 460,
        "y": 140,
        "wires": [
            [
                "8a05ec42c2689fbf"
            ]
        ]
    },
    {
        "id": "41579691e47f144b",
        "type": "inject",
        "z": "78f6133b785a2d23",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 240,
        "y": 120,
        "wires": [
            [
                "a1d15927aaf75a03"
            ]
        ]
    },
    {
        "id": "8a05ec42c2689fbf",
        "type": "debug",
        "z": "78f6133b785a2d23",
        "name": "debug 140",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 690,
        "y": 120,
        "wires": []
    },
    {
        "id": "b8105a53432e5737",
        "type": "event-state",
        "z": "78f6133b785a2d23",
        "name": "",
        "server": "7220f2b5bd861769",
        "list": "",
        "category": "switch",
        "device": "fff59808-b715-4ffc-b814-977dbe11c103",
        "state": "power",
        "x": 190,
        "y": 200,
        "wires": [
            [
                "feafaf5773aead42"
            ]
        ]
    },
    {
        "id": "feafaf5773aead42",
        "type": "switch",
        "z": "78f6133b785a2d23",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "on",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "off",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 390,
        "y": 200,
        "wires": [
            [
                "672487e588de0c57"
            ],
            [
                "98dd7fb21a8326c8"
            ]
        ]
    },
    {
        "id": "672487e588de0c57",
        "type": "control-device",
        "z": "78f6133b785a2d23",
        "name": "",
        "server": "7220f2b5bd861769",
        "list": "",
        "category": "switch",
        "device": "91cc78da-0208-45ef-a32d-705198072276",
        "v2Data": "{\"state\":{\"power\":{\"powerState\":\"on\"}}}",
        "x": 600,
        "y": 180,
        "wires": [
            [
                "757e6486efd504b3"
            ]
        ]
    },
    {
        "id": "98dd7fb21a8326c8",
        "type": "control-device",
        "z": "78f6133b785a2d23",
        "name": "",
        "server": "7220f2b5bd861769",
        "list": "",
        "category": "switch",
        "device": "91cc78da-0208-45ef-a32d-705198072276",
        "v2Data": "{\"state\":{\"power\":{\"powerState\":\"off\"}}}",
        "x": 600,
        "y": 220,
        "wires": [
            [
                "2fab2d3e75dbccd9"
            ]
        ]
    },
    {
        "id": "757e6486efd504b3",
        "type": "debug",
        "z": "78f6133b785a2d23",
        "name": "debug 141",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 790,
        "y": 180,
        "wires": []
    },
    {
        "id": "2fab2d3e75dbccd9",
        "type": "debug",
        "z": "78f6133b785a2d23",
        "name": "debug 142",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 790,
        "y": 220,
        "wires": []
    },
    {
        "id": "8b79a4fa2acdd734",
        "type": "event-state",
        "z": "78f6133b785a2d23",
        "name": "",
        "server": "7220f2b5bd861769",
        "list": "",
        "category": "temperatureAndHumiditySensor",
        "device": "0x28dba7fffe80ee6f",
        "state": "temperature",
        "x": 150,
        "y": 320,
        "wires": [
            [
                "370786494726fe1b"
            ]
        ]
    },
    {
        "id": "370786494726fe1b",
        "type": "json",
        "z": "78f6133b785a2d23",
        "name": "",
        "property": "payload",
        "action": "obj",
        "pretty": false,
        "x": 300,
        "y": 320,
        "wires": [
            [
                "2bfda539d1769b9d"
            ]
        ]
    },
    {
        "id": "2bfda539d1769b9d",
        "type": "change",
        "z": "78f6133b785a2d23",
        "name": "",
        "rules": [
            {
                "t": "move",
                "p": "payload.payload.temperature.temperature",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 600,
        "y": 320,
        "wires": [
            [
                "16e339ec7fd320f0"
            ]
        ]
    },
    {
        "id": "fedfbee4c4915324",
        "type": "event-state",
        "z": "78f6133b785a2d23",
        "name": "",
        "server": "7220f2b5bd861769",
        "list": "",
        "category": "switch",
        "device": "fff59808-b715-4ffc-b814-977dbe11c103",
        "state": "power",
        "x": 170,
        "y": 260,
        "wires": [
            [
                "5929f2acb1531d86"
            ]
        ]
    },
    {
        "id": "16e339ec7fd320f0",
        "type": "function",
        "z": "78f6133b785a2d23",
        "name": "function 10",
        "func": "if (msg.payload === \"on\") {\n    const temperature = msg.payload.payload.temperature.temperature;\n\n    // Ensure temperature is a number before assigning\n    if (typeof temperature === msg.payload ) {\n        msg.payload = msg.payload.payload.temperature.temperature;\n    } else {\n        console.error(\"Temperature is not a number:\", temperature);\n        delete msg.payload;\n    }\n} else {\n    // Heating is off, don't send any message\n    delete msg.payload;\n}\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 930,
        "y": 320,
        "wires": [
            [
                "8288b1c3e715bc64"
            ]
        ]
    },
    {
        "id": "763d02cd398bfa82",
        "type": "inject",
        "z": "78f6133b785a2d23",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 80,
        "y": 280,
        "wires": [
            [
                "2bfda539d1769b9d"
            ]
        ]
    },
    {
        "id": "8288b1c3e715bc64",
        "type": "debug",
        "z": "78f6133b785a2d23",
        "name": "debug 145",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1170,
        "y": 200,
        "wires": []
    },
    {
        "id": "7bf799bf0f293d49",
        "type": "change",
        "z": "78f6133b785a2d23",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 600,
        "y": 260,
        "wires": [
            [
                "16e339ec7fd320f0"
            ]
        ]
    },
    {
        "id": "5929f2acb1531d86",
        "type": "json",
        "z": "78f6133b785a2d23",
        "name": "",
        "property": "payload",
        "action": "obj",
        "pretty": false,
        "x": 330,
        "y": 260,
        "wires": [
            [
                "7bf799bf0f293d49"
            ]
        ]
    },
    {
        "id": "7220f2b5bd861769",
        "type": "api-server",
        "name": "Ihost",
        "ip": "ihost-1002094200.local",
        "ipaddr": "192.168.68.53",
        "token": "958d6609-5f01-4e7d-a531-9c409bf56663"
    }
]