Ошибка в статье и итоговое флоу

27 февраля 2019, 14:52

Дополнение к вчерашней статье.

Сегодня внезапно перестали работать флоу в Node Red, связанные с Deconz. В результате дебага выяснил, что Надерет перестал адекватно воспринимать сообщения от деконз по вебсокету если рань, добавил ноду json, в ее настройке поставил Always convert to Java Script Object и пропустил через нее все сообщения от Деконза, все заработало как надо. Если присмотреться к скриншоту ниже, то видно что первые сообщения приходят как string, а последнее как object - так, как нам надо.

В дополнение выкладываю итоговое флоу с выключателями в спальне: Выключатель на входе: левая кнопка вкл/выкл подсветку шкафа с заданной яркостью и ct (color temerature - температура света). Правая кнопка управляет основной группой освещения. Яркость и ct при включении зависят от времени суток (до и после заката)

Прикроватные выключатели «Мама» и «Папа»: одна кнопка управляет собственным светом (вкл/выкл), вторая - Основной группой освещения по аналогии с выключателем на входе.

[
    {
        "id": "df96a184.f3357",
        "type": "tab",
        "label": "Выключатели спальня",
        "disabled": false,
        "info": ""
    },
    {
        "id": "13db1fe7.0e05b",
        "type": "http request",
        "z": "df96a184.f3357",
        "name": "Получить состояние Папа",
        "method": "GET",
        "ret": "obj",
        "url": "http://127.0.0.1:80/api/8EE4111F2F/lights/9",
        "tls": "",
        "x": 687,
        "y": 69,
        "wires": [
            [
                "c1253732.8eed58"
            ]
        ]
    },
    {
        "id": "d45f4f2e.ac6ff8",
        "type": "websocket in",
        "z": "df96a184.f3357",
        "name": "Деконз",
        "server": "",
        "client": "5ca7f5bc.f64c94",
        "x": 55,
        "y": 77,
        "wires": [
            [
                "ff8a1669.00259"
            ]
        ]
    },
    {
        "id": "7ac6fb00.8648a4",
        "type": "switch",
        "z": "df96a184.f3357",
        "name": "папа",
        "property": "payload.id",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "21",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 1,
        "x": 338,
        "y": 71,
        "wires": [
            [
                "735b0216.fefcec"
            ]
        ],
        "outputLabels": [
            "On/Off"
        ]
    },
    {
        "id": "735b0216.fefcec",
        "type": "switch",
        "z": "df96a184.f3357",
        "name": "лев/прав",
        "property": "payload.state.buttonevent",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1002",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "2002",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 471,
        "y": 72,
        "wires": [
            [
                "13db1fe7.0e05b"
            ],
            [
                "57a79a7b.db717c"
            ]
        ],
        "outputLabels": [
            "On/Off",
            "Brighter-ShortPress"
        ]
    },
    {
        "id": "1f1aed5b.fd0e83",
        "type": "http request",
        "z": "df96a184.f3357",
        "name": "Вкл/выкл папа",
        "method": "PUT",
        "ret": "obj",
        "url": "http://127.0.0.1:80/api/8EE4111F2F/lights/9/state",
        "tls": "",
        "x": 1246,
        "y": 72,
        "wires": [
            []
        ]
    },
    {
        "id": "d308ee0e.b4a398",
        "type": "change",
        "z": "df96a184.f3357",
        "name": "включаем",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"on\":true}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1048,
        "y": 60,
        "wires": [
            [
                "1f1aed5b.fd0e83"
            ]
        ]
    },
    {
        "id": "5c5618ff.49b9d",
        "type": "change",
        "z": "df96a184.f3357",
        "name": "выключаем",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"on\":false}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1049,
        "y": 100,
        "wires": [
            [
                "1f1aed5b.fd0e83"
            ]
        ]
    },
    {
        "id": "c1253732.8eed58",
        "type": "switch",
        "z": "df96a184.f3357",
        "name": "вкл/выкл",
        "property": "payload.state.on",
        "propertyType": "msg",
        "rules": [
            {
                "t": "false"
            },
            {
                "t": "true"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 888,
        "y": 69,
        "wires": [
            [
                "d308ee0e.b4a398"
            ],
            [
                "5c5618ff.49b9d"
            ]
        ]
    },
    {
        "id": "5a4c258e.553e74",
        "type": "switch",
        "z": "df96a184.f3357",
        "name": "мама",
        "property": "payload.id",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "23",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 1,
        "x": 251,
        "y": 534,
        "wires": [
            [
                "e5682d20.f748a"
            ]
        ],
        "outputLabels": [
            "On/Off"
        ]
    },
    {
        "id": "e5682d20.f748a",
        "type": "switch",
        "z": "df96a184.f3357",
        "name": "лев/прав",
        "property": "payload.state.buttonevent",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1002",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "2002",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 415,
        "y": 534,
        "wires": [
            [
                "57a79a7b.db717c"
            ],
            [
                "de20fc96.69aa38"
            ]
        ],
        "outputLabels": [
            "On/Off",
            "Brighter-ShortPress"
        ]
    },
    {
        "id": "de20fc96.69aa38",
        "type": "http request",
        "z": "df96a184.f3357",
        "name": "Получить состояние Мама",
        "method": "GET",
        "ret": "obj",
        "url": "http://127.0.0.1:80/api/8EE4111F2F/lights/35",
        "tls": "",
        "x": 651,
        "y": 537,
        "wires": [
            [
                "600c9d2.0a7a5e4"
            ]
        ]
    },
    {
        "id": "600c9d2.0a7a5e4",
        "type": "switch",
        "z": "df96a184.f3357",
        "name": "вкл/выкл",
        "property": "payload.state.on",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 909,
        "y": 615,
        "wires": [
            [
                "a0a4ef66.027438"
            ],
            [
                "7d15971.c9d64e8"
            ]
        ]
    },
    {
        "id": "7d15971.c9d64e8",
        "type": "change",
        "z": "df96a184.f3357",
        "name": "вкл",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"on\":true}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1091,
        "y": 635,
        "wires": [
            [
                "e6f85a33.da7988"
            ]
        ]
    },
    {
        "id": "a0a4ef66.027438",
        "type": "change",
        "z": "df96a184.f3357",
        "name": "выкл",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"on\":false}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1072,
        "y": 585,
        "wires": [
            [
                "e6f85a33.da7988"
            ]
        ]
    },
    {
        "id": "e6f85a33.da7988",
        "type": "http request",
        "z": "df96a184.f3357",
        "name": "мама",
        "method": "PUT",
        "ret": "obj",
        "url": "http://127.0.0.1:80/api/8EE4111F2F/lights/35/state",
        "tls": "",
        "x": 1312,
        "y": 617,
        "wires": [
            []
        ]
    },
    {
        "id": "57a79a7b.db717c",
        "type": "http request",
        "z": "df96a184.f3357",
        "name": "Получить состояние Спальни",
        "method": "GET",
        "ret": "obj",
        "url": "http://127.0.0.1:80/api/8EE4111F2F/groups/4",
        "tls": "",
        "x": 203,
        "y": 304,
        "wires": [
            [
                "8236481a.2ea388"
            ]
        ]
    },
    {
        "id": "a181375e.3199f",
        "type": "http request",
        "z": "df96a184.f3357",
        "name": "день/ночь",
        "method": "GET",
        "ret": "obj",
        "url": "http://127.0.0.1:80/api/8EE4111F2F/sensors/1",
        "tls": "",
        "x": 629,
        "y": 324,
        "wires": [
            [
                "6d9e428.97c5c3c"
            ]
        ]
    },
    {
        "id": "8236481a.2ea388",
        "type": "switch",
        "z": "df96a184.f3357",
        "name": "вкл/выкл",
        "property": "payload.state.any_on",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 451,
        "y": 302,
        "wires": [
            [
                "6fb8e720.f24"
            ],
            [
                "a181375e.3199f",
                "31f6304f.457f18"
            ]
        ]
    },
    {
        "id": "6fb8e720.f24",
        "type": "change",
        "z": "df96a184.f3357",
        "name": "выключаем",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"on\":false}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1081,
        "y": 138,
        "wires": [
            [
                "d656dc49.8de6f"
            ]
        ]
    },
    {
        "id": "6d9e428.97c5c3c",
        "type": "switch",
        "z": "df96a184.f3357",
        "name": "день/ночь",
        "property": "payload.state.daylight",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 804,
        "y": 316,
        "wires": [
            [
                "f94d98d7.b7d86",
                "8476ebc.82e0818"
            ],
            [
                "55ce29c3.01b79",
                "50aa4498.a9ee1c"
            ]
        ]
    },
    {
        "id": "55ce29c3.01b79",
        "type": "function",
        "z": "df96a184.f3357",
        "name": "Яркость ночью",
        "func": "msg.payload = 203\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 979,
        "y": 294,
        "wires": [
            [
                "fc6b9d97.33da28"
            ]
        ]
    },
    {
        "id": "50aa4498.a9ee1c",
        "type": "function",
        "z": "df96a184.f3357",
        "name": "ct ночью",
        "func": "msg.payload = 550;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 977,
        "y": 335,
        "wires": [
            [
                "5104cbd7.b82fe4"
            ]
        ]
    },
    {
        "id": "f94d98d7.b7d86",
        "type": "function",
        "z": "df96a184.f3357",
        "name": "Яркость днем",
        "func": "msg.payload = 254;\n\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 985,
        "y": 222,
        "wires": [
            [
                "fc6b9d97.33da28"
            ]
        ]
    },
    {
        "id": "8476ebc.82e0818",
        "type": "function",
        "z": "df96a184.f3357",
        "name": "ct днем",
        "func": "msg.payload = 1;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 977,
        "y": 260,
        "wires": [
            [
                "5104cbd7.b82fe4"
            ]
        ]
    },
    {
        "id": "fc6b9d97.33da28",
        "type": "change",
        "z": "df96a184.f3357",
        "name": "яркость",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\t   \"bri\": msg.payload,\t   \"transitiontime\": 1\t\t}",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1146,
        "y": 252,
        "wires": [
            [
                "d656dc49.8de6f"
            ]
        ]
    },
    {
        "id": "5104cbd7.b82fe4",
        "type": "change",
        "z": "df96a184.f3357",
        "name": "ct",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\t   \"ct\": msg.payload,\t   \"transitiontime\": 1\t\t}",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1141,
        "y": 299,
        "wires": [
            [
                "d656dc49.8de6f"
            ]
        ]
    },
    {
        "id": "31f6304f.457f18",
        "type": "change",
        "z": "df96a184.f3357",
        "name": "включаем",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"on\":true}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1078,
        "y": 182,
        "wires": [
            [
                "d656dc49.8de6f"
            ]
        ]
    },
    {
        "id": "d656dc49.8de6f",
        "type": "http request",
        "z": "df96a184.f3357",
        "name": "спальня",
        "method": "PUT",
        "ret": "obj",
        "url": "http://127.0.0.1:80/api/8EE4111F2F/groups/4/action",
        "tls": "",
        "x": 1293,
        "y": 192,
        "wires": [
            []
        ]
    },
    {
        "id": "52e82a10.01f254",
        "type": "switch",
        "z": "df96a184.f3357",
        "name": "вход",
        "property": "payload.id",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "22",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 1,
        "x": 345,
        "y": 109,
        "wires": [
            [
                "3db3dd28.9a8672"
            ]
        ],
        "outputLabels": [
            "On/Off"
        ]
    },
    {
        "id": "3db3dd28.9a8672",
        "type": "switch",
        "z": "df96a184.f3357",
        "name": "лев/прав",
        "property": "payload.state.buttonevent",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1002",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "2002",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 477,
        "y": 110,
        "wires": [
            [
                "52bca6a0.36aa2"
            ],
            [
                "57a79a7b.db717c"
            ]
        ],
        "outputLabels": [
            "On/Off",
            "Brighter-ShortPress"
        ]
    },
    {
        "id": "52bca6a0.36aa2",
        "type": "http request",
        "z": "df96a184.f3357",
        "name": "Получить состояние Спальня шкаф",
        "method": "GET",
        "ret": "obj",
        "url": "http://127.0.0.1:80/api/8EE4111F2F/lights/57",
        "tls": "",
        "x": 483,
        "y": 386,
        "wires": [
            [
                "fd7e0317.ef1fc8"
            ]
        ]
    },
    {
        "id": "fd7e0317.ef1fc8",
        "type": "switch",
        "z": "df96a184.f3357",
        "name": "вкл/выкл",
        "property": "payload.state.on",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 756,
        "y": 395,
        "wires": [
            [
                "eb8efc02.e32c"
            ],
            [
                "5a5652e3.9c65a4",
                "9f07f8f5.c5a918",
                "6063286.00f7858"
            ]
        ]
    },
    {
        "id": "5a5652e3.9c65a4",
        "type": "change",
        "z": "df96a184.f3357",
        "name": "вкл",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"on\":true}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1018,
        "y": 429,
        "wires": [
            [
                "24947304.a71694"
            ]
        ]
    },
    {
        "id": "eb8efc02.e32c",
        "type": "change",
        "z": "df96a184.f3357",
        "name": "выкл",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"on\":false}",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1025,
        "y": 387,
        "wires": [
            [
                "24947304.a71694"
            ]
        ]
    },
    {
        "id": "24947304.a71694",
        "type": "http request",
        "z": "df96a184.f3357",
        "name": "спальня шкаф",
        "method": "PUT",
        "ret": "obj",
        "url": "http://127.0.0.1:80/api/8EE4111F2F/lights/57/state",
        "tls": "",
        "x": 1228,
        "y": 402,
        "wires": [
            []
        ]
    },
    {
        "id": "6063286.00f7858",
        "type": "function",
        "z": "df96a184.f3357",
        "name": "Яркость",
        "func": "msg.payload = 254;\n\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 964,
        "y": 520,
        "wires": [
            [
                "12da9c6a.d4bcec"
            ]
        ]
    },
    {
        "id": "9f07f8f5.c5a918",
        "type": "function",
        "z": "df96a184.f3357",
        "name": "ct",
        "func": "msg.payload = 1;\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 983,
        "y": 478,
        "wires": [
            [
                "ef525c0c.6ceec"
            ]
        ]
    },
    {
        "id": "12da9c6a.d4bcec",
        "type": "change",
        "z": "df96a184.f3357",
        "name": "яркость",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\t   \"bri\": msg.payload,\t   \"transitiontime\": 1\t\t}",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1107,
        "y": 520,
        "wires": [
            [
                "24947304.a71694"
            ]
        ]
    },
    {
        "id": "ef525c0c.6ceec",
        "type": "change",
        "z": "df96a184.f3357",
        "name": "ct",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\t   \"ct\": msg.payload,\t   \"transitiontime\": 1\t\t}",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1101,
        "y": 477,
        "wires": [
            [
                "24947304.a71694"
            ]
        ]
    },
    {
        "id": "ff8a1669.00259",
        "type": "json",
        "z": "df96a184.f3357",
        "name": "",
        "property": "payload",
        "action": "obj",
        "pretty": false,
        "x": 189,
        "y": 76,
        "wires": [
            [
                "7ac6fb00.8648a4",
                "52e82a10.01f254",
                "5a4c258e.553e74"
            ]
        ]
    },
    {
        "id": "5ca7f5bc.f64c94",
        "type": "websocket-client",
        "z": "",
        "path": "ws://127.0.0.1:8088",
        "tls": "",
        "wholemsg": "false"
    }
]

Все новости мира умных домов - t.me/SprutAI_News или Instagram
Остались вопросы? Мы в Telegram - @SprutAI

Хочешь умный дом но нет времени разбираться?
Посмотри примеры работ и выбери себе интегратора.
  1. Григорий Абрамов (grishmanCH)

    вот теперь понятно откуда ноги растут, у меня изначально деконз посылал только string

К списку блогов

Похожие записи

20 января 2019, 17:39
Создание очень бюджетной автоматизации рулонных штор
11 апреля 2019, 17:17
Краткий обзор и распаковка обновления всеми любимого USB стика ConBee 2 (deCONZ) от Dresden Electronic.
06 февраля 2019, 18:34
Как забиндить диммер IKEA и умную лампу в Deconz
19 февраля 2019, 18:43
Ответы на вопросы, заданные в ЛС в телеграмме
14 апреля 2019, 19:36
Все изменения в Deconz 2.05.60-2.05.63.
27 января 2019, 10:55
Избавляемся от wi-fi реле на ESP в пользу zigbee без прошивок и танцев с бубном.
13 марта 2020, 21:07
Чем чаще двигаешься - тем дольше свет не погаснет
28 июня 2019, 09:50
Расскажу о планах на ближайшие несколько недель и немного упрощу вам жизнь.
10 мая 2020, 15:21
Состояние проекта. Поставка новых компонентов. Задержки на таможне и производство новых деталей собственной разработки.