温度大小的比较的函数怎么表达


flows-2.json (2.1 KB)
想比较俩个温度的大小 弄了一晚上么有整明白,请大佬赐教

你的温度就是msg.payload。因为两个传过来的都是msg.payload,你可以在function前加两个转换,把msg.payload转成其他变量名,比如msg.wd1,msg.wd2。然后一起传个function,比较一下。

flows-2.json (2.1 KB)

能否帮忙写一下

[
    {
        "id": "b1435ae1.e80208",
        "type": "tab",
        "label": "流程1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "8fb17375.ab41b",
        "type": "ioBroker get",
        "z": "b1435ae1.e80208",
        "name": "DVES_CAB507 DS18B20-1  Temperature",
        "topic": "sonoff.0.DVES_CAB507.DS18B20-1_Temperature",
        "attrname": "payload1",
        "payloadType": "value",
        "x": 340,
        "y": 80,
        "wires": [
            [
                "a218c2ef.d6acf"
            ]
        ]
    },
    {
        "id": "350d3018.c9008",
        "type": "inject",
        "z": "b1435ae1.e80208",
        "name": "1",
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 90,
        "y": 140,
        "wires": [
            [
                "8fb17375.ab41b",
                "3484cb1d.3d2584"
            ]
        ]
    },
    {
        "id": "3484cb1d.3d2584",
        "type": "ioBroker get",
        "z": "b1435ae1.e80208",
        "name": "DVES_CAB507 DS18B20-2  Temperature",
        "topic": "sonoff.0.DVES_CAB507.DS18B20-2_Temperature",
        "attrname": "payload2",
        "payloadType": "value",
        "x": 340,
        "y": 180,
        "wires": [
            [
                "a218c2ef.d6acf"
            ]
        ]
    },
    {
        "id": "e12001c1.72d4",
        "type": "debug",
        "z": "b1435ae1.e80208",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 790,
        "y": 140,
        "wires": []
    },
    {
        "id": "a218c2ef.d6acf",
        "type": "function",
        "z": "b1435ae1.e80208",
        "name": "",
        "func": "if(msg.payload1 > msg.payload2){\n    msg.message = \"1>2\"\n}else{\n    msg.message = \"1<2\"\n}\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 630,
        "y": 140,
        "wires": [
            [
                "e12001c1.72d4"
            ]
        ]
    }
]

试试看