Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

OlegJktu
starter
Beiträge: 37
Registriert: 29.10.2017, 06:48

Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von OlegJktu » 16.02.2018, 09:05

Это общая тема по Node-RED для сбора опытов пользователей и поиска решений.

Node-RED это визуальная среда программирования, в которой можно реализовать различные сценарии и правила автоматизации в графическом виде без написания какого-либо кода.

здесь общие материалы
Хорошая статья по node-red https://geektimes.ru/post/279814/
Офф. библиотека node-red https://flows.nodered.org/
об интерфейсе Node-Red http://wikihandbk.com/wiki/Raspberry_Pi ... 1_Node-RED
публикация по взаимодействию Nod-Red и xiaomi напрямую https://kuznik.livejournal.com/1429.html

upd1 23/08/18: еще интересные материалы по nod-red
https://community.vscale.io/hc/ru/commu ... 1-Debian-8
https://zftlab.org/pages/2017012100.html
https://stefkblog.wordpress.com/node-red-install-steps/
https://tech.scargill.net/a-thermostat-weekend/
русскоязычный канал в телеграмм: https://t.me/node_red
Zuletzt geändert von OlegJktu am 23.08.2018, 12:15, insgesamt 4-mal geändert.

OlegJktu
starter
Beiträge: 37
Registriert: 29.10.2017, 06:48

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von OlegJktu » 16.02.2018, 09:10

Включение/выключение от геркона калитки уличного света после заката.
Калиток несколько, свет выключается по таймеру.
Нода рассвета импортирована
Оборудование герконы xiaomi и aqara проводной выключатель
Screenshot_20180215_183042.png
код для импорта
Spoiler: Show hidden text

Code: Alles auswählen

