Switch node icons color problem

Finally I'm back...
After three night of work, changes and various attempts (and with your help), I managed to get it to work!!!
Now I can turn on or off the lights from NodeRed, from Shelly Apps or from original wall switch and in every case icon on NodeRed dashboard change (Yellow for ON status, Grey for OFF status)

Thanks to all...

I attach my code:

[
    {
        "id": "69103026.a212b",
        "type": "comment",
        "z": "4f28d205.05afcc",
        "name": "Luci Esterne",
        "info": "",
        "x": 110,
        "y": 40,
        "wires": []
    },
    {
        "id": "33d06843.6dce88",
        "type": "ui_audio",
        "z": "4f28d205.05afcc",
        "name": "Messaggio Vocale",
        "group": "3b49ec8e.cf4144",
        "voice": "it-IT",
        "always": true,
        "x": 600,
        "y": 40,
        "wires": []
    },
    {
        "id": "34fc0755.d3c048",
        "type": "http request",
        "z": "4f28d205.05afcc",
        "name": "Switch Shelly",
        "method": "GET",
        "ret": "txt",
        "paytoqs": false,
        "url": "http://admin:XXXX@192.168.1.213/relay/0?turn=toggle",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 380,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "8539e1f.f79182",
        "type": "change",
        "z": "4f28d205.05afcc",
        "name": "Setta Messaggio",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "true",
                "fromt": "bool",
                "to": "Luci Esterne Accese",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "false",
                "fromt": "bool",
                "to": "Luci Esterne Spente",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 400,
        "y": 40,
        "wires": [
            [
                "33d06843.6dce88"
            ]
        ]
    },
    {
        "id": "cac6dfed.07eb",
        "type": "ui_switch",
        "z": "4f28d205.05afcc",
        "name": "",
        "label": "Accendi / Spegni",
        "tooltip": "",
        "group": "a4049c44.5b032",
        "order": 1,
        "width": 6,
        "height": "2",
        "passthru": false,
        "decouple": "true",
        "topic": "",
        "style": "",
        "onvalue": "true",
        "onvalueType": "str",
        "onicon": "onicon",
        "oncolor": "oncolor",
        "offvalue": "false",
        "offvalueType": "str",
        "officon": "officon",
        "offcolor": "offcolor",
        "x": 130,
        "y": 80,
        "wires": [
            [
                "8539e1f.f79182",
                "34fc0755.d3c048"
            ]
        ]
    },
    {
        "id": "9ebebda1.5024a",
        "type": "function",
        "z": "4f28d205.05afcc",
        "name": "Luci ON",
        "func": "msg.ui_control = {  onicon:\"fa-4x fa-lightbulb-o\",oncolor:\"yellow\"}\nmsg.payload=\"true\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 810,
        "y": 130,
        "wires": [
            [
                "cac6dfed.07eb"
            ]
        ]
    },
    {
        "id": "a7e417f4.f4d768",
        "type": "http request",
        "z": "4f28d205.05afcc",
        "name": "Status Shelly",
        "method": "GET",
        "ret": "txt",
        "paytoqs": false,
        "url": "http://admin:XXXX@192.168.1.213/relay/0?status",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "",
        "x": 230,
        "y": 150,
        "wires": [
            [
                "e502c6f.06e5438"
            ]
        ]
    },
    {
        "id": "e502c6f.06e5438",
        "type": "json",
        "z": "4f28d205.05afcc",
        "name": "Trasforma in JSON",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 410,
        "y": 150,
        "wires": [
            [
                "14b6bd7a.f0edb3"
            ]
        ]
    },
    {
        "id": "14b6bd7a.f0edb3",
        "type": "switch",
        "z": "4f28d205.05afcc",
        "name": "Controllo se ON o OFF",
        "property": "payload.ison",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 620,
        "y": 150,
        "wires": [
            [
                "9ebebda1.5024a"
            ],
            [
                "f1ebdbd6.28a388"
            ]
        ]
    },
    {
        "id": "f1ebdbd6.28a388",
        "type": "function",
        "z": "4f28d205.05afcc",
        "name": "Luci OFF",
        "func": "msg.ui_control = {  officon:\"fa-3x fa-lightbulb-o\",offcolor:\"grey\"}\nmsg.payload=\"false\"\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 810,
        "y": 170,
        "wires": [
            [
                "cac6dfed.07eb"
            ]
        ]
    },
    {
        "id": "5c103573.3e325c",
        "type": "inject",
        "z": "4f28d205.05afcc",
        "name": "Avvio",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 90,
        "y": 150,
        "wires": [
            [
                "a7e417f4.f4d768"
            ]
        ]
    },
    {
        "id": "3b49ec8e.cf4144",
        "type": "ui_group",
        "z": "",
        "name": "Gestione Cancello",
        "tab": "be3b686.c1d7998",
        "order": 1,
        "disp": true,
        "width": 6,
        "collapse": true
    },
    {
        "id": "a4049c44.5b032",
        "type": "ui_group",
        "z": "",
        "name": "Luci Esterne",
        "tab": "59b63931.02dec8",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "be3b686.c1d7998",
        "type": "ui_tab",
        "z": "",
        "name": "Cancello",
        "icon": "account_balance",
        "order": 5,
        "disabled": false,
        "hidden": false
    },
    {
        "id": "59b63931.02dec8",
        "type": "ui_tab",
        "z": "",
        "name": "Luci",
        "icon": "lightbulb_outline",
        "order": 6,
        "disabled": false,
        "hidden": false
    }
]
1 Like