How to change the LED color when the alarm goes off due to rising temperature

Hello.

I’m using sensors for NCD products On NODE-RED, the alarm sounds when the temperature value of the sensor is higher than the set temperature value.
If the alarm goes off and the default color of the LED is green, if the temperature is higher than the set temperature, the alarm goes off together and you want to change the color of the LED to red.

Please help me

Hi,

It sounds like you are using one of our temperature sensors to monitor an asset and are using a Node-Red Dashboard widget LED to indicate pass or fail state of the temperature. Have you created a Node-Red flow yet? If so can you export that Node-Red flow and share it? If you do not have anything yet let me know and I can put together an example for you.

[
    {
        "id": "9576c84fc05fba48",
        "type": "play audio",
        "z": "c7f311b561d11f73",
        "name": "",
        "voice": "0",
        "x": 1210,
        "y": 1140,
        "wires": []
    },
    {
        "id": "59d6f528028e9030",
        "type": "change",
        "z": "c7f311b561d11f73",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "\"Sensor \" & (msg.payload.addr) & \" battery warning\"\t",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 980,
        "y": 1060,
        "wires": [
            [
                "6ce686c110da4464",
                "9576c84fc05fba48"
            ]
        ]
    },
    {
        "id": "fcc79c5b85608fba",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "Set temperature limits",
        "property": "payload_data.battery",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lt",
                "v": "0",
                "vt": "str"
            },
            {
                "t": "gt",
                "v": "2",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 720,
        "y": 980,
        "wires": [
            [
                "59d6f528028e9030"
            ],
            [
                "59d6f528028e9030"
            ]
        ]
    },
    {
        "id": "6ce686c110da4464",
        "type": "debug",
        "z": "c7f311b561d11f73",
        "name": "debug 47",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1220,
        "y": 1080,
        "wires": []
    },
    {
        "id": "c9776bc6f8e1e143",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "Limit to Type 80",
        "property": "payload_type",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "80",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 480,
        "y": 960,
        "wires": [
            [
                "fcc79c5b85608fba"
            ]
        ]
    },
    {
        "id": "62e6cca397d10a0a",
        "type": "ncd-gateway-node",
        "z": "c7f311b561d11f73",
        "name": "",
        "connection": "e69d0ec8c02da9b1",
        "unknown_devices": false,
        "outputs": 1,
        "x": 170,
        "y": 600,
        "wires": [
            [
                "8786d56e7500f219",
                "c9776bc6f8e1e143",
                "b59f324404e127c6",
                "fa92b63bfa0505ed",
                "9ba3716add53a55e",
                "148a32035db48ed2"
            ]
        ]
    },
    {
        "id": "8786d56e7500f219",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "Limit to Type 80",
        "property": "payload.sensor_type",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "80",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 480,
        "y": 720,
        "wires": [
            [
                "3e57dace527138b2",
                "7f9c386269e249e2",
                "a96407ea593cbe8a"
            ]
        ]
    },
    {
        "id": "b59f324404e127c6",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "Limit to Type 80",
        "property": "payload.sensor_type",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "80",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 460,
        "y": 440,
        "wires": [
            [
                "620598867c3564f1"
            ]
        ]
    },
    {
        "id": "fa92b63bfa0505ed",
        "type": "debug",
        "z": "c7f311b561d11f73",
        "name": "debug 48",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 440,
        "y": 320,
        "wires": []
    },
    {
        "id": "9ba3716add53a55e",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "Limit to Type 80",
        "property": "payload.sensor_type",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "80",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 100,
        "y": 160,
        "wires": [
            [
                "f1a8611ec698886c"
            ]
        ]
    },
    {
        "id": "148a32035db48ed2",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "Limit to Type 80",
        "property": "payload.sensor_type",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "80",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 480,
        "y": 1080,
        "wires": [
            [
                "57d8bca623128d14"
            ]
        ]
    },
    {
        "id": "3e57dace527138b2",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "Set temperature limits",
        "property": "payload.sensor_data.x_rms_ACC_G",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lte",
                "v": "-5",
                "vt": "str"
            },
            {
                "t": "gte",
                "v": "30",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 740,
        "y": 720,
        "wires": [
            [
                "732fb2bb4e6eaa80"
            ],
            [
                "732fb2bb4e6eaa80"
            ]
        ]
    },
    {
        "id": "7f9c386269e249e2",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "Set temperature limits",
        "property": "payload.sensor_data.y_rms_ACC_G",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lte",
                "v": "-5",
                "vt": "str"
            },
            {
                "t": "gte",
                "v": "30",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 740,
        "y": 820,
        "wires": [
            [
                "75bcc56541b2f87a"
            ],
            [
                "75bcc56541b2f87a"
            ]
        ]
    },
    {
        "id": "a96407ea593cbe8a",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "Set temperature limits",
        "property": "payload.sensor_data.z_rms_ACC_G",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lte",
                "v": "-5",
                "vt": "str"
            },
            {
                "t": "gte",
                "v": "30",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 740,
        "y": 900,
        "wires": [
            [
                "1e311fe9b4d37638"
            ],
            [
                "1e311fe9b4d37638"
            ]
        ]
    },
    {
        "id": "620598867c3564f1",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "Set temperature limits",
        "property": "payload.sensor_data.temperature",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lt",
                "v": "0",
                "vt": "str"
            },
            {
                "t": "gt",
                "v": "30",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 720,
        "y": 380,
        "wires": [
            [
                "4c7f33789ca7c3dd"
            ],
            [
                "4c7f33789ca7c3dd"
            ]
        ]
    },
    {
        "id": "f1a8611ec698886c",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "Set temperature limits",
        "property": "payload.sensor_data.temperature",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lt",
                "v": "0",
                "vt": "str"
            },
            {
                "t": "gt",
                "v": "20",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 380,
        "y": 80,
        "wires": [
            [
                "0981ef9f82b4f128"
            ],
            [
                "0981ef9f82b4f128"
            ]
        ]
    },
    {
        "id": "57d8bca623128d14",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "Set temperature limits",
        "property": "payload.sensor_data.y_rms_ACC_G",
        "propertyType": "msg",
        "rules": [
            {
                "t": "lte",
                "v": "-5",
                "vt": "str"
            },
            {
                "t": "gte",
                "v": "30",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 720,
        "y": 1080,
        "wires": [
            [
                "1fb67de8539a66ee"
            ],
            [
                "1fb67de8539a66ee"
            ]
        ]
    },
    {
        "id": "732fb2bb4e6eaa80",
        "type": "change",
        "z": "c7f311b561d11f73",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "\"Sensor \" & (msg.payload.addr) & \" x_rms_ACC_G warning\"\t",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1000,
        "y": 720,
        "wires": [
            [
                "c08bfffb2cfdd8b5",
                "ce55fad01b0fdc81"
            ]
        ]
    },
    {
        "id": "75bcc56541b2f87a",
        "type": "change",
        "z": "c7f311b561d11f73",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "\"Sensor \" & (msg.payload.addr) & \" y_rms_ACC_G warning\"\t",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1000,
        "y": 820,
        "wires": [
            [
                "6f87d81ef73d57dc",
                "1cdf22ca0bfa782c"
            ]
        ]
    },
    {
        "id": "1e311fe9b4d37638",
        "type": "change",
        "z": "c7f311b561d11f73",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "\"Sensor \" & (msg.payload.addr) & \" z_rms_ACC_G warning\"\t",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1000,
        "y": 900,
        "wires": [
            [
                "ea3ac57bc63bb859",
                "be3d473f26b90abe"
            ]
        ]
    },
    {
        "id": "4c7f33789ca7c3dd",
        "type": "change",
        "z": "c7f311b561d11f73",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "\"Sensor \" & (msg.payload.addr) & \" 1D온도센서오류\"",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 940,
        "y": 380,
        "wires": [
            [
                "88a786641233d073",
                "eab249c4c1bd0a77",
                "93cc2b40ca04753f"
            ]
        ]
    },
    {
        "id": "0981ef9f82b4f128",
        "type": "change",
        "z": "c7f311b561d11f73",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "\"Sensor \" & (msg.payload.addr) & \" 1D온도센서오류\"",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 600,
        "y": 40,
        "wires": [
            [
                "4a79585c9bca2479"
            ]
        ]
    },
    {
        "id": "1fb67de8539a66ee",
        "type": "change",
        "z": "c7f311b561d11f73",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "\"Sensor \" & (msg.payload.addr) & \" x_rms_ACC_G warning\"\t",
                "tot": "jsonata"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "\"Sensor \" & (msg.payload.addr) & \" y_rms_ACC_G warning\"",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "\"Sensor \" & (msg.payload.addr) & \" z_rms_ACC_G warning\"",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 960,
        "y": 1140,
        "wires": [
            []
        ]
    },
    {
        "id": "c08bfffb2cfdd8b5",
        "type": "debug",
        "z": "c7f311b561d11f73",
        "name": "debug 49",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1220,
        "y": 640,
        "wires": []
    },
    {
        "id": "ce55fad01b0fdc81",
        "type": "play audio",
        "z": "c7f311b561d11f73",
        "name": "",
        "voice": "0",
        "x": 1250,
        "y": 700,
        "wires": []
    },
    {
        "id": "6f87d81ef73d57dc",
        "type": "debug",
        "z": "c7f311b561d11f73",
        "name": "debug 50",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1260,
        "y": 780,
        "wires": []
    },
    {
        "id": "1cdf22ca0bfa782c",
        "type": "play audio",
        "z": "c7f311b561d11f73",
        "name": "",
        "voice": "0",
        "x": 1270,
        "y": 840,
        "wires": []
    },
    {
        "id": "ea3ac57bc63bb859",
        "type": "debug",
        "z": "c7f311b561d11f73",
        "name": "debug 51",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1240,
        "y": 940,
        "wires": []
    },
    {
        "id": "be3d473f26b90abe",
        "type": "play audio",
        "z": "c7f311b561d11f73",
        "name": "",
        "voice": "0",
        "x": 1230,
        "y": 1000,
        "wires": []
    },
    {
        "id": "88a786641233d073",
        "type": "play audio",
        "z": "c7f311b561d11f73",
        "name": "",
        "voice": "0",
        "x": 1230,
        "y": 420,
        "wires": []
    },
    {
        "id": "eab249c4c1bd0a77",
        "type": "debug",
        "z": "c7f311b561d11f73",
        "name": "debug 52",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1180,
        "y": 360,
        "wires": []
    },
    {
        "id": "93cc2b40ca04753f",
        "type": "ui_text_input",
        "z": "c7f311b561d11f73",
        "name": "",
        "label": "",
        "tooltip": "",
        "group": "edb876bc2485de7b",
        "order": 11,
        "width": 0,
        "height": 0,
        "passthru": true,
        "mode": "text",
        "delay": 300,
        "topic": "topic",
        "topicType": "msg",
        "x": 1260,
        "y": 480,
        "wires": [
            []
        ]
    },
    {
        "id": "4a79585c9bca2479",
        "type": "trigger",
        "z": "c7f311b561d11f73",
        "name": "blink blue",
        "op1": "colors.led.blue",
        "op2": "colors.led.off",
        "op1type": "global",
        "op2type": "global",
        "duration": "250",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 820,
        "y": 60,
        "wires": [
            [
                "e677e442b4934d9d"
            ]
        ]
    },
    {
        "id": "e677e442b4934d9d",
        "type": "ui_template",
        "z": "c7f311b561d11f73",
        "group": "edb876bc2485de7b",
        "name": "",
        "order": 1,
        "width": "3",
        "height": "3",
        "format": "<style>\n.led {\n    position:absolute;\n    width: 50px;\n    height: 50px;\n    margin: auto;\n    border-radius: 50%;\n}\n</style>\n\n<div><span class=\"led\" style=\"background-color: {{msg.payload}}; box-shadow: #000000BB 0 -1px 1px 0px, inset #000000AA  0 -1px 4px, {{msg.payload}} 0 3px 15px;\"></span></div>",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "x": 1020,
        "y": 60,
        "wires": [
            [
                "d48d9add6d75dbe0"
            ]
        ]
    },
    {
        "id": "bb5b6ebfeca18b38",
        "type": "trigger",
        "z": "c7f311b561d11f73",
        "name": "blink red",
        "op1": "colors.led.red",
        "op2": "colors.led.off",
        "op1type": "global",
        "op2type": "global",
        "duration": "250",
        "extend": false,
        "overrideDelay": false,
        "units": "ms",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 820,
        "y": 120,
        "wires": [
            [
                "e677e442b4934d9d"
            ]
        ]
    },
    {
        "id": "d48d9add6d75dbe0",
        "type": "switch",
        "z": "c7f311b561d11f73",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "colors.led.blue",
                "vt": "global"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 1170,
        "y": 60,
        "wires": [
            [
                "b2944f95f5c0e52c"
            ]
        ]
    },
    {
        "id": "b2944f95f5c0e52c",
        "type": "delay",
        "z": "c7f311b561d11f73",
        "name": "",
        "pauseType": "random",
        "timeout": "300",
        "timeoutUnits": "milliseconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "200",
        "randomLast": "500",
        "randomUnits": "milliseconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 680,
        "y": 120,
        "wires": [
            [
                "bb5b6ebfeca18b38"
            ]
        ]
    },
    {
        "id": "e69d0ec8c02da9b1",
        "type": "ncd-gateway-config",
        "name": "",
        "comm_type": "serial",
        "ip_address": "",
        "tcp_port": "2101",
        "port": "COM3",
        "baudRate": "115200",
        "pan_id": "7fff",
        "rssi": false
    },
    {
        "id": "edb876bc2485de7b",
        "type": "ui_group",
        "name": "A-1",
        "tab": "2b1876438ce56d83",
        "order": 1,
        "disp": true,
        "width": 8,
        "collapse": false
    },
    {
        "id": "2b1876438ce56d83",
        "type": "ui_tab",
        "name": "Main SCREEN",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

Thank you. I’ll post the chords
Can I get an example JSON file?

I don’t believe the msg.payload is being set correctly when being passed to the input of your template node. Here is a simple example that just changes the color of the LED widget. Maybe it will help you accomplish what you are trying to do.

[
    {
        "id": "957395e842a759c9",
        "type": "inject",
        "z": "69ce12e2f2a6adf6",
        "name": "Green",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "#ABFF00",
        "payloadType": "str",
        "x": 950,
        "y": 1140,
        "wires": [
            [
                "bab4bc6cafbd53cf"
            ]
        ]
    },
    {
        "id": "aac6b5d1abd3627f",
        "type": "inject",
        "z": "69ce12e2f2a6adf6",
        "name": "Blue",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "#24E0FF",
        "payloadType": "str",
        "x": 950,
        "y": 1180,
        "wires": [
            [
                "bab4bc6cafbd53cf"
            ]
        ]
    },
    {
        "id": "bab4bc6cafbd53cf",
        "type": "ui_template",
        "z": "69ce12e2f2a6adf6",
        "group": "edb876bc2485de7b",
        "name": "",
        "order": 1,
        "width": "3",
        "height": "3",
        "format": "<style>\n.led {\n    position:absolute;\n    width: 50px;\n    height: 50px;\n    margin: auto;\n    border-radius: 50%;\n}\n</style>\n\n<div><span class=\"led\" style=\"background-color:{{msg.payload}}; box-shadow: #000000BB 0 -1px 1px 0px, inset #000000AA  0 -1px 4px, {{msg.payload}} 0 3px 15px;\"></span></div>",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "resendOnRefresh": false,
        "templateScope": "local",
        "className": "",
        "x": 1160,
        "y": 1220,
        "wires": [
            [
                "6bd949a8c8766714"
            ]
        ]
    },
    {
        "id": "edb876bc2485de7b",
        "type": "ui_group",
        "name": "A-1",
        "tab": "2b1876438ce56d83",
        "order": 1,
        "disp": true,
        "width": 8,
        "collapse": false
    },
    {
        "id": "2b1876438ce56d83",
        "type": "ui_tab",
        "name": "Main SCREEN",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]

Thank you.
Just one more thing. Can I ask you a favor?

In the case of LEDs, the warning light should be turned on when the motor temperature rises and vibrations are severe, so it doesn’t matter if you don’t distinguish colors, but I hope you can make or correct the wrong part by looking at Json.

You can add a second switch node to the output of the set temperature limit node which will check the vibration readings or you can simply add additional conditions to the set temperature Node which checks the vibration readings. Is this what you are asking?