[
    {
        "id": "baa1fd17.7e498",
        "type": "sunrise",
        "z": "85a64329.4b4868",
        "name": "Sunrise",
        "lat": "",
        "lon": "51.025",
        "start": "sunrise",
        "end": "sunset",
        "x": 213.88333129882812,
        "y": 686.3333129882812,
        "wires": [
            [
                "21122ee.294b452",
                "9acc79fb.e2428"
            ],
            []
        ]
    },
    {
        "id": "21122ee.294b452",
        "type": "debug",
        "z": "85a64329.4b4868",
        "name": "debug sunrise",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 243.88333129882812,
        "y": 642.6666259765625,
        "wires": []
    },
    {
        "id": "bb8b62dc.6e039",
        "type": "comment",
        "z": "85a64329.4b4868",
        "name": "this flow on outdoor ligt after sunset when gate is open and off light after 5 min",
        "info": "",
        "x": 752.9833679199219,
        "y": 29,
        "wires": []
    },
    {
        "id": "4fca973e.3c251",
        "type": "ioBroker in",
        "z": "85a64329.4b4868",
        "name": "GATE_magnet_158d00018761d4.state is opened",
        "topic": "mihome.0.devices.magnet_158d00018761d4.state",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 311.88336181640625,
        "y": 256.8666687011719,
        "wires": [
            [
                "776668e.1105998",
                "71a75b15.3706f4"
            ]
        ]
    },
    {
        "id": "776668e.1105998",
        "type": "debug",
        "z": "85a64329.4b4868",
        "name": "magnet_158d00018761d4.state",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 251.88339233398438,
        "y": 223.23333740234375,
        "wires": []
    },
    {
        "id": "1550a55c.7851bb",
        "type": "ioBroker in",
        "z": "85a64329.4b4868",
        "name": " workshop_magnet_158d00019f3001.state Is opened",
        "topic": "mihome.0.devices.magnet_158d00019f3001.state",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 331.8833312988281,
        "y": 349.8666687011719,
        "wires": [
            [
                "56201f03.9ea298",
                "71a75b15.3706f4"
            ]
        ]
    },
    {
        "id": "56201f03.9ea298",
        "type": "debug",
        "z": "85a64329.4b4868",
        "name": "magnet_158d00019f3001.state",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 268.8832702636719,
        "y": 316.23333740234375,
        "wires": []
    },
    {
        "id": "71a75b15.3706f4",
        "type": "switch",
        "z": "85a64329.4b4868",
        "name": "only true can go ",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "outputs": 1,
        "x": 686.7666320800781,
        "y": 262.8833312988281,
        "wires": [
            [
                "53ecee2e.2398c8"
            ]
        ]
    },
    {
        "id": "997d0d6f.ca65f",
        "type": "inject",
        "z": "85a64329.4b4868",
        "name": "",
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 211.76669311523438,
        "y": 552.88330078125,
        "wires": [
            [
                "9acc79fb.e2428"
            ]
        ]
    },
    {
        "id": "b1a9087e.cb206",
        "type": "inject",
        "z": "85a64329.4b4868",
        "name": "",
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 211.76669311523438,
        "y": 592.88330078125,
        "wires": [
            [
                "9acc79fb.e2428"
            ]
        ]
    },
    {
        "id": "3e0de5ee.0bfb12",
        "type": "inject",
        "z": "85a64329.4b4868",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 258.7666931152344,
        "y": 139.13330078125,
        "wires": [
            [
                "71a75b15.3706f4"
            ]
        ]
    },
    {
        "id": "cf8bd889.cad118",
        "type": "inject",
        "z": "85a64329.4b4868",
        "name": "",
        "topic": "",
        "payload": "false",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 258.7666931152344,
        "y": 175.13330078125,
        "wires": [
            [
                "71a75b15.3706f4"
            ]
        ]
    },
    {
        "id": "9acc79fb.e2428",
        "type": "switch",
        "z": "85a64329.4b4868",
        "name": "Light Threshold Selector",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "0",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "outputs": 2,
        "x": 489.7666320800781,
        "y": 685.1333618164062,
        "wires": [
            [
                "768924ab.192bcc",
                "b7a4a04d.c88a9"
            ],
            [
                "f082e4a.388b698",
                "e66874d7.3af6e"
            ]
        ]
    },
    {
        "id": "f082e4a.388b698",
        "type": "change",
        "z": "85a64329.4b4868",
        "name": "Enable Light",
        "rules": [
            {
                "t": "set",
                "p": "Light_enabled",
                "pt": "flow",
                "to": "Yes",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 707.4332885742188,
        "y": 712.4166870117188,
        "wires": [
            []
        ]
    },
    {
        "id": "768924ab.192bcc",
        "type": "change",
        "z": "85a64329.4b4868",
        "name": "Disable Light",
        "rules": [
            {
                "t": "set",
                "p": "Light_enabled",
                "pt": "flow",
                "to": "No",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 715.0999145507812,
        "y": 654.933349609375,
        "wires": [
            []
        ]
    },
    {
        "id": "53ecee2e.2398c8",
        "type": "switch",
        "z": "85a64329.4b4868",
        "name": "Light Enabled?",
        "property": "Light_enabled",
        "propertyType": "flow",
        "rules": [
            {
                "t": "eq",
                "v": "Yes",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "outputs": 1,
        "x": 888.7665710449219,
        "y": 265.1333312988281,
        "wires": [
            [
                "6627bb64.af4574",
                "3c9b49d4.2207b6",
                "d69ccd87.4c3a58"
            ]
        ]
    },
    {
        "id": "e66874d7.3af6e",
        "type": "debug",
        "z": "85a64329.4b4868",
        "name": "Enable Light",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 479.9833679199219,
        "y": 728.4832763671875,
        "wires": []
    },
    {
        "id": "b7a4a04d.c88a9",
        "type": "debug",
        "z": "85a64329.4b4868",
        "name": "Disable Light",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 481.9833679199219,
        "y": 638.4832763671875,
        "wires": []
    },
    {
        "id": "6627bb64.af4574",
        "type": "debug",
        "z": "85a64329.4b4868",
        "name": "Light_enabled",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 891.9832763671875,
        "y": 211.48333740234375,
        "wires": []
    },
    {
        "id": "d69ccd87.4c3a58",
        "type": "trigger",
        "z": "85a64329.4b4868",
        "op1": "",
        "op2": "0",
        "op1type": "nul",
        "op2type": "num",
        "duration": "5",
        "extend": true,
        "units": "min",
        "reset": "",
        "name": "Switch off delay",
        "x": 1119.7666320800781,
        "y": 432.1333312988281,
        "wires": [
            [
                "bea3c898.817f28",
                "b1f418f5.d04728",
                "91d18cbe.93646"
            ]
        ]
    },
    {
        "id": "3c9b49d4.2207b6",
        "type": "change",
        "z": "85a64329.4b4868",
        "name": "turn light on",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "1",
                "tot": "num"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1131.7666625976562,
        "y": 267.1333312988281,
        "wires": [
            [
                "29449ff1.9b69c",
                "b1f418f5.d04728",
                "91d18cbe.93646"
            ]
        ]
    },
    {
        "id": "29449ff1.9b69c",
        "type": "debug",
        "z": "85a64329.4b4868",
        "name": "turn light on",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 1137.9833374023438,
        "y": 174.48333740234375,
        "wires": []
    },
    {
        "id": "b1f418f5.d04728",
        "type": "ioBroker out",
        "z": "85a64329.4b4868",
        "name": "Outdoor Wall switch 0",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014a81c0.channel_0",
        "ack": "false",
        "autoCreate": "false",
        "x": 1475.9833374023438,
        "y": 262.1166687011719,
        "wires": []
    },
    {
        "id": "91d18cbe.93646",
        "type": "ioBroker out",
        "z": "85a64329.4b4868",
        "name": "Outdoor Wall switch 1",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014a81c0.channel_1",
        "ack": "false",
        "autoCreate": "false",
        "x": 1473.9833374023438,
        "y": 215.11666870117188,
        "wires": []
    },
    {
        "id": "6adcc643.3d6868",
        "type": "inject",
        "z": "85a64329.4b4868",
        "name": "",
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 1138.7666625976562,
        "y": 71.13333129882812,
        "wires": [
            [
                "b1f418f5.d04728",
                "91d18cbe.93646"
            ]
        ]
    },
    {
        "id": "37c34bfe.9ef6c4",
        "type": "inject",
        "z": "85a64329.4b4868",
        "name": "",
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 1141.7666625976562,
        "y": 112.13333129882812,
        "wires": [
            [
                "91d18cbe.93646",
                "b1f418f5.d04728"
            ]
        ]
    },
    {
        "id": "ecde291d.85ec38",
        "type": "inject",
        "z": "85a64329.4b4868",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 944.7666320800781,
        "y": 476.13336181640625,
        "wires": [
            [
                "d69ccd87.4c3a58"
            ]
        ]
    },
    {
        "id": "bea3c898.817f28",
        "type": "debug",
        "z": "85a64329.4b4868",
        "name": "Switch off delay",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 1132.9833068847656,
        "y": 476.48333740234375,
        "wires": []
    },
    {
        "id": "c79b8e6f.97929",
        "type": "comment",
        "z": "85a64329.4b4868",
        "name": "todo: добавить проверку если свет включен вручную",
        "info": "",
        "x": 233.98336791992188,
        "y": 26.416671752929688,
        "wires": []
    },
    {
        "id": "addb06e3.2317b8",
        "type": "comment",
        "z": "85a64329.4b4868",
        "name": "use only open state",
        "info": "",
        "x": 683.9833068847656,
        "y": 227.41665649414062,
        "wires": []
    },
    {
        "id": "ad0906e7.0ecfc",
        "type": "comment",
        "z": "85a64329.4b4868",
        "name": "Light Enable? logic \t",
        "info": "",
        "x": 518.9833679199219,
        "y": 583.4166259765625,
        "wires": []
    },
    {
        "id": "eee07832.758b7",
        "type": "comment",
        "z": "85a64329.4b4868",
        "name": "transform true to number 1",
        "info": "",
        "x": 1149.9833374023438,
        "y": 298.4166564941406,
        "wires": []
    },
    {
        "id": "babce20c.3c7838",
        "type": "comment",
        "z": "85a64329.4b4868",
        "name": "timer auto off",
        "info": "",
        "x": 1113.0999755859375,
        "y": 398.4166564941406,
        "wires": []
    },
    {
        "id": "30ce3361.293e44",
        "type": "comment",
        "z": "85a64329.4b4868",
        "name": "instruction http://forums.opto22.com/t/sun-rise-set-inside-outside-light-control/1206",
        "info": "",
        "x": 437.8833312988281,
        "y": 807.88330078125,
        "wires": []
    },
    {
        "id": "a7cdf129.a3e248",
        "type": "comment",
        "z": "85a64329.4b4868",
        "name": "The  sunrise node provide two outputs. The first output emits a msg.payload of 1 or 0 every minute depending if day-time (1) or night-time (0).",
        "info": "",
        "x": 617.8833312988281,
        "y": 770.5499877929688,
        "wires": []
    }
]

OlegJktu
starter
Beiträge: 37
Registriert: 29.10.2017, 06:48

Правило автоматизации на Nod-red при открытии геркона зажигается определенным цветом шлюз xiaomi , потом по таймеру выкл

Beitrag von OlegJktu » 19.02.2018, 17:24

Скрипт автоматизации на Nod-red
при открытии геркона зажигается определенным цветом шлюз xiaomi , потом по таймеру выключается

В блоках
Spoiler: Show hidden text
[img]
Screenshot_20180219_162343.png
[/img]
Код для импорта
Spoiler: Show hidden text

Code: Alles auswählen

[
    {
        "id": "456cb82a.fd7948",
        "type": "ioBroker in",
        "z": "a66658c7.550b58",
        "name": " workshop_magnet_158d00019f3001.state Is opened",
        "topic": "mihome.0.devices.magnet_158d00019f3001.state",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 260,
        "y": 300,
        "wires": [
            [
                "af011381.eb9f",
                "8bd93765.129008"
            ]
        ]
    },
    {
        "id": "af011381.eb9f",
        "type": "debug",
        "z": "a66658c7.550b58",
        "name": "magnet_158d00019f3001.state",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 190,
        "y": 260,
        "wires": []
    },
    {
        "id": "fd83b635.f38138",
        "type": "inject",
        "z": "a66658c7.550b58",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 130,
        "y": 360,
        "wires": [
            [
                "8bd93765.129008"
            ]
        ]
    },
    {
        "id": "8e12fb37.497708",
        "type": "inject",
        "z": "a66658c7.550b58",
        "name": "",
        "topic": "",
        "payload": "false",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 130,
        "y": 396,
        "wires": [
            [
                "8bd93765.129008"
            ]
        ]
    },
    {
        "id": "8ce5e25d.17d4",
        "type": "ioBroker out",
        "z": "a66658c7.550b58",
        "name": "RGB",
        "topic": "mihome.0.devices.gateway_34ce008acd8e.rgb",
        "ack": "false",
        "autoCreate": "false",
        "x": 1430,
        "y": 280,
        "wires": []
    },
    {
        "id": "68772b5c.25b88c",
        "type": "ioBroker out",
        "z": "a66658c7.550b58",
        "name": "Switch Light",
        "topic": "mihome.0.devices.gateway_34ce008acd8e.on",
        "ack": "false",
        "autoCreate": "false",
        "x": 1450,
        "y": 360,
        "wires": []
    },
    {
        "id": "b64768f6.d049d8",
        "type": "ioBroker out",
        "z": "a66658c7.550b58",
        "name": "Dimmer Light",
        "topic": "mihome.0.devices.gateway_34ce008acd8e.dimmer",
        "ack": "false",
        "autoCreate": "false",
        "x": 1460,
        "y": 440,
        "wires": []
    },
    {
        "id": "18bd5339.0386f5",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "xiaomi gate light",
        "info": "",
        "x": 1460,
        "y": 240,
        "wires": []
    },
    {
        "id": "1de3d955.71503f",
        "type": "inject",
        "z": "a66658c7.550b58",
        "name": "",
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 790,
        "y": 740,
        "wires": [
            [
                "68772b5c.25b88c"
            ]
        ]
    },
    {
        "id": "3f5b4c40.1bc1fc",
        "type": "inject",
        "z": "a66658c7.550b58",
        "name": "",
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 790,
        "y": 820,
        "wires": [
            [
                "68772b5c.25b88c"
            ]
        ]
    },
    {
        "id": "b40c358a.1fb2d",
        "type": "inject",
        "z": "a66658c7.550b58",
        "name": "",
        "topic": "",
        "payload": "10",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 950,
        "y": 740,
        "wires": [
            [
                "b64768f6.d049d8"
            ]
        ]
    },
    {
        "id": "10b5b883.56783f",
        "type": "inject",
        "z": "a66658c7.550b58",
        "name": "",
        "topic": "",
        "payload": "100",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 950,
        "y": 820,
        "wires": [
            [
                "b64768f6.d049d8"
            ]
        ]
    },
    {
        "id": "bdf673f6.71fba8",
        "type": "inject",
        "z": "a66658c7.550b58",
        "name": "",
        "topic": "",
        "payload": "3b5998",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 1130,
        "y": 840,
        "wires": [
            [
                "8ce5e25d.17d4"
            ]
        ]
    },
    {
        "id": "4099cfb6.c7903",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "blue",
        "info": "",
        "x": 1130,
        "y": 800,
        "wires": []
    },
    {
        "id": "88d99b3.b59b568",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "rose light",
        "info": "",
        "x": 1140,
        "y": 620,
        "wires": []
    },
    {
        "id": "c79c8b4a.0d3018",
        "type": "inject",
        "z": "a66658c7.550b58",
        "name": "",
        "topic": "",
        "payload": "ff052b",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 1130,
        "y": 660,
        "wires": [
            [
                "8ce5e25d.17d4"
            ]
        ]
    },
    {
        "id": "74b535ca.f6f42c",
        "type": "inject",
        "z": "a66658c7.550b58",
        "name": "",
        "topic": "",
        "payload": "25525500",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 1140,
        "y": 740,
        "wires": [
            [
                "8ce5e25d.17d4"
            ]
        ]
    },
    {
        "id": "bc34c3f.1f533c",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "yellow",
        "info": "",
        "x": 1130,
        "y": 700,
        "wires": []
    },
    {
        "id": "f7c7a1e3.715438",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "use rgb code for colore",
        "info": "",
        "x": 1180,
        "y": 580,
        "wires": []
    },
    {
        "id": "964fed94.f8d07",
        "type": "inject",
        "z": "a66658c7.550b58",
        "name": "",
        "topic": "",
        "payload": "0168107",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 1140,
        "y": 920,
        "wires": [
            [
                "8ce5e25d.17d4"
            ]
        ]
    },
    {
        "id": "4fea5244.f7857c",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "green (jade)",
        "info": "",
        "x": 1150,
        "y": 880,
        "wires": []
    },
    {
        "id": "ff5974a4.ad7fa",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "off light",
        "info": "",
        "x": 770,
        "y": 780,
        "wires": []
    },
    {
        "id": "de1be05a.f80a78",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "on light",
        "info": "",
        "x": 770,
        "y": 700,
        "wires": []
    },
    {
        "id": "11bcb3e9.21585c",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "dimmer 10%",
        "info": "",
        "x": 950,
        "y": 700,
        "wires": []
    },
    {
        "id": "2ca7693d.efac0e",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "dimmer 100%",
        "info": "",
        "x": 950,
        "y": 780,
        "wires": []
    },
    {
        "id": "8bd93765.129008",
        "type": "switch",
        "z": "a66658c7.550b58",
        "name": "only true can go ",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 670,
        "y": 340,
        "wires": [
            [
                "13edfbbe.d9906c",
                "cd3f8ab7.0eca08"
            ]
        ]
    },
    {
        "id": "cd3f8ab7.0eca08",
        "type": "trigger",
        "z": "a66658c7.550b58",
        "op1": "",
        "op2": "0",
        "op1type": "nul",
        "op2type": "num",
        "duration": "5",
        "extend": true,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "name": "Switch off delay",
        "x": 970,
        "y": 440,
        "wires": [
            [
                "289711e6.f11e5e",
                "68772b5c.25b88c"
            ]
        ]
    },
    {
        "id": "13edfbbe.d9906c",
        "type": "change",
        "z": "a66658c7.550b58",
        "name": "turn on light=rose",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "ff052b",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 970,
        "y": 300,
        "wires": [
            [
                "b0f9ddc5.20bec8",
                "8ce5e25d.17d4"
            ]
        ]
    },
    {
        "id": "b0f9ddc5.20bec8",
        "type": "debug",
        "z": "a66658c7.550b58",
        "name": "light сolour",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 950,
        "y": 260,
        "wires": []
    },
    {
        "id": "be57342b.3db75",
        "type": "inject",
        "z": "a66658c7.550b58",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 950,
        "y": 480,
        "wires": [
            [
                "cd3f8ab7.0eca08"
            ]
        ]
    },
    {
        "id": "289711e6.f11e5e",
        "type": "debug",
        "z": "a66658c7.550b58",
        "name": "Switch off delay colour",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 990,
        "y": 400,
        "wires": []
    },
    {
        "id": "42bbf4a.ddb650c",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "use only open state",
        "info": "",
        "x": 667.2166748046875,
        "y": 304.5333251953125,
        "wires": []
    },
    {
        "id": "ec572092.e9152",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "transform true to a/z = rgb light",
        "info": "",
        "x": 1010,
        "y": 220,
        "wires": []
    },
    {
        "id": "c41b84e3.0d613",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "xiaomi magnet",
        "info": "",
        "x": 140,
        "y": 220,
        "wires": []
    },
    {
        "id": "2da7ae59.6e0652",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "todo добавить проверку на яркость",
        "info": "",
        "x": 200,
        "y": 80,
        "wires": []
    },
    {
        "id": "b34db716.47b03",
        "type": "comment",
        "z": "a66658c7.550b58",
        "name": "зажигает определенным цветом шлюз xiaomi при открытии геркона, потом по таймеру выключает",
        "info": "",
        "x": 800,
        "y": 40,
        "wires": []
    }
]

OlegJktu
starter
Beiträge: 37
Registriert: 29.10.2017, 06:48

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von OlegJktu » 01.03.2018, 13:43

и тут через пол года обнаружилось, что все таки нужно кормить исполнителям в iobroker boolean true или false . Так что буду все свои 1 и 0 переписывать.
Spoiler: Show hidden text
Screenshot_20180301_144122.png

OlegJktu
starter
Beiträge: 37
Registriert: 29.10.2017, 06:48

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von OlegJktu » 22.03.2018, 07:29

усложненная версия включение света после рассвета/заката от геркона
добавлена кнопка для ручнных действий
изменено включение на boolean правда/ложь
кубик рассвет/закат нужно установить
Spoiler: Show hidden text
[img]
Screenshot_20180322_082024.png
Screenshot_20180322_082024.png (102.44 KiB) 1904 mal betrachtet
[/img]
Spoiler: Show hidden text

Code: Alles auswählen

[
    {
        "id": "6ac9c974.384968",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "instruction http://forums.opto22.com/t/sun-rise-set-inside-outside-light-control/1206",
        "info": "",
        "x": 1880,
        "y": 340,
        "wires": []
    },
    {
        "id": "626a2b09.b47c3c",
        "type": "sunrise",
        "z": "cb46759f.f0546",
        "name": "Sunrise",
        "lat": "34.745",
        "lon": "33.202",
        "start": "sunrise",
        "end": "sunset",
        "x": 1698.9999694824219,
        "y": 197.33331298828125,
        "wires": [
            [
                "a957fffa.db7b98"
            ],
            []
        ]
    },
    {
        "id": "5afbe96b.88fd28",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "The  sunrise node provide two outputs. The first output emits a msg.payload of 1 or 0 every minute depending if day-time (1) or night-time (0).",
        "info": "",
        "x": 2060,
        "y": 302.66668701171875,
        "wires": []
    },
    {
        "id": "478e60b1.e34a2",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "on outdoor ligt after sunset when gate is open and off light after 5 min",
        "info": "",
        "x": 678.1000061035156,
        "y": 20,
        "wires": []
    },
    {
        "id": "36ac190e.c8dfd6",
        "type": "ioBroker in",
        "z": "cb46759f.f0546",
        "name": "GATE_magnet_158d00018761d4.state is opened",
        "topic": "mihome.0.devices.magnet_158d00018761d4.state",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 257,
        "y": 247.86666870117188,
        "wires": [
            [
                "34ca1746.53007",
                "b0640f61.3d05e8"
            ]
        ]
    },
    {
        "id": "34ca1746.53007",
        "type": "debug",
        "z": "cb46759f.f0546",
        "name": "magnet_158d00018761d4.state",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 197.00003051757812,
        "y": 214.23333740234375,
        "wires": []
    },
    {
        "id": "3e9889a3.95a206",
        "type": "ioBroker in",
        "z": "cb46759f.f0546",
        "name": " workshop_magnet_158d00019f3001.state Is opened",
        "topic": "mihome.0.devices.magnet_158d00019f3001.state",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 276.9999694824219,
        "y": 340.8666687011719,
        "wires": [
            [
                "34f0e658.cd3cca",
                "b0640f61.3d05e8"
            ]
        ]
    },
    {
        "id": "34f0e658.cd3cca",
        "type": "debug",
        "z": "cb46759f.f0546",
        "name": "magnet_158d00019f3001.state",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 213.99990844726562,
        "y": 307.23333740234375,
        "wires": []
    },
    {
        "id": "b0640f61.3d05e8",
        "type": "switch",
        "z": "cb46759f.f0546",
        "name": "only true can go ",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "outputs": 1,
        "x": 671.8833312988281,
        "y": 256.8833312988281,
        "wires": [
            [
                "9a9335d.fada8c8"
            ]
        ]
    },
    {
        "id": "85144b0f.ed3c38",
        "type": "inject",
        "z": "cb46759f.f0546",
        "name": "",
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 1696.8833312988281,
        "y": 63.88330078125,
        "wires": [
            [
                "a957fffa.db7b98"
            ]
        ]
    },
    {
        "id": "191ee8fd.faa00f",
        "type": "inject",
        "z": "cb46759f.f0546",
        "name": "",
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 1696.8833312988281,
        "y": 103.88330078125,
        "wires": [
            [
                "a957fffa.db7b98"
            ]
        ]
    },
    {
        "id": "affc8f7f.a95b9",
        "type": "inject",
        "z": "cb46759f.f0546",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 203.88333129882812,
        "y": 130.13330078125,
        "wires": [
            [
                "b0640f61.3d05e8"
            ]
        ]
    },
    {
        "id": "998219b6.9fe0d",
        "type": "inject",
        "z": "cb46759f.f0546",
        "name": "",
        "topic": "",
        "payload": "false",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 203.88333129882812,
        "y": 166.13330078125,
        "wires": [
            [
                "b0640f61.3d05e8"
            ]
        ]
    },
    {
        "id": "a957fffa.db7b98",
        "type": "switch",
        "z": "cb46759f.f0546",
        "name": "Light Threshold Selector",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "0",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 1974.8832702636719,
        "y": 196.13336181640625,
        "wires": [
            [
                "462070c5.411e08",
                "870a9285.9b6d88"
            ],
            [
                "eec13355.379898",
                "abf36251.890f4"
            ]
        ]
    },
    {
        "id": "eec13355.379898",
        "type": "change",
        "z": "cb46759f.f0546",
        "name": "Enable Light",
        "rules": [
            {
                "t": "set",
                "p": "Light_enabled",
                "pt": "flow",
                "to": "Yes",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2192.5499267578125,
        "y": 223.41668701171875,
        "wires": [
            []
        ]
    },
    {
        "id": "462070c5.411e08",
        "type": "change",
        "z": "cb46759f.f0546",
        "name": "Disable Light",
        "rules": [
            {
                "t": "set",
                "p": "Light_enabled",
                "pt": "flow",
                "to": "No",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 2200.216552734375,
        "y": 165.933349609375,
        "wires": [
            []
        ]
    },
    {
        "id": "9a9335d.fada8c8",
        "type": "switch",
        "z": "cb46759f.f0546",
        "name": "Light Enabled?",
        "property": "Light_enabled",
        "propertyType": "flow",
        "rules": [
            {
                "t": "eq",
                "v": "Yes",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 873.8832702636719,
        "y": 259.1333312988281,
        "wires": [
            [
                "fac6bbcc.150b48",
                "a68bffb3.949ff"
            ]
        ]
    },
    {
        "id": "abf36251.890f4",
        "type": "debug",
        "z": "cb46759f.f0546",
        "name": "Enable Light",
        "active": true,
        "console": "false",
        "complete": "payload",
        "x": 1965.1000061035156,
        "y": 239.4832763671875,
        "wires": []
    },
    {
        "id": "870a9285.9b6d88",
        "type": "debug",
        "z": "cb46759f.f0546",
        "name": "Disable Light",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 1967.1000061035156,
        "y": 149.4832763671875,
        "wires": []
    },
    {
        "id": "a68bffb3.949ff",
        "type": "trigger",
        "z": "cb46759f.f0546",
        "op1": "",
        "op2": "false",
        "op1type": "nul",
        "op2type": "bool",
        "duration": "5",
        "extend": true,
        "units": "min",
        "reset": "",
        "bytopic": "all",
        "name": "Switch off delay",
        "x": 877.88330078125,
        "y": 362.1333312988281,
        "wires": [
            [
                "93ad5800.9f6eb",
                "c72be595.1351b8"
            ]
        ]
    },
    {
        "id": "fac6bbcc.150b48",
        "type": "change",
        "z": "cb46759f.f0546",
        "name": "turn light on",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1076.88330078125,
        "y": 258.1333312988281,
        "wires": [
            [
                "93ad5800.9f6eb",
                "c72be595.1351b8"
            ]
        ]
    },
    {
        "id": "93ad5800.9f6eb",
        "type": "ioBroker out",
        "z": "cb46759f.f0546",
        "name": "Outdoor Wall switch 0",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014a81c0.channel_0",
        "ack": "false",
        "autoCreate": "false",
        "x": 1421.0999755859375,
        "y": 253.11666870117188,
        "wires": []
    },
    {
        "id": "c72be595.1351b8",
        "type": "ioBroker out",
        "z": "cb46759f.f0546",
        "name": "Outdoor Wall switch 1",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014a81c0.channel_1",
        "ack": "false",
        "autoCreate": "false",
        "x": 1419.0999755859375,
        "y": 206.11666870117188,
        "wires": []
    },
    {
        "id": "da2930d3.54392",
        "type": "inject",
        "z": "cb46759f.f0546",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 650,
        "y": 380,
        "wires": [
            [
                "a68bffb3.949ff"
            ]
        ]
    },
    {
        "id": "a730a086.c9536",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "добавить проверку если свет включен вручную",
        "info": "",
        "x": 223.10000610351562,
        "y": 22.416671752929688,
        "wires": []
    },
    {
        "id": "50fea2fa.cfdeec",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "use only open state",
        "info": "",
        "x": 669.1000061035156,
        "y": 221.41665649414062,
        "wires": []
    },
    {
        "id": "54440158.f3c1d",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "Light Enable? logic \t",
        "info": "",
        "x": 2004.1000061035156,
        "y": 94.4166259765625,
        "wires": []
    },
    {
        "id": "13855cce.d47e0b",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "transform true to boolean true",
        "info": "",
        "x": 1105.0999755859375,
        "y": 289.4166564941406,
        "wires": []
    },
    {
        "id": "5c28d209.d7908c",
        "type": "inject",
        "z": "cb46759f.f0546",
        "name": "",
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 1110,
        "y": 60,
        "wires": [
            [
                "93ad5800.9f6eb",
                "c72be595.1351b8"
            ]
        ]
    },
    {
        "id": "e89a076b.9e796",
        "type": "inject",
        "z": "cb46759f.f0546",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 1110,
        "y": 100,
        "wires": [
            [
                "93ad5800.9f6eb",
                "c72be595.1351b8"
            ]
        ]
    },
    {
        "id": "7d5e3d7f.77248c",
        "type": "switch",
        "z": "cb46759f.f0546",
        "name": "only true can go ",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "outputs": 1,
        "x": 620,
        "y": 660,
        "wires": [
            [
                "fcec6a63.c39b8",
                "a68bffb3.949ff"
            ]
        ]
    },
    {
        "id": "fcec6a63.c39b8",
        "type": "change",
        "z": "cb46759f.f0546",
        "name": "turn light on",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 990,
        "y": 660,
        "wires": [
            [
                "c72be595.1351b8",
                "93ad5800.9f6eb"
            ]
        ]
    },
    {
        "id": "dcebfe1a.b17568",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "use only open state",
        "info": "",
        "x": 610,
        "y": 620,
        "wires": []
    },
    {
        "id": "dcd691d1.b462d8",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "transform true to boolean true",
        "info": "",
        "x": 1018.2166748046875,
        "y": 691.2833251953125,
        "wires": []
    },
    {
        "id": "e86a0bf3.8f1088",
        "type": "ioBroker in",
        "z": "cb46759f.f0546",
        "name": "Simple click",
        "topic": "mihome.0.devices.switch_158d00018b3ec2.click",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 150,
        "y": 600,
        "wires": [
            [
                "7d5e3d7f.77248c"
            ]
        ]
    },
    {
        "id": "4ae7bdc8.0ee354",
        "type": "ioBroker in",
        "z": "cb46759f.f0546",
        "name": "Long click",
        "topic": "mihome.0.devices.switch_158d00018b3ec2.long",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 140,
        "y": 660,
        "wires": [
            [
                "7d5e3d7f.77248c"
            ]
        ]
    },
    {
        "id": "6d7dfc8f.675164",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "Button in workshop",
        "info": "",
        "x": 150,
        "y": 540,
        "wires": []
    },
    {
        "id": "17500624.77184a",
        "type": "inject",
        "z": "cb46759f.f0546",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 150,
        "y": 740,
        "wires": [
            [
                "7d5e3d7f.77248c"
            ]
        ]
    },
    {
        "id": "70b2aa44.66bb44",
        "type": "inject",
        "z": "cb46759f.f0546",
        "name": "",
        "topic": "",
        "payload": "false",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "",
        "x": 150,
        "y": 776,
        "wires": [
            [
                "7d5e3d7f.77248c"
            ]
        ]
    },
    {
        "id": "2e6fc6e2.5a7f0a",
        "type": "ioBroker in",
        "z": "cb46759f.f0546",
        "name": "Double click",
        "topic": "mihome.0.devices.switch_158d00018b3ec2.double",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 150,
        "y": 980,
        "wires": [
            [
                "5c44adfc.2874e4"
            ]
        ]
    },
    {
        "id": "fe5ed37e.c754b",
        "type": "change",
        "z": "cb46759f.f0546",
        "name": "turn light off",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 980,
        "wires": [
            [
                "bc8e2b43.fe6888",
                "1c209343.871e7d"
            ]
        ]
    },
    {
        "id": "5c44adfc.2874e4",
        "type": "switch",
        "z": "cb46759f.f0546",
        "name": "only true can go ",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "outputs": 1,
        "x": 360,
        "y": 980,
        "wires": [
            [
                "fe5ed37e.c754b"
            ]
        ]
    },
    {
        "id": "1c209343.871e7d",
        "type": "ioBroker out",
        "z": "cb46759f.f0546",
        "name": "Outdoor Wall switch 0",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014a81c0.channel_0",
        "ack": "false",
        "autoCreate": "false",
        "x": 820,
        "y": 1000,
        "wires": []
    },
    {
        "id": "bc8e2b43.fe6888",
        "type": "ioBroker out",
        "z": "cb46759f.f0546",
        "name": "Outdoor Wall switch 1",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014a81c0.channel_1",
        "ack": "false",
        "autoCreate": "false",
        "x": 818,
        "y": 953,
        "wires": []
    },
    {
        "id": "80cea61f.bcd498",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "transform true to boolean false",
        "info": "",
        "x": 540,
        "y": 1020,
        "wires": []
    },
    {
        "id": "225e21ac.8c67f6",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "Turb on light when Simple Click and auto off (5 min)",
        "info": "",
        "x": 240,
        "y": 500,
        "wires": []
    },
    {
        "id": "91d6e72d.497cb8",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "Turn off light when Double Click xiaomi button",
        "info": "",
        "x": 190,
        "y": 940,
        "wires": []
    },
    {
        "id": "3c7a4a19.08b98e",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "I",
        "info": "",
        "x": 50,
        "y": 100,
        "wires": []
    },
    {
        "id": "e9affc54.6d159",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "II",
        "info": "",
        "x": 50,
        "y": 460,
        "wires": []
    },
    {
        "id": "8f32f343.3396b",
        "type": "comment",
        "z": "cb46759f.f0546",
        "name": "III",
        "info": "",
        "x": 50,
        "y": 900,
        "wires": []
    }
]

OlegJktu
starter
Beiträge: 37
Registriert: 29.10.2017, 06:48

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von OlegJktu » 22.03.2018, 07:41

супер простой пример отправки в телеграмм показаний температуры
буквально в 2 клика
в ежедневном использовании не удобен, но демонстрирует легкость использования всей связки
можно на основании примера сделать с сенсором движения и таймером или включением от кнопки - примитивная сигнализация.
Spoiler: Show hidden text
Выделение_003.png
Выделение_003.png (18.88 KiB) 1904 mal betrachtet
Spoiler: Show hidden text

Code: Alles auswählen

[
    {
        "id": "2489f4e.baaaf8c",
        "type": "ioBroker out",
        "z": "574f3b3e.d4abf4",
        "name": "Send text through telegram",
        "topic": "telegram.0.communicate.response",
        "ack": "false",
        "autoCreate": "false",
        "x": 500,
        "y": 160,
        "wires": []
    },
    {
        "id": "418735a7.2f9ed4",
        "type": "ioBroker in",
        "z": "574f3b3e.d4abf4",
        "name": "Temperature",
        "topic": "mihome.0.devices.sensor_ht_158d0001a2ac8c.temperature",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 90,
        "y": 160,
        "wires": [
            [
                "2489f4e.baaaf8c"
            ]
        ]
    },
    {
        "id": "729c5909.13793",
        "type": "comment",
        "z": "574f3b3e.d4abf4",
        "name": "простой пример отправки показаний температуры через telegram",
        "info": "",
        "x": 390,
        "y": 40,
        "wires": []
    },
    {
        "id": "3346ce5e.bfc1ba",
        "type": "comment",
        "z": "574f3b3e.d4abf4",
        "name": "температура датчик xiaomi",
        "info": "",
        "x": 140,
        "y": 120,
        "wires": []
    },
    {
        "id": "3fea008e.59c6e8",
        "type": "comment",
        "z": "574f3b3e.d4abf4",
        "name": "отправка в телеграм через драйвер ioBroker",
        "info": "",
        "x": 560,
        "y": 120,
        "wires": []
    },
    {
        "id": "215495b9.63d532",
        "type": "comment",
        "z": "574f3b3e.d4abf4",
        "name": "при изменении выдает новое значение",
        "info": "",
        "x": 180,
        "y": 200,
        "wires": []
    }
]

OlegJktu
starter
Beiträge: 37
Registriert: 29.10.2017, 06:48

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von OlegJktu » 29.04.2018, 13:07

Управление поливом с помощью Megad
Пример включения и выключения с кнопки
Участвуют, кнопка, датчик тока, тупой насос, клапан полива
Spoiler: Show hidden text
nod-red megad полив.png
Spoiler: Show hidden text

Code: Alles auswählen

[
    {
        "id": "46789dc2.3c2a44",
        "type": "comment",
        "z": "e3989afe.8977f",
        "name": "megad-328 управляет насосом и клапанами",
        "info": "",
        "x": 260,
        "y": 80,
        "wires": []
    },
    {
        "id": "33a9bbce.29e0dc",
        "type": "comment",
        "z": "e3989afe.8977f",
        "name": "Улица, полив",
        "info": "",
        "x": 150,
        "y": 40,
        "wires": []
    },
    {
        "id": "e0633c01.d000a8",
        "type": "comment",
        "z": "e3989afe.8977f",
        "name": "https://github.com/ioBroker/ioBroker.megad",
        "info": "",
        "x": 630,
        "y": 80,
        "wires": []
    },
    {
        "id": "941defa2.7bc51",
        "type": "ioBroker in",
        "z": "e3989afe.8977f",
        "name": "P0 Кнопка Полива",
        "topic": "megad.0.p0_P0_Кнопка_Полива",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 170,
        "y": 240,
        "wires": [
            [
                "2e48bd16.1c6af2"
            ]
        ]
    },
    {
        "id": "2e48bd16.1c6af2",
        "type": "switch",
        "z": "e3989afe.8977f",
        "name": "используем только  true",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 390,
        "y": 240,
        "wires": [
            [
                "93cc0e23.b69f1"
            ]
        ]
    },
    {
        "id": "93cc0e23.b69f1",
        "type": "trigger",
        "z": "e3989afe.8977f",
        "op1": "",
        "op2": "true",
        "op1type": "nul",
        "op2type": "str",
        "duration": "1",
        "extend": true,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "name": "защита от дребезга",
        "x": 620,
        "y": 240,
        "wires": [
            [
                "99201819.1550f",
                "c42febb8.9dc128"
            ]
        ]
    },
    {
        "id": "4368c932.80665",
        "type": "comment",
        "z": "e3989afe.8977f",
        "name": "Насос без реле давления, открываем поливочный клапан на 1 секунду раньше запуска насоса, избегаем гидроудара",
        "info": "",
        "x": 510,
        "y": 120,
        "wires": []
    },
    {
        "id": "c068cdcb.9d73c",
        "type": "ioBroker out",
        "z": "e3989afe.8977f",
        "name": "P13 насос",
        "topic": "megad.0.p13_P13_насос",
        "ack": "false",
        "autoCreate": "false",
        "x": 1330,
        "y": 160,
        "wires": []
    },
    {
        "id": "6f3f49ef.868208",
        "type": "ioBroker out",
        "z": "e3989afe.8977f",
        "name": "P7 клапан полива",
        "topic": "megad.0.p7_P7_клапан_полива",
        "ack": "false",
        "autoCreate": "false",
        "x": 1350,
        "y": 100,
        "wires": []
    },
    {
        "id": "5b4256ee.883bb",
        "type": "trigger",
        "z": "e3989afe.8977f",
        "op1": "",
        "op2": "true",
        "op1type": "nul",
        "op2type": "bool",
        "duration": "1",
        "extend": true,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "name": "задержка запуска насоса",
        "x": 1120,
        "y": 160,
        "wires": [
            [
                "c068cdcb.9d73c",
                "70f70af7.c5fdc4"
            ]
        ]
    },
    {
        "id": "fcae5628.9128b8",
        "type": "ioBroker out",
        "z": "e3989afe.8977f",
        "name": "P13 насос",
        "topic": "megad.0.p13_P13_насос",
        "ack": "false",
        "autoCreate": "false",
        "x": 1330,
        "y": 320,
        "wires": []
    },
    {
        "id": "44b8be25.efad08",
        "type": "ioBroker out",
        "z": "e3989afe.8977f",
        "name": "P7 клапан полива",
        "topic": "megad.0.p7_P7_клапан_полива",
        "ack": "false",
        "autoCreate": "false",
        "x": 1350,
        "y": 380,
        "wires": []
    },
    {
        "id": "1d8ba8ac.e64b5f",
        "type": "trigger",
        "z": "e3989afe.8977f",
        "op1": "",
        "op2": "false",
        "op1type": "nul",
        "op2type": "bool",
        "duration": "1",
        "extend": true,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "name": "задержка закрытия клапана",
        "x": 1090,
        "y": 320,
        "wires": [
            [
                "44b8be25.efad08",
                "25803339.499cf4"
            ]
        ]
    },
    {
        "id": "1524a368.575175",
        "type": "switch",
        "z": "e3989afe.8977f",
        "name": "WATER_PUMP_STATUS",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "true",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "false",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 500,
        "y": 480,
        "wires": [
            [
                "a40b4c82.f71cc8"
            ],
            [
                "824b2a03.fe3e6"
            ]
        ]
    },
    {
        "id": "a40b4c82.f71cc8",
        "type": "change",
        "z": "e3989afe.8977f",
        "name": "PUMP on",
        "rules": [
            {
                "t": "set",
                "p": "WATER_PUMP_STATUS",
                "pt": "flow",
                "to": "true",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 720,
        "y": 440,
        "wires": [
            []
        ]
    },
    {
        "id": "824b2a03.fe3e6",
        "type": "change",
        "z": "e3989afe.8977f",
        "name": "PUMP off",
        "rules": [
            {
                "t": "set",
                "p": "WATER_PUMP_STATUS",
                "pt": "flow",
                "to": "false",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 730,
        "y": 520,
        "wires": [
            []
        ]
    },
    {
        "id": "99201819.1550f",
        "type": "switch",
        "z": "e3989afe.8977f",
        "name": "Насос включен?",
        "property": "WATER_PUMP_STATUS",
        "propertyType": "flow",
        "rules": [
            {
                "t": "eq",
                "v": "false",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 830,
        "y": 240,
        "wires": [
            [
                "250c5e6f.ba05d2",
                "684b7ac1.b2f894"
            ],
            [
                "f6b74775.1674b",
                "18627b04.646b2d"
            ]
        ]
    },
    {
        "id": "65e49bf.8ed3064",
        "type": "comment",
        "z": "e3989afe.8977f",
        "name": "кнопка насоса передает кратко временное нажатие. Логика нажали кнопку - нужно совершить дейтствие. Включить или выключиь воду",
        "info": "",
        "x": 750,
        "y": 40,
        "wires": []
    },
    {
        "id": "c42febb8.9dc128",
        "type": "debug",
        "z": "e3989afe.8977f",
        "name": "P0 Кнопка Полива",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 560,
        "y": 320,
        "wires": []
    },
    {
        "id": "c520ce3f.6653",
        "type": "inject",
        "z": "e3989afe.8977f",
        "name": "Эмуляция нажатия кнопки",
        "topic": "",
        "payload": "true",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 160,
        "y": 320,
        "wires": [
            [
                "2e48bd16.1c6af2"
            ]
        ]
    },
    {
        "id": "250c5e6f.ba05d2",
        "type": "debug",
        "z": "e3989afe.8977f",
        "name": "включаем воду",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 850,
        "y": 200,
        "wires": []
    },
    {
        "id": "f6b74775.1674b",
        "type": "debug",
        "z": "e3989afe.8977f",
        "name": "выключаем воду",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 850,
        "y": 280,
        "wires": []
    },
    {
        "id": "f73c67af.2318f",
        "type": "ioBroker in",
        "z": "e3989afe.8977f",
        "name": "P6 Датчик тока на насосе",
        "topic": "megad.0.p6_P6_Датчик_тока_на_насосе",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 200,
        "y": 480,
        "wires": [
            [
                "9732da94.a91608",
                "1524a368.575175"
            ]
        ]
    },
    {
        "id": "9732da94.a91608",
        "type": "debug",
        "z": "e3989afe.8977f",
        "name": "P6 Датчик тока на насосе",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 210,
        "y": 440,
        "wires": []
    },
    {
        "id": "d974ed91.798988",
        "type": "inject",
        "z": "e3989afe.8977f",
        "name": "Эмуляция насос работает",
        "topic": "",
        "payload": "true",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 200,
        "y": 580,
        "wires": [
            [
                "1524a368.575175",
                "9732da94.a91608"
            ]
        ]
    },
    {
        "id": "3aff6ba2.f636bc",
        "type": "inject",
        "z": "e3989afe.8977f",
        "name": "Эмуляция насос выключен",
        "topic": "",
        "payload": "false",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 200,
        "y": 620,
        "wires": [
            [
                "1524a368.575175",
                "9732da94.a91608"
            ]
        ]
    },
    {
        "id": "70f70af7.c5fdc4",
        "type": "debug",
        "z": "e3989afe.8977f",
        "name": "Включаем насос",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 1570,
        "y": 160,
        "wires": []
    },
    {
        "id": "aa7d5953.99fb9",
        "type": "debug",
        "z": "e3989afe.8977f",
        "name": "Открываем клапан",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 1580,
        "y": 100,
        "wires": []
    },
    {
        "id": "cc4e41d1.9599b8",
        "type": "debug",
        "z": "e3989afe.8977f",
        "name": "Выключаем насос",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 1580,
        "y": 320,
        "wires": []
    },
    {
        "id": "25803339.499cf4",
        "type": "debug",
        "z": "e3989afe.8977f",
        "name": "закрываем клапан",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 1580,
        "y": 380,
        "wires": []
    },
    {
        "id": "684b7ac1.b2f894",
        "type": "change",
        "z": "e3989afe.8977f",
        "name": "включаеи воду",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1080,
        "y": 220,
        "wires": [
            [
                "5b4256ee.883bb",
                "6f3f49ef.868208",
                "aa7d5953.99fb9"
            ]
        ]
    },
    {
        "id": "18627b04.646b2d",
        "type": "change",
        "z": "e3989afe.8977f",
        "name": "выключаем воду",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1090,
        "y": 260,
        "wires": [
            [
                "1d8ba8ac.e64b5f",
                "fcae5628.9128b8",
                "cc4e41d1.9599b8"
            ]
        ]
    },
    {
        "id": "283b136.f00c86c",
        "type": "ioBroker in",
        "z": "e3989afe.8977f",
        "name": "P13 насос",
        "topic": "megad.0.p13_P13_насос",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 580,
        "y": 640,
        "wires": [
            [
                "1b2112ce.90a1f5"
            ]
        ]
    },
    {
        "id": "1b2112ce.90a1f5",
        "type": "debug",
        "z": "e3989afe.8977f",
        "name": "реле насос данные из ioBroker  (megad не отдает включение реле, сервер должен помнить сам или переодически опрашивать)",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 1150,
        "y": 640,
        "wires": []
    }
]
Zuletzt geändert von OlegJktu am 02.05.2018, 07:27, insgesamt 1-mal geändert.

OlegJktu
starter
Beiträge: 37
Registriert: 29.10.2017, 06:48

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von OlegJktu » 29.04.2018, 19:35

Управление выключателем xiaomi с реле с помощью кнопки xiaomi
однократное - включаем первую нагрузку
двойное - включаем вторую нагрузку
длинное - выключаем все
Spoiler: Show hidden text
Screenshot_20180429_212811.png
Spoiler: Show hidden text

Code: Alles auswählen

[
    {
        "id": "69a9ed68.238a84",
        "type": "ioBroker in",
        "z": "4ee7097b.356f",
        "name": "Simple click",
        "topic": "mihome.0.devices.switch_158d0001a2dd26.click",
        "payloadType": "value",
        "onlyack": false,
        "func": "all",
        "gap": "",
        "x": 190,
        "y": 300,
        "wires": [
            [
                "36bc6c90.9c9324",
                "745d4961.1a05"
            ]
        ]
    },
    {
        "id": "467664dc.4dbb14",
        "type": "ioBroker in",
        "z": "4ee7097b.356f",
        "name": "Double click",
        "topic": "mihome.0.devices.switch_158d0001a2dd26.double",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 190,
        "y": 460,
        "wires": [
            [
                "ac75359e.a18658",
                "379acba1.aa162c"
            ]
        ]
    },
    {
        "id": "7f082a3.20eb054",
        "type": "ioBroker in",
        "z": "4ee7097b.356f",
        "name": "Long click",
        "topic": "mihome.0.devices.switch_158d0001a2dd26.long",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 180,
        "y": 640,
        "wires": [
            [
                "e02a9e6.202296",
                "509fcc41.fa17f4"
            ]
        ]
    },
    {
        "id": "3095b95f.a9e6c6",
        "type": "comment",
        "z": "4ee7097b.356f",
        "name": "Xiaomi button",
        "info": "",
        "x": 190,
        "y": 160,
        "wires": []
    },
    {
        "id": "36bc6c90.9c9324",
        "type": "debug",
        "z": "4ee7097b.356f",
        "name": "Simple click",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 190,
        "y": 260,
        "wires": []
    },
    {
        "id": "ac75359e.a18658",
        "type": "debug",
        "z": "4ee7097b.356f",
        "name": "Double click",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 190,
        "y": 420,
        "wires": []
    },
    {
        "id": "e02a9e6.202296",
        "type": "debug",
        "z": "4ee7097b.356f",
        "name": "Long click",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 180,
        "y": 600,
        "wires": []
    },
    {
        "id": "509fcc41.fa17f4",
        "type": "switch",
        "z": "4ee7097b.356f",
        "name": "only true can go ",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 440,
        "y": 640,
        "wires": [
            [
                "3dad983e.35515"
            ]
        ]
    },
    {
        "id": "3dad983e.35515",
        "type": "change",
        "z": "4ee7097b.356f",
        "name": "turn off light ",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 684.9999694824219,
        "y": 641.25,
        "wires": [
            [
                "4c4c1867.8ee4e8",
                "d6794d95.06d58",
                "4bd2fa2c.3a68dc"
            ]
        ]
    },
    {
        "id": "4c4c1867.8ee4e8",
        "type": "debug",
        "z": "4ee7097b.356f",
        "name": "выключаем все",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 710,
        "y": 600,
        "wires": []
    },
    {
        "id": "31141ed2.4e3ffa",
        "type": "comment",
        "z": "4ee7097b.356f",
        "name": "use only true",
        "info": "",
        "x": 430,
        "y": 600,
        "wires": []
    },
    {
        "id": "11f80759.28aeb1",
        "type": "comment",
        "z": "4ee7097b.356f",
        "name": "transform string true to boolean false",
        "info": "",
        "x": 700,
        "y": 680,
        "wires": []
    },
    {
        "id": "379acba1.aa162c",
        "type": "switch",
        "z": "4ee7097b.356f",
        "name": "only true can go ",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 440,
        "y": 460,
        "wires": [
            [
                "8ec236c2.32943"
            ]
        ]
    },
    {
        "id": "7b52b34d.b9df4c",
        "type": "comment",
        "z": "4ee7097b.356f",
        "name": "use only true",
        "info": "",
        "x": 430,
        "y": 420,
        "wires": []
    },
    {
        "id": "745d4961.1a05",
        "type": "switch",
        "z": "4ee7097b.356f",
        "name": "only true can go ",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 440,
        "y": 300,
        "wires": [
            [
                "92164e8f.1ec86"
            ]
        ]
    },
    {
        "id": "522d7bad.c43f34",
        "type": "comment",
        "z": "4ee7097b.356f",
        "name": "use only true",
        "info": "",
        "x": 430,
        "y": 260,
        "wires": []
    },
    {
        "id": "8ec236c2.32943",
        "type": "change",
        "z": "4ee7097b.356f",
        "name": "turn light on",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 670,
        "y": 460,
        "wires": [
            [
                "7ea19fca.814e2",
                "717cb955.c6f5f"
            ]
        ]
    },
    {
        "id": "92164e8f.1ec86",
        "type": "change",
        "z": "4ee7097b.356f",
        "name": "turn light on",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 670,
        "y": 300,
        "wires": [
            [
                "71059890.74a9e",
                "b0b19ebb.e07358"
            ]
        ]
    },
    {
        "id": "7ea19fca.814e2",
        "type": "ioBroker out",
        "z": "4ee7097b.356f",
        "name": "Outdoor Wall switch 0",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014a81c0.channel_0",
        "ack": "false",
        "autoCreate": "false",
        "x": 1000,
        "y": 460,
        "wires": []
    },
    {
        "id": "71059890.74a9e",
        "type": "ioBroker out",
        "z": "4ee7097b.356f",
        "name": "Outdoor Wall switch 1",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014a81c0.channel_1",
        "ack": "false",
        "autoCreate": "false",
        "x": 998,
        "y": 293,
        "wires": []
    },
    {
        "id": "d6794d95.06d58",
        "type": "ioBroker out",
        "z": "4ee7097b.356f",
        "name": "Outdoor Wall switch 0",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014a81c0.channel_0",
        "ack": "false",
        "autoCreate": "false",
        "x": 1000,
        "y": 620,
        "wires": []
    },
    {
        "id": "4bd2fa2c.3a68dc",
        "type": "ioBroker out",
        "z": "4ee7097b.356f",
        "name": "Outdoor Wall switch 1",
        "topic": "mihome.0.devices.ctrl_neutral2_158d00014a81c0.channel_1",
        "ack": "false",
        "autoCreate": "false",
        "x": 998,
        "y": 573,
        "wires": []
    },
    {
        "id": "e4ef99e8.9f5c6",
        "type": "comment",
        "z": "4ee7097b.356f",
        "name": "реле xiaomi",
        "info": "",
        "x": 1010,
        "y": 220,
        "wires": []
    },
    {
        "id": "717cb955.c6f5f",
        "type": "debug",
        "z": "4ee7097b.356f",
        "name": "зажигаем по двойному",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 710,
        "y": 400,
        "wires": []
    },
    {
        "id": "b0b19ebb.e07358",
        "type": "debug",
        "z": "4ee7097b.356f",
        "name": "зажигаем по одиночному",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 720,
        "y": 240,
        "wires": []
    }
]

Sergey777
starter
Beiträge: 31
Registriert: 27.01.2018, 22:00

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von Sergey777 » 01.05.2018, 08:21

Кто поможет реализовать переключение в Node-RED? Нужно чтоб один раз пришел сигнал - реле включилось. Проверка статуса, если второй раз сигнал пришёл, то состояние реле переключилось из true в false. (Сигнал от кнопки - "true").
В JS скриптах в Blockly есть такой готовый функционал, но мне интересно знать как это сделать в Node-RED.
Пааамааагитеее!

OlegJktu
starter
Beiträge: 37
Registriert: 29.10.2017, 06:48

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von OlegJktu » 02.05.2018, 07:33

Sergey777 hat geschrieben:
01.05.2018, 08:21
Кто поможет реализовать переключение в Node-RED? Нужно чтоб один раз пришел сигнал - реле включилось. Проверка статуса, если второй раз сигнал пришёл, то состояние реле переключилось из true в false. (Сигнал от кнопки - "true").
...

Вот в этом примере Управление поливом с помощью Megad viewtopic.php?f=48&t=11969&p=146339#p146339

Включается и выключается реле с одинакового триггера (события? какой термин лучше?).
Там конечно в связи с железной реализацией статус берется с датчика тока, но можно и статус реле брать из ioBroker.

По сути вы заводите поток, который работает как стрелка у поезда и переводит логику на разные ветки. В примере две ветки завязаны на статус датчика тока. А кнопка одна и сигнал с нее всегда используется один.
Хотя на практике при управлении скажем групповыми объектами это просто физически не удобно. Лучше использовать разные триггеры.

Sergey777
starter
Beiträge: 31
Registriert: 27.01.2018, 22:00

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von Sergey777 » 02.05.2018, 19:41

Управление устройством Sonoff POW с прошивкой Sonoff-Tasmota 5.12.0 by Theo Arends с помощью кнопки Xiaomi Smart Wireless Switch способом переключателя: оно нажатие - включение, повторное одиночное нажатие - выключение в Node-RED.
Switch_Sonoff-Tasmota.PNG
Spoiler: Show hidden text

Code: Alles auswählen

[
    {
        "id": "3d24ecec.e06e74",
        "type": "ioBroker in",
        "z": "592d1520.8a0b7c",
        "name": "Sonoff_POW_2",
        "topic": "sonoff.0.Sonoff_POW_2_A02EBD.POWER",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 100,
        "y": 100,
        "wires": [
            [
                "27d901f5.d4750e"
            ]
        ]
    },
    {
        "id": "6f767919.8e2a08",
        "type": "ioBroker in",
        "z": "592d1520.8a0b7c",
        "name": "Simple click",
        "topic": "mihome.0.devices.switch_158d0001f35894.click",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 90,
        "y": 240,
        "wires": [
            [
                "968c2eb2.8acea"
            ]
        ]
    },
    {
        "id": "968c2eb2.8acea",
        "type": "switch",
        "z": "592d1520.8a0b7c",
        "name": "Берём только  true",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 310,
        "y": 240,
        "wires": [
            [
                "8e6a94c5.d104d8"
            ]
        ]
    },
    {
        "id": "8e6a94c5.d104d8",
        "type": "switch",
        "z": "592d1520.8a0b7c",
        "name": "Sonoff включен?",
        "property": "SONOFF_STATUS",
        "propertyType": "flow",
        "rules": [
            {
                "t": "eq",
                "v": "false",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 530,
        "y": 240,
        "wires": [
            [
                "c050f5a9.d5b6e8"
            ],
            [
                "ae48a910.728298"
            ]
        ]
    },
    {
        "id": "c050f5a9.d5b6e8",
        "type": "change",
        "z": "592d1520.8a0b7c",
        "name": "Включаем Sonoff",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 750,
        "y": 200,
        "wires": [
            [
                "1a869456.60fd4c",
                "50071ed6.6539"
            ]
        ]
    },
    {
        "id": "ae48a910.728298",
        "type": "change",
        "z": "592d1520.8a0b7c",
        "name": "Отключаем Sonoff",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 750,
        "y": 280,
        "wires": [
            [
                "e49adeee.4b67c",
                "4b2f12f9.8b6b0c"
            ]
        ]
    },
    {
        "id": "50071ed6.6539",
        "type": "ioBroker out",
        "z": "592d1520.8a0b7c",
        "name": "Sonoff_POW_2",
        "topic": "sonoff.0.Sonoff_POW_2_A02EBD.POWER",
        "ack": "false",
        "autoCreate": "false",
        "x": 960,
        "y": 200,
        "wires": []
    },
    {
        "id": "4b2f12f9.8b6b0c",
        "type": "ioBroker out",
        "z": "592d1520.8a0b7c",
        "name": "Sonoff_POW_2",
        "topic": "sonoff.0.Sonoff_POW_2_A02EBD.POWER",
        "ack": "false",
        "autoCreate": "false",
        "x": 960,
        "y": 280,
        "wires": []
    },
    {
        "id": "27d901f5.d4750e",
        "type": "switch",
        "z": "592d1520.8a0b7c",
        "name": "Передаём статус Sonoff",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "true",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "false",
                "vt": "str"
            }
        ],
        "checkall": "false",
        "repair": false,
        "outputs": 2,
        "x": 330,
        "y": 100,
        "wires": [
            [
                "95638670.fa4628"
            ],
            [
                "826333d5.a331d"
            ]
        ]
    },
    {
        "id": "95638670.fa4628",
        "type": "change",
        "z": "592d1520.8a0b7c",
        "name": "Sonoff ON",
        "rules": [
            {
                "t": "set",
                "p": "SONOFF_STATUS",
                "pt": "flow",
                "to": "true",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 570,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "826333d5.a331d",
        "type": "change",
        "z": "592d1520.8a0b7c",
        "name": "Sonoff OFF",
        "rules": [
            {
                "t": "set",
                "p": "SONOFF_STATUS",
                "pt": "flow",
                "to": "false",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 570,
        "y": 120,
        "wires": [
            []
        ]
    },
    {
        "id": "1a869456.60fd4c",
        "type": "debug",
        "z": "592d1520.8a0b7c",
        "name": "Включаем",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 950,
        "y": 140,
        "wires": []
    },
    {
        "id": "e49adeee.4b67c",
        "type": "debug",
        "z": "592d1520.8a0b7c",
        "name": "Отключаем",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 950,
        "y": 340,
        "wires": []
    },
    {
        "id": "31ce9e04.577692",
        "type": "comment",
        "z": "592d1520.8a0b7c",
        "name": "Тут логика работы",
        "info": "",
        "x": 310,
        "y": 180,
        "wires": []
    },
    {
        "id": "c6fc3258.f4318",
        "type": "comment",
        "z": "592d1520.8a0b7c",
        "name": "Тут определяем состояние реле Sonoff",
        "info": "",
        "x": 330,
        "y": 40,
        "wires": []
    }
]
P.S. Идею подсказал выше OlegJktu, подсмотрено тут: viewtopic.php?f=48&t=11969&p=146339#p146339

OlegJktu
starter
Beiträge: 37
Registriert: 29.10.2017, 06:48

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von OlegJktu » 06.05.2018, 18:25

1) спасибо, что выложили.
2) 5+ за оформление.

Sergey777
starter
Beiträge: 31
Registriert: 27.01.2018, 22:00

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von Sergey777 » 31.05.2018, 20:38

Пожалуй, приведу ещё примерчик. Вывод даты и времени в нужном формате.
Дата время - это системное время вашего сервера iobroker.
timeFormat.PNG
Spoiler: Show hidden text

Code: Alles auswählen

[
    {
        "id": "72f2c7dc.bf9298",
        "type": "function",
        "z": "ee32e2c4.bc665",
        "name": "FormatTime",
        "func": "var now     = new Date(); \nvar year    = now.getFullYear();\nvar month   = now.getMonth()+1; \nvar day     = now.getDate();\nvar hour    = now.getHours();\nvar minute  = now.getMinutes();\nvar second  = now.getSeconds(); \nif(month.toString().length == 1) {\nvar month = '0'+month;\n}\nif(day.toString().length == 1) {\nvar day = '0'+day;\n}   \nif(hour.toString().length == 1) {\nvar hour = '0'+hour;\n}\nif(minute.toString().length == 1) {\nvar minute = '0'+minute;\n}\nif(second.toString().length == 1) {\nvar second = '0'+second;\n}   \n//msg.timestamp = hour+':'+minute+':'+second+' '+day+'.'+month+'.'+year;\n//msg.timestamp = hour+':'+minute+':'+second+' '+day+'.'+month+'.'+year;\n//msg.timestamp = hour+'ч'+minute+'м'+second+'c';\nmsg.timestamp = hour+':'+minute+':'+second;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 290,
        "y": 120,
        "wires": [
            [
                "f59066e5.1b1ea8"
            ]
        ]
    },
    {
        "id": "904cda57.320dd8",
        "type": "inject",
        "z": "ee32e2c4.bc665",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 110,
        "y": 120,
        "wires": [
            [
                "72f2c7dc.bf9298"
            ]
        ]
    },
    {
        "id": "f59066e5.1b1ea8",
        "type": "debug",
        "z": "ee32e2c4.bc665",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "timestamp",
        "x": 480,
        "y": 120,
        "wires": []
    }
]
В блоке function, который я обозвал FormatTime, написан скрипт. В закоментированных строках 23,24,25 примеры вывода.
Если внимательно присмотреться к первому скрину, то видим, что время события в логе и время переданное в сообщении разнится на час. Это потому, что на компьютере в браузере одно время, а в моей Raspberry другой часовой пояс. Устанавливаем корректное время в малине, и снова выводим сообщение:
timeFormat2.PNG
Теперь всё совпадает.
P.S. Я понимаю, для кого-то это азы, как азбука. Но я новичок, и потратил какое-то время на поиски и доработки этого кода. Думаю не будет лишним для форумчан.

Sergey777
starter
Beiträge: 31
Registriert: 27.01.2018, 22:00

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von Sergey777 » 31.05.2018, 22:34

Приобрёл я как-то датчики открытия двери Door Sensor Aqara MCCGQ11LM (Вот, к примеру,обзор), установил. Так как мы тут обсуждаем альтернативную систему умного дома, то завёл датчики в NODE-RED iobroker'a. Мне нужно было получать оповещения, когда дверь открывается и закрывается. Отправку этих оповещений я реализовал через WebHook, но Вы можете отправить их куда угодно, например в Telegramm.
Spoiler: Show hidden text
Небольшое отступление:
У меня есть NAS бренда Synology, а для операционной системы DSM, которая работает в NAS, есть приложение Chat - это такой чатик, типа WhatsApp или Telegramm, но слегка по проще, поднятый на своём собственном NAS, имеет приложения для Windows, IOS, Android и просто работает через web браузер. Я решил получать оповещения именно в этот чат, так как в семье активно им пользуемся.
У данного чата есть возможность принимать сообщения WebHook и передавать их определённому пользователю или группе(каналу). Собственно отправку WebHook я и реализовал в NODE-RED. Кроме отправки уведомлений, я отправляю команду камере, камера по этой команде делает серию скринов, которые потом можно просмотреть.
Но вскоре меня ждал сюрприз, о котором нигде я не смог найти информации. Как оказалось Door Sensor постоянно шлёт контрольный сигнал со статусом последнего события. Мои датчики шлют false или true каждые 50 минут 15 сек +/- 10 сек. Если дверь закрыта и состояние false, то каждые 50 минут прилетает false. Если было последнее событие true, то каждые 50 минут присылает true. Таким образом датчик говорит нам, что он тут, он работает, сигнал доходит, всё нормально. Ну раз так, то придётся использовать это во благо. И так, представляю свой алгоритм:
DoorSensor.PNG
Spoiler: Show hidden text

Code: Alles auswählen

[
    {
        "id": "1aeb151d.c59e5b",
        "type": "debug",
        "z": "84c517f4.99a9d8",
        "name": "Door Sensor Status",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 1150,
        "y": 520,
        "wires": []
    },
    {
        "id": "9d4c980c.2ae028",
        "type": "ioBroker in",
        "z": "84c517f4.99a9d8",
        "name": "Дверь: Is opened",
        "topic": "mihome.0.devices.magnet_158d000204a13f.state",
        "payloadType": "value",
        "onlyack": "",
        "func": "all",
        "gap": "",
        "x": 100,
        "y": 100,
        "wires": [
            [
                "ee85c4c6.465928",
                "cdead55f.15fd68",
                "8f07a637.ea61d8",
                "60b595ae.188ecc"
            ]
        ]
    },
    {
        "id": "ee85c4c6.465928",
        "type": "rbe",
        "z": "84c517f4.99a9d8",
        "name": "",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "property": "payload",
        "x": 230,
        "y": 520,
        "wires": [
            [
                "bf1f32e6.64566"
            ]
        ]
    },
    {
        "id": "f95f7441.dbefd8",
        "type": "inject",
        "z": "84c517f4.99a9d8",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 90,
        "y": 500,
        "wires": [
            [
                "ee85c4c6.465928"
            ]
        ]
    },
    {
        "id": "1fd5e312.859f5d",
        "type": "inject",
        "z": "84c517f4.99a9d8",
        "name": "",
        "topic": "",
        "payload": "false",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 90,
        "y": 540,
        "wires": [
            [
                "ee85c4c6.465928"
            ]
        ]
    },
    {
        "id": "c8540540.ae8f58",
        "type": "debug",
        "z": "84c517f4.99a9d8",
        "name": "Alarm!!!",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 1180,
        "y": 140,
        "wires": []
    },
    {
        "id": "cdead55f.15fd68",
        "type": "trigger",
        "z": "84c517f4.99a9d8",
        "op1": "",
        "op2": "Датчик потерян!!!",
        "op1type": "nul",
        "op2type": "str",
        "duration": "51",
        "extend": true,
        "units": "min",
        "reset": "",
        "bytopic": "all",
        "name": "",
        "x": 310,
        "y": 160,
        "wires": [
            [
                "43366ff3.584b9",
                "e4dac972.f0da88",
                "1af60a78.c2b8f6"
            ]
        ]
    },
    {
        "id": "8f07a637.ea61d8",
        "type": "debug",
        "z": "84c517f4.99a9d8",
        "name": "Все статусы двери",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 1150,
        "y": 100,
        "wires": []
    },
    {
        "id": "4af07332.c31ebc",
        "type": "http request",
        "z": "84c517f4.99a9d8",
        "name": "Открыта дверь",
        "method": "POST",
        "ret": "txt",
        "url": "https://mydomen.com/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=mytokenlongmytokenlooong&payload={\"text\": \":negative_squared_cross_mark: Открыта дверь  {{{timestamp}}}\"}",
        "tls": "",
        "x": 940,
        "y": 500,
        "wires": [
            [
                "1aeb151d.c59e5b"
            ]
        ]
    },
    {
        "id": "e871555e.9092c8",
        "type": "http request",
        "z": "84c517f4.99a9d8",
        "name": "Закрыта дверь",
        "method": "POST",
        "ret": "txt",
        "url": "https://mydomen.com/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=mytokenlongmytokenlooong&payload={\"text\": \":white_check_mark: Закрыта дверь  {{{timestamp}}}\"}",
        "tls": "",
        "x": 940,
        "y": 540,
        "wires": [
            [
                "1aeb151d.c59e5b"
            ]
        ]
    },
    {
        "id": "d89df571.d12d58",
        "type": "change",
        "z": "84c517f4.99a9d8",
        "name": "Door Opened",
        "rules": [
            {
                "t": "set",
                "p": "DOOR_SENSOR_VHOD_STATUS",
                "pt": "flow",
                "to": "true",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 580,
        "y": 500,
        "wires": [
            [
                "fc67fce9.c5769",
                "c0483154.d949"
            ]
        ]
    },
    {
        "id": "9b119486.99ec68",
        "type": "change",
        "z": "84c517f4.99a9d8",
        "name": "Door Closed",
        "rules": [
            {
                "t": "set",
                "p": "DOOR_SENSOR_VHOD_STATUS",
                "pt": "flow",
                "to": "false",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 590,
        "y": 540,
        "wires": [
            [
                "9adfd17e.42ebe",
                "c0483154.d949"
            ]
        ]
    },
    {
        "id": "bf1f32e6.64566",
        "type": "switch",
        "z": "84c517f4.99a9d8",
        "name": "Делим состояния",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "true",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "false",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 390,
        "y": 520,
        "wires": [
            [
                "d89df571.d12d58"
            ],
            [
                "9b119486.99ec68"
            ]
        ]
    },
    {
        "id": "8f3fa46.4374758",
        "type": "http request",
        "z": "84c517f4.99a9d8",
        "name": "Тревога!!",
        "method": "POST",
        "ret": "txt",
        "url": "https://mydomen.com/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=mytokenlongmytokenlooong&payload={\"text\": \":warning:\\nДатчик входной двери не отвечает!!!\\nСостояние не будет отображаться.\\nПроверьте датчик!\\n{{{timestamp}}}\\n*****\"}",
        "tls": "",
        "x": 960,
        "y": 140,
        "wires": [
            [
                "c8540540.ae8f58"
            ]
        ]
    },
    {
        "id": "43366ff3.584b9",
        "type": "debug",
        "z": "84c517f4.99a9d8",
        "name": "Alarm 1!!!",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 1180,
        "y": 180,
        "wires": []
    },
    {
        "id": "60b595ae.188ecc",
        "type": "change",
        "z": "84c517f4.99a9d8",
        "name": "alarm_reset",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "reset_alarm_message_resend",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 350,
        "y": 400,
        "wires": [
            [
                "a140ee35.eb306"
            ]
        ]
    },
    {
        "id": "e4dac972.f0da88",
        "type": "delay",
        "z": "84c517f4.99a9d8",
        "name": "",
        "pauseType": "delay",
        "timeout": "2",
        "timeoutUnits": "hours",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 380,
        "y": 280,
        "wires": [
            [
                "a140ee35.eb306"
            ]
        ]
    },
    {
        "id": "a140ee35.eb306",
        "type": "trigger",
        "z": "84c517f4.99a9d8",
        "op1": "",
        "op2": "Датчик потерян!!!",
        "op1type": "pay",
        "op2type": "str",
        "duration": "-2",
        "extend": true,
        "units": "hr",
        "reset": "reset_alarm_message_resend",
        "bytopic": "all",
        "name": "",
        "x": 570,
        "y": 280,
        "wires": [
            [
                "633cd7fc.a57828"
            ]
        ]
    },
    {
        "id": "c2a947ee.7a9ba8",
        "type": "debug",
        "z": "84c517f4.99a9d8",
        "name": "Повтор сообщения",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "x": 1140,
        "y": 280,
        "wires": []
    },
    {
        "id": "93e5590d.d5f328",
        "type": "comment",
        "z": "84c517f4.99a9d8",
        "name": "Если от Door Sensor нет ни одного сообщения в течение 51 минуты, шлём сообщение об аварии",
        "info": "",
        "x": 370,
        "y": 60,
        "wires": []
    },
    {
        "id": "e3926866.fb3ef8",
        "type": "comment",
        "z": "84c517f4.99a9d8",
        "name": "Если после отсылки аварийного сообщения снова нет сообщений от Door Sensor, то повторяем отправку аварийного сообщения через два часа и каждые два часа",
        "info": "",
        "x": 560,
        "y": 240,
        "wires": []
    },
    {
        "id": "74aa47b.7cba4b8",
        "type": "comment",
        "z": "84c517f4.99a9d8",
        "name": "Если какое-либо сообщение от Door Sensor пришло, считаем что всё в порядке и сбрасываем повторную отправку аварийных сообщений",
        "info": "",
        "x": 480,
        "y": 360,
        "wires": []
    },
    {
        "id": "8c3f52d4.a0dd2",
        "type": "http request",
        "z": "84c517f4.99a9d8",
        "name": "Тревога повторно!",
        "method": "POST",
        "ret": "txt",
        "url": "https://mydomen.com/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=mytokenlongmytokenlooong&payload={\"text\": \":exclamation: :warning: :exclamation:\\nALARM!!!\\nДатчик входной двери не отвечает!!!\\nСостояние не будет отображаться.\\nПроверьте датчик!\\n{{{timestamp}}}\\n*****\"}",
        "tls": "",
        "x": 930,
        "y": 280,
        "wires": [
            [
                "c2a947ee.7a9ba8"
            ]
        ]
    },
    {
        "id": "f18c64e0.259e88",
        "type": "comment",
        "z": "84c517f4.99a9d8",
        "name": "При каждом изменении состояния Door Sensor отправляем сообщение ",
        "info": "",
        "x": 260,
        "y": 460,
        "wires": []
    },
    {
        "id": "c0483154.d949",
        "type": "http request",
        "z": "84c517f4.99a9d8",
        "name": "Команда камере",
        "method": "POST",
        "ret": "txt",
        "url": "https://mysurveillancedomen.com/webapi/entry.cgi?api=SYNO.SurveillanceStation.ExternalEvent&method=\"Trigger\"&version=1&eventId=1&eventName=\"This is external event1\"&account=\"root\"&password=\"123456\"",
        "tls": "",
        "x": 810,
        "y": 660,
        "wires": [
            []
        ]
    },
    {
        "id": "1af60a78.c2b8f6",
        "type": "function",
        "z": "84c517f4.99a9d8",
        "name": "FormatTime",
        "func": "var now     = new Date(); \nvar year    = now.getFullYear();\nvar month   = now.getMonth()+1; \nvar day     = now.getDate();\nvar hour    = now.getHours();\nvar minute  = now.getMinutes();\nvar second  = now.getSeconds(); \nif(month.toString().length == 1) {\nvar month = '0'+month;\n}\nif(day.toString().length == 1) {\nvar day = '0'+day;\n}   \nif(hour.toString().length == 1) {\nvar hour = '0'+hour;\n}\nif(minute.toString().length == 1) {\nvar minute = '0'+minute;\n}\nif(second.toString().length == 1) {\nvar second = '0'+second;\n}   \nmsg.timestamp = hour+':'+minute+':'+second+' '+day+'.'+month+'.'+year;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 810,
        "y": 140,
        "wires": [
            [
                "8f3fa46.4374758"
            ]
        ]
    },
    {
        "id": "9adfd17e.42ebe",
        "type": "function",
        "z": "84c517f4.99a9d8",
        "name": "FormatTime",
        "func": "var now     = new Date(); \nvar year    = now.getFullYear();\nvar month   = now.getMonth()+1; \nvar day     = now.getDate();\nvar hour    = now.getHours();\nvar minute  = now.getMinutes();\nvar second  = now.getSeconds(); \nif(month.toString().length == 1) {\nvar month = '0'+month;\n}\nif(day.toString().length == 1) {\nvar day = '0'+day;\n}   \nif(hour.toString().length == 1) {\nvar hour = '0'+hour;\n}\nif(minute.toString().length == 1) {\nvar minute = '0'+minute;\n}\nif(second.toString().length == 1) {\nvar second = '0'+second;\n}   \n//msg.timestamp = hour+':'+minute+':'+second+' '+day+'.'+month+'.'+year;\n//msg.timestamp = hour+':'+minute+':'+second+' '+day+'.'+month+'.'+year;\n//msg.timestamp = hour+'ч'+minute+'м'+second+'c';\nmsg.timestamp = hour+':'+minute+':'+second;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 770,
        "y": 540,
        "wires": [
            [
                "e871555e.9092c8"
            ]
        ]
    },
    {
        "id": "fc67fce9.c5769",
        "type": "function",
        "z": "84c517f4.99a9d8",
        "name": "FormatTime",
        "func": "var now     = new Date(); \nvar year    = now.getFullYear();\nvar month   = now.getMonth()+1; \nvar day     = now.getDate();\nvar hour    = now.getHours();\nvar minute  = now.getMinutes();\nvar second  = now.getSeconds(); \nif(month.toString().length == 1) {\nvar month = '0'+month;\n}\nif(day.toString().length == 1) {\nvar day = '0'+day;\n}   \nif(hour.toString().length == 1) {\nvar hour = '0'+hour;\n}\nif(minute.toString().length == 1) {\nvar minute = '0'+minute;\n}\nif(second.toString().length == 1) {\nvar second = '0'+second;\n}   \n//msg.timestamp = hour+':'+minute+':'+second+' '+day+'.'+month+'.'+year;\n//msg.timestamp = hour+':'+minute+':'+second+' '+day+'.'+month+'.'+year;\n//msg.timestamp = hour+'ч'+minute+'м'+second+'c';\nmsg.timestamp = hour+':'+minute+':'+second;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 770,
        "y": 500,
        "wires": [
            [
                "4af07332.c31ebc"
            ]
        ]
    },
    {
        "id": "633cd7fc.a57828",
        "type": "function",
        "z": "84c517f4.99a9d8",
        "name": "FormatTime",
        "func": "var now     = new Date(); \nvar year    = now.getFullYear();\nvar month   = now.getMonth()+1; \nvar day     = now.getDate();\nvar hour    = now.getHours();\nvar minute  = now.getMinutes();\nvar second  = now.getSeconds(); \nif(month.toString().length == 1) {\nvar month = '0'+month;\n}\nif(day.toString().length == 1) {\nvar day = '0'+day;\n}   \nif(hour.toString().length == 1) {\nvar hour = '0'+hour;\n}\nif(minute.toString().length == 1) {\nvar minute = '0'+minute;\n}\nif(second.toString().length == 1) {\nvar second = '0'+second;\n}   \nmsg.timestamp = hour+':'+minute+':'+second+' '+day+'.'+month+'.'+year;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 750,
        "y": 280,
        "wires": [
            [
                "8c3f52d4.a0dd2"
            ]
        ]
    },
    {
        "id": "605ffa0e.d692d4",
        "type": "comment",
        "z": "84c517f4.99a9d8",
        "name": "При открытии\\закрытии двери отправляем камере команду \"делать скриншоты\"",
        "info": "",
        "x": 810,
        "y": 620,
        "wires": []
    }
]
Как это работает? Так: приходит true или false от датчика открытия двери. Поступает на trigger и на блок rbe. Trigger начинает отсчитывать 51 минуту. Если за это время не поступит ни одного сообщения от датчика - триггер сработает и отправит аварийное сообщение. Блок rbe просто следит за состоянием, если состояние сменилось на противоположное - он передаёт сигнал дальше, если состояние не меняется, например постоянно прилетает false или true - он не реагирует (нужно его так настроить). При изменении состояния сигнал проходит на блок switch, разделяется на два канала, один true, другой false и далее уходит на блок change, на блок function, где привожу дату/время в удобный вид(об этом писал в посту выше) и далее POST запросом отправляется в WebHook.
Блок delay делает задержку на 2 часа, а следующий блок resend будет отправлять сообщение об аварии каждые 2 часа, пока от датчика не появится первый сигнал, который через alarm_reset сбросит триггер resend.
Spoiler: Show hidden text
А вот примерно так сообщения выглядят на мобильнике:
Chat.PNG
Там в примерах, в ссылках WebHook, в полезной нагрузке(сообщении), прописаны коды смайлов. Ну так, чтоб в заблуждение не ввело никого.
Ну как-то так.

OlegJktu
starter
Beiträge: 37
Registriert: 29.10.2017, 06:48

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von OlegJktu » 01.06.2018, 09:10

спасибо что отписались.
У меня флоу ловил только состояние открыто от герконов, я как-то и не видел, что пульс жизни от датчиков постоянно идет.
Видимо датчики движения тоже пульс будут слать.

Sergey777
starter
Beiträge: 31
Registriert: 27.01.2018, 22:00

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von Sergey777 » 01.06.2018, 13:30

OlegJktu hat geschrieben:
01.06.2018, 09:10
Видимо датчики движения тоже пульс будут слать.
Каждые три минуты.

Yurech
Beiträge: 9
Registriert: 17.03.2018, 21:01

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von Yurech » 03.06.2018, 20:56

Sergey777 hat geschrieben:
01.06.2018, 13:30
OlegJktu hat geschrieben:
01.06.2018, 09:10
Видимо датчики движения тоже пульс будут слать.
Каждые три минуты.
А можно как то изменить для датчика двери интервал отправки статуса например не 50 мин. а 15мин?

Sergey777
starter
Beiträge: 31
Registriert: 27.01.2018, 22:00

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von Sergey777 » 04.06.2018, 05:13

Yurech hat geschrieben:
03.06.2018, 20:56
А можно как то изменить для датчика двери интервал отправки статуса например не 50 мин. а 15мин?
На данный момент, боюсь, что нет. Это нужно менять прошивку датчика. Я даже незнаю как это делается, по воздуху, или же нужно разбирать и подпаявыться к контроллеру. Опять же нужно эту прошивку написать. Я пока не встречал такого.

Gavrik
Beiträge: 6
Registriert: 28.05.2018, 20:02

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von Gavrik » 09.06.2018, 17:58

Добрый день, прошу сильно не пинать новичка :)

Есть управление поливом.
В адаптере Wrapper создана логическая переменная которая хранит состояния включен или нет полив оп расписанию.
Spoiler: Show hidden text
2018_06_09_19_33_17_objects_ioBroker.png
2018_06_09_19_33_17_objects_ioBroker.png (11.56 KiB) 1211 mal betrachtet
В визуализации есть переключатель который управляет этой логической переменной.
Spoiler: Show hidden text
2018_06_09_19_30_35_Transmission_Remote_GUI.png
В Node-Red создаем расписание для запуска полива и проверяем включен или нет автоматический полив.
Spoiler: Show hidden text
2018_06_09_19_43_54_Node_RED_192.168.13.232.png
Проблема в том что в Node-Red через какое то небольшое время теряется состояние переменной "автоматический полив", соответственно результат логического сложения получается вот таким :
Spoiler: Show hidden text
2018_06_09_19_32_36_Node_RED_192.168.13.232.png
В самой визуализации переменная читается, а в вот в Node-Red нет.
Что делаю не правильно ? Ее нужно принудительно читать еще раз ?

Если поклацать переключатель на визуализации - она оживает (переменная)

Sergey777
starter
Beiträge: 31
Registriert: 27.01.2018, 22:00

Re: Node-RED примеры, решения и и вопросы. Общая тема по Node-RED

Beitrag von Sergey777 » 10.06.2018, 09:10

Gavrik hat geschrieben:
09.06.2018, 17:58
Если поклацать переключатель на визуализации - она оживает (переменная)
Точно сказать не могу. Но из опыта роботы с Node-RED - он сам нифига не считывает, ему надо это принудительно сделать. После того как обновили состояние переменных - он их помнит всегда, пока работает.Если на какой-либо страничке (вкладке, Flow) Вы нажали "Deploy" - вся node-red сбрасывается(перезагружается) и состояния переменных и сенсоров снова становятся неопределёнными. У меня, например перестаёт работать логика, пока вручную не по щёлкаю сенсоры.
А если отладить, запустить, и потом ничего не трогать, не перезагружать систему, не выключать систему, то всё работает бесконечно долго, включая статусы переменных, пока не произойдёт какой-либо аварийный сбой.
Так что когда отладите полностью систему и запустите в постоянную работу, обновите состояние всех нужных переменных и кусков кода, и потом оно будет всегда работать, пока что-то не перезапустите сами.

Antworten