Not all UI Switches are updating Status

Newbie here.

I am working on a simple project that turns relays on/off via the dashboard. I also want to set the relays ON via an automated script to turn on at a specific time in the morning. Using the Inject node, I can get the event to occur but ONLY the 1st relay will show the status correctly on the UI -- the other 3 execute the command properly but DON'T change the switch state on the UI. See screenshots below:

I've spent lots of time reviewing the settings for each UI switch and input trying to make sure they are all the same. Here are the settings on Relay 1. They are the same for relay 2, 3, 4.

Any help is appreciated!

Thanks,
Tom

1 Like

Here is the NR flow where you can see the statuses of the relays all ON..

You did not share the configuration of the inject node. My best guess is that the payload received by the ui_switch node is not matching the data type configured for on / off. You configured the switch nodes to send numbers 0/1 when clicked, so it is mandatory that the inject node send msg.payload with values 0 or 1 .

From the node help:

In pass through mode the switch state can be updated by an incoming msg.payload with the specified values, that must also match the specified type (number, string, etc).

I found a behavior that is not intuitive for me.

I managed to find a way to replicate a case where the ui_switch will not update its status in the editor.

Looks like it is a must that we wire something to the output of the ui_switch in order for it to update the status. In below testing flow the behavior is different when the debug nodes are wired / not wired.

At least this is what is seems to happen in my environment.

29 Dec 09:26:12 - [info] Node-RED version: v1.0.0
29 Dec 09:26:12 - [info] Node.js version: v8.11.1
29 Dec 09:26:12 - [info] Windows_NT 10.0.17763 x64 LE
29 Dec 09:26:15 - [info] Loading palette nodes
29 Dec 09:26:21 - [info] Worldmap version 2.2.0
29 Dec 09:26:22 - [info] Dashboard version 2.19.2 started at /ui

Can anyone test and confirm ?

[{"id":"49ee18f5.a1ec18","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"44b27109.3d21a","type":"ui_switch","z":"49ee18f5.a1ec18","name":"Switch 1","label":"switch 1","tooltip":"","group":"e7ca9205.45fb","order":3,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":360,"y":140,"wires":[[]]},{"id":"580f76ab.4e2458","type":"ui_switch","z":"49ee18f5.a1ec18","name":"Switch 2","label":"switch 2","tooltip":"","group":"e7ca9205.45fb","order":3,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"on","onvalueType":"str","onicon":"","oncolor":"","offvalue":"off","offvalueType":"str","officon":"","offcolor":"","x":360,"y":200,"wires":[[]]},{"id":"2596ae73.31b882","type":"inject","z":"49ee18f5.a1ec18","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"1","x":130,"y":140,"wires":[["44b27109.3d21a","580f76ab.4e2458"]]},{"id":"640afc.fb75b504","type":"inject","z":"49ee18f5.a1ec18","name":"","topic":"","payload":"off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"1","x":130,"y":200,"wires":[["580f76ab.4e2458","44b27109.3d21a"]]},{"id":"10da206b.40521","type":"debug","z":"49ee18f5.a1ec18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":140,"wires":[]},{"id":"5cef6e99.45a93","type":"debug","z":"49ee18f5.a1ec18","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":530,"y":200,"wires":[]},{"id":"e7ca9205.45fb","type":"ui_group","z":"","name":"Default","tab":"4c84c814.4b2f68","disp":false,"width":"3","collapse":false},{"id":"4c84c814.4b2f68","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":6,"disabled":false,"hidden":false}]

Hi Andrei -

Below is the inject node. It has the same data type, number.

Thanks for looking at this.

Tom

@teoboyle post here an example non-working flow, just as many nodes as you need to show the problem. See this post for how to share a flow.

In which case sounds good. When building a flow like yours it works for me.
As @Colin suggested we would need to have a look on your flow, if you can share it.

[
    {
        "id": "aea1bfab.87782",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "fcff0166.31e51",
        "type": "mqtt in",
        "z": "aea1bfab.87782",
        "name": "/home/p1/I2CRelay1",
        "topic": "/home/p1/I2CRelay1",
        "qos": "2",
        "datatype": "auto",
        "broker": "81d264d5.eb5ad8",
        "x": 330,
        "y": 1165,
        "wires": [
            [
                "c3a9d0fe.e9646"
            ]
        ]
    },
    {
        "id": "8e170cfc.321da",
        "type": "exec",
        "z": "aea1bfab.87782",
        "command": "i2cset -y 1 0x10 0x01 0x00",
        "addpay": false,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "Relay1OFF",
        "x": 950,
        "y": 1245,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "2fad9f93.fef2c",
        "type": "exec",
        "z": "aea1bfab.87782",
        "command": "i2cset -y 1 0x10 0x01 0xFF",
        "addpay": false,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "Relay1ON",
        "x": 950,
        "y": 1165,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "9c0b8031.8a4d3",
        "type": "switch",
        "z": "aea1bfab.87782",
        "name": "Relay1_Switch",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 720,
        "y": 1165,
        "wires": [
            [
                "f239b85.df67548",
                "8e170cfc.321da"
            ],
            [
                "f239b85.df67548",
                "2fad9f93.fef2c"
            ]
        ]
    },
    {
        "id": "c3a9d0fe.e9646",
        "type": "json",
        "z": "aea1bfab.87782",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 530,
        "y": 1165,
        "wires": [
            [
                "9c0b8031.8a4d3"
            ]
        ]
    },
    {
        "id": "f239b85.df67548",
        "type": "debug",
        "z": "aea1bfab.87782",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 950,
        "y": 1325,
        "wires": []
    },
    {
        "id": "15f9c1f2.4e9e5e",
        "type": "ui_switch",
        "z": "aea1bfab.87782",
        "name": "Relay1",
        "label": "Relay1",
        "tooltip": "",
        "group": "dbccbb51.1690a8",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "/home/p1/I2CRelay1",
        "style": "",
        "onvalue": "1",
        "onvalueType": "num",
        "onicon": "",
        "oncolor": "",
        "offvalue": "0",
        "offvalueType": "num",
        "officon": "",
        "offcolor": "",
        "x": 120,
        "y": 40,
        "wires": [
            [
                "f70dbf76.d0cad"
            ]
        ]
    },
    {
        "id": "f70dbf76.d0cad",
        "type": "mqtt out",
        "z": "aea1bfab.87782",
        "name": "Relay1",
        "topic": "/home/p1/I2CRelay1",
        "qos": "",
        "retain": "",
        "broker": "81d264d5.eb5ad8",
        "x": 400,
        "y": 40,
        "wires": []
    },
    {
        "id": "6749180d.10bb68",
        "type": "mqtt in",
        "z": "aea1bfab.87782",
        "name": "/home/p1/I2CRelay3",
        "topic": "/home/p1/I2CRelay3",
        "qos": "2",
        "datatype": "auto",
        "broker": "81d264d5.eb5ad8",
        "x": 330,
        "y": 1745,
        "wires": [
            [
                "33080c1e.8c3844"
            ]
        ]
    },
    {
        "id": "33080c1e.8c3844",
        "type": "json",
        "z": "aea1bfab.87782",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 530,
        "y": 1750,
        "wires": [
            [
                "adddf3ac.c8359"
            ]
        ]
    },
    {
        "id": "bc47815d.8dcc4",
        "type": "exec",
        "z": "aea1bfab.87782",
        "command": "i2cset -y 1 0x10 0x03 0x00 ",
        "addpay": false,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "Relay3OFF",
        "x": 950,
        "y": 1810,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "a5453296.15311",
        "type": "exec",
        "z": "aea1bfab.87782",
        "command": "i2cset -y 1 0x10 0x03 0xFF ",
        "addpay": false,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "Relay3ON",
        "x": 950,
        "y": 1710,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "5d3b7873.3014d8",
        "type": "debug",
        "z": "aea1bfab.87782",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 950,
        "y": 1890,
        "wires": []
    },
    {
        "id": "e371a719.0a59b8",
        "type": "ui_switch",
        "z": "aea1bfab.87782",
        "name": "Relay3",
        "label": "Relay3",
        "tooltip": "",
        "group": "dbccbb51.1690a8",
        "order": 3,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "/home/p1/I2CRelay3",
        "style": "",
        "onvalue": "1",
        "onvalueType": "str",
        "onicon": "",
        "oncolor": "",
        "offvalue": "0",
        "offvalueType": "str",
        "officon": "",
        "offcolor": "",
        "x": 123,
        "y": 318,
        "wires": [
            [
                "5fd9714e.b8987"
            ]
        ]
    },
    {
        "id": "5fd9714e.b8987",
        "type": "mqtt out",
        "z": "aea1bfab.87782",
        "name": "Relay3",
        "topic": "/home/p1/I2CRelay3",
        "qos": "",
        "retain": "",
        "broker": "81d264d5.eb5ad8",
        "x": 403,
        "y": 318,
        "wires": []
    },
    {
        "id": "adddf3ac.c8359",
        "type": "switch",
        "z": "aea1bfab.87782",
        "name": "Relay3_Switch",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 730,
        "y": 1750,
        "wires": [
            [
                "5d3b7873.3014d8",
                "bc47815d.8dcc4"
            ],
            [
                "5d3b7873.3014d8",
                "a5453296.15311"
            ]
        ]
    },
    {
        "id": "db27acbc.375fe",
        "type": "mqtt in",
        "z": "aea1bfab.87782",
        "name": "/home/p1/I2CRelay2",
        "topic": "/home/p1/I2CRelay2",
        "qos": "2",
        "datatype": "auto",
        "broker": "81d264d5.eb5ad8",
        "x": 330,
        "y": 1485,
        "wires": [
            [
                "824fece3.3ec6f"
            ]
        ]
    },
    {
        "id": "824fece3.3ec6f",
        "type": "json",
        "z": "aea1bfab.87782",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 530,
        "y": 1485,
        "wires": [
            [
                "d0cef954.1b9558"
            ]
        ]
    },
    {
        "id": "e3b12b75.cede48",
        "type": "exec",
        "z": "aea1bfab.87782",
        "command": "i2cset -y 1 0x10 0x02 0x00 ",
        "addpay": false,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "Relay2OFF",
        "x": 950,
        "y": 1545,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "76f0ace.1c8c254",
        "type": "exec",
        "z": "aea1bfab.87782",
        "command": "i2cset -y 1 0x10 0x02 0xFF ",
        "addpay": false,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "Relay2ON",
        "x": 950,
        "y": 1445,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "7e57fd35.9505c4",
        "type": "debug",
        "z": "aea1bfab.87782",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 950,
        "y": 1625,
        "wires": []
    },
    {
        "id": "d0cef954.1b9558",
        "type": "switch",
        "z": "aea1bfab.87782",
        "name": "Relay2_Switch",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 730,
        "y": 1485,
        "wires": [
            [
                "7e57fd35.9505c4",
                "e3b12b75.cede48"
            ],
            [
                "7e57fd35.9505c4",
                "76f0ace.1c8c254"
            ]
        ]
    },
    {
        "id": "8fc360e7.3e731",
        "type": "ui_switch",
        "z": "aea1bfab.87782",
        "name": "Relay2",
        "label": "Relay2",
        "tooltip": "",
        "group": "dbccbb51.1690a8",
        "order": 2,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "/home/p1/I2CRelay2",
        "style": "",
        "onvalue": "1",
        "onvalueType": "str",
        "onicon": "",
        "oncolor": "",
        "offvalue": "0",
        "offvalueType": "str",
        "officon": "",
        "offcolor": "",
        "x": 120,
        "y": 189,
        "wires": [
            [
                "6371b6cb.208a38"
            ]
        ]
    },
    {
        "id": "6371b6cb.208a38",
        "type": "mqtt out",
        "z": "aea1bfab.87782",
        "name": "Relay2",
        "topic": "/home/p1/I2CRelay2",
        "qos": "",
        "retain": "",
        "broker": "81d264d5.eb5ad8",
        "x": 400,
        "y": 189,
        "wires": []
    },
    {
        "id": "35134e39.e09ca2",
        "type": "mqtt in",
        "z": "aea1bfab.87782",
        "name": "/home/p1/I2CRelay4",
        "topic": "/home/p1/I2CRelay4",
        "qos": "2",
        "datatype": "auto",
        "broker": "81d264d5.eb5ad8",
        "x": 330,
        "y": 2047,
        "wires": [
            [
                "f936ba91.2f6118"
            ]
        ]
    },
    {
        "id": "f936ba91.2f6118",
        "type": "json",
        "z": "aea1bfab.87782",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 530,
        "y": 2047,
        "wires": [
            [
                "ecfed3ea.2a3b8"
            ]
        ]
    },
    {
        "id": "bae1b8ed.cd7318",
        "type": "exec",
        "z": "aea1bfab.87782",
        "command": "i2cset -y 1 0x10 0x04 0x00 ",
        "addpay": false,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "Relay4OFF",
        "x": 950,
        "y": 2107,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "e0b75b46.e03a98",
        "type": "exec",
        "z": "aea1bfab.87782",
        "command": "i2cset -y 1 0x10 0x04 0xFF ",
        "addpay": false,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "Relay4ON",
        "x": 950,
        "y": 2007,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "f9421946.306dd8",
        "type": "debug",
        "z": "aea1bfab.87782",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 950,
        "y": 2187,
        "wires": []
    },
    {
        "id": "ecfed3ea.2a3b8",
        "type": "switch",
        "z": "aea1bfab.87782",
        "name": "Relay4_Switch",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 700,
        "y": 2040,
        "wires": [
            [
                "f9421946.306dd8",
                "bae1b8ed.cd7318"
            ],
            [
                "f9421946.306dd8",
                "e0b75b46.e03a98"
            ]
        ]
    },
    {
        "id": "f839be77.20271",
        "type": "ui_switch",
        "z": "aea1bfab.87782",
        "name": "Relay4",
        "label": "Relay4",
        "tooltip": "",
        "group": "dbccbb51.1690a8",
        "order": 4,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "/home/p1/I2CRelay4",
        "style": "",
        "onvalue": "1",
        "onvalueType": "str",
        "onicon": "",
        "oncolor": "",
        "offvalue": "0",
        "offvalueType": "str",
        "officon": "",
        "offcolor": "",
        "x": 120,
        "y": 442,
        "wires": [
            [
                "670e97fb.0248b8"
            ]
        ]
    },
    {
        "id": "670e97fb.0248b8",
        "type": "mqtt out",
        "z": "aea1bfab.87782",
        "name": "Relay4",
        "topic": "/home/p1/I2CRelay4",
        "qos": "",
        "retain": "",
        "broker": "81d264d5.eb5ad8",
        "x": 400,
        "y": 442,
        "wires": []
    },
    {
        "id": "e4d1b125.0d88f",
        "type": "ui_template",
        "z": "aea1bfab.87782",
        "group": "31e65dc1.63aa32",
        "name": "Weather",
        "order": 0,
        "width": "4",
        "height": "4",
        "format": "<div ng-bind-html=\"<a href=\"https://www.wunderground.com/dashboard/pws/KILSCHAU15\"><img src=\"http://banners.wunderground.com/cgi-bin/banner/ban/wxBanner?bannertype=wxstnsticker_both&weatherstationcount=KILSCHAU15\" height=\"160\" width=\"160\" border=\"0\" alt=\"Weather Underground PWS KILSCHAU15\" /></a></div>",
        "storeOutMessages": true,
        "fwdInMessages": true,
        "templateScope": "local",
        "x": 80,
        "y": 620,
        "wires": [
            []
        ]
    },
    {
        "id": "acea7277.c0e9d",
        "type": "inject",
        "z": "aea1bfab.87782",
        "name": "AutomateRelay1",
        "topic": "AutomateRelay1",
        "payload": "1",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 120,
        "y": 120,
        "wires": [
            [
                "15f9c1f2.4e9e5e"
            ]
        ]
    },
    {
        "id": "9cc4ebee.bb9138",
        "type": "comment",
        "z": "aea1bfab.87782",
        "name": "Relays Below Here",
        "info": "",
        "x": 410,
        "y": 1060,
        "wires": []
    },
    {
        "id": "de4fbb0c.c38598",
        "type": "inject",
        "z": "aea1bfab.87782",
        "name": "AutomateRelay2",
        "topic": "AutomateRelay2",
        "payload": "1",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 120,
        "y": 260,
        "wires": [
            [
                "8fc360e7.3e731"
            ]
        ]
    },
    {
        "id": "f01e0cca.0f9de",
        "type": "inject",
        "z": "aea1bfab.87782",
        "name": "AutomateRelay3",
        "topic": "AutomateRelay3",
        "payload": "1",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 120,
        "y": 380,
        "wires": [
            [
                "e371a719.0a59b8"
            ]
        ]
    },
    {
        "id": "b0de393f.e93828",
        "type": "inject",
        "z": "aea1bfab.87782",
        "name": "AutomateRelay4",
        "topic": "AutomateRelay4",
        "payload": "1",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 120,
        "y": 520,
        "wires": [
            [
                "f839be77.20271"
            ]
        ]
    },
    {
        "id": "7f21bec1.ed04b",
        "type": "status",
        "z": "aea1bfab.87782",
        "name": "",
        "scope": [
            "9c0b8031.8a4d3",
            "adddf3ac.c8359",
            "d0cef954.1b9558",
            "ecfed3ea.2a3b8"
        ],
        "x": 1160,
        "y": 1480,
        "wires": [
            []
        ]
    },
    {
        "id": "81d264d5.eb5ad8",
        "type": "mqtt-broker",
        "z": "",
        "name": "EclipseWS",
        "broker": "ws://test.mosquitto.org:8080",
        "port": "8080",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "Test connection",
        "birthQos": "0",
        "birthPayload": "Connect?",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "dbccbb51.1690a8",
        "type": "ui_group",
        "z": "",
        "name": "Home Relays",
        "tab": "e47097f1.4ad908",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "31e65dc1.63aa32",
        "type": "ui_group",
        "z": "",
        "name": "Information",
        "tab": "e47097f1.4ad908",
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "e47097f1.4ad908",
        "type": "ui_tab",
        "z": "",
        "name": "N9GUN Desktop Control",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

Flow is attached.

I see clearly now. You may want to change data type to number. Only the first switch is configured for number type . The others are configured to string type.

Awesome... Thanks.