2019年2月11日 星期一

Raspberry pi 3B+,node red連接小米溫溼度計的flow

其實還有另一個flow是控制我以前用esp8266做的小燈的開關啦...

先貼溫溼度計的flow

[
    {
        "id": "811e81b2.69c7e",
        "type": "tab",
        "label": "Flow 2",
        "disabled": false,
        "info": ""
    },
    {
        "id": "2dc493b8.a8556c",
        "type": "Xiaomi BLE",
        "z": "811e81b2.69c7e",
        "name": "",
        "address": "4c:65:a8:de:77:a7",
        "scanningTimeout": 60,
        "x": 490,
        "y": 240,
        "wires": [
            [
                "37c2b54c.fb3d1a",
                "2c78dbb9.d6cf04",
                "dafff79d.aa63f8",
                "b005969f.8462d8",
                "e713df43.0e2a6",
                "87bb489c.d41738",
                "c27a4844.a06aa8",
                "758d8e31.a3d77",
                "30839133.de252e"
            ]
        ]
    },
    {
        "id": "32ece7e.0e5f618",
        "type": "inject",
        "z": "811e81b2.69c7e",
        "name": "",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "repeat": "10",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 270,
        "y": 240,
        "wires": [
            [
                "2dc493b8.a8556c"
            ]
        ]
    },
    {
        "id": "37c2b54c.fb3d1a",
        "type": "debug",
        "z": "811e81b2.69c7e",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "x": 870,
        "y": 60,
        "wires": []
    },
    {
        "id": "c27a4844.a06aa8",
        "type": "ui_gauge",
        "z": "811e81b2.69c7e",
        "name": "temperature",
        "group": "6245aa9a.edfeb4",
        "order": 1,
        "width": "6",
        "height": "6",
        "gtype": "gage",
        "title": "Temptrature",
        "label": "degree",
        "format": "{{msg.payload.temperature}}℃",
        "min": 0,
        "max": "50",
        "colors": [
            "#0088ff",
            "#88ff88",
            "#ff8000"
        ],
        "seg1": "20",
        "seg2": "30",
        "x": 890,
        "y": 240,
        "wires": []
    },
    {
        "id": "758d8e31.a3d77",
        "type": "ui_gauge",
        "z": "811e81b2.69c7e",
        "name": "humidity",
        "group": "6245aa9a.edfeb4",
        "order": 2,
        "width": "6",
        "height": "6",
        "gtype": "gage",
        "title": "humidity",
        "label": "percent",
        "format": "{{msg.payload.humidity}}%",
        "min": 0,
        "max": "100",
        "colors": [
            "#88ffcc",
            "#00ccff",
            "#0088ff"
        ],
        "seg1": "",
        "seg2": "",
        "x": 880,
        "y": 280,
        "wires": []
    },
    {
        "id": "2c78dbb9.d6cf04",
        "type": "debug",
        "z": "811e81b2.69c7e",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.battery",
        "x": 920,
        "y": 180,
        "wires": []
    },
    {
        "id": "dafff79d.aa63f8",
        "type": "debug",
        "z": "811e81b2.69c7e",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.temperature",
        "x": 930,
        "y": 100,
        "wires": []
    },
    {
        "id": "b005969f.8462d8",
        "type": "debug",
        "z": "811e81b2.69c7e",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload.humidity",
        "x": 920,
        "y": 140,
        "wires": []
    },
    {
        "id": "20f8884f.324858",
        "type": "ui_chart",
        "z": "811e81b2.69c7e",
        "name": "",
        "group": "6245aa9a.edfeb4",
        "order": 3,
        "width": "12",
        "height": "6",
        "label": "Temperature & Humidity",
        "chartType": "line",
        "legend": "true",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "0",
        "ymax": "100",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "86400",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "x": 1070,
        "y": 400,
        "wires": [
            [],
            []
        ]
    },
    {
        "id": "b1921aef.c3c278",
        "type": "ui_toast",
        "z": "811e81b2.69c7e",
        "position": "top right",
        "displayTime": "3",
        "highlight": "",
        "outputs": 0,
        "ok": "OK",
        "cancel": "",
        "topic": "",
        "name": "",
        "x": 910,
        "y": 520,
        "wires": []
    },
    {
        "id": "fee2bff5.d8649",
        "type": "status",
        "z": "811e81b2.69c7e",
        "name": "Xiaomi BLE status",
        "scope": [
            "2dc493b8.a8556c"
        ],
        "x": 470,
        "y": 300,
        "wires": [
            [
                "fa6fdb9d.fbfc48",
                "f5a35c45.43ea5"
            ]
        ]
    },
    {
        "id": "fa6fdb9d.fbfc48",
        "type": "debug",
        "z": "811e81b2.69c7e",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "x": 650,
        "y": 400,
        "wires": []
    },
    {
        "id": "f5a35c45.43ea5",
        "type": "switch",
        "z": "811e81b2.69c7e",
        "name": "",
        "property": "status.text",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "requesting",
                "vt": "str"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 390,
        "y": 500,
        "wires": [
            [
                "4755b0f4.9eca9"
            ],
            [],
            [
                "e2010767.b35498",
                "5a63b6e6.effad8"
            ]
        ]
    },
    {
        "id": "705f9b52.25c644",
        "type": "change",
        "z": "811e81b2.69c7e",
        "name": "enable ui",
        "rules": [
            {
                "t": "set",
                "p": "enabled",
                "pt": "msg",
                "to": "true",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "thesensor",
                "pt": "flow",
                "to": "1",
                "tot": "num"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 660,
        "y": 440,
        "wires": [
            [
                "c27a4844.a06aa8",
                "758d8e31.a3d77",
                "30839133.de252e"
            ]
        ]
    },
    {
        "id": "e2010767.b35498",
        "type": "change",
        "z": "811e81b2.69c7e",
        "name": "disable ui",
        "rules": [
            {
                "t": "set",
                "p": "enabled",
                "pt": "msg",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "set",
                "p": "payload.temperature",
                "pt": "msg",
                "to": "-",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.humidity",
                "pt": "msg",
                "to": "-",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload.battery",
                "pt": "msg",
                "to": "-",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "thesensor",
                "pt": "flow",
                "to": "0",
                "tot": "num"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 660,
        "y": 480,
        "wires": [
            [
                "c27a4844.a06aa8",
                "758d8e31.a3d77",
                "30839133.de252e"
            ]
        ]
    },
    {
        "id": "e713df43.0e2a6",
        "type": "change",
        "z": "811e81b2.69c7e",
        "name": "t",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.temperature",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "Temperature",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 870,
        "y": 360,
        "wires": [
            [
                "20f8884f.324858"
            ]
        ]
    },
    {
        "id": "87bb489c.d41738",
        "type": "change",
        "z": "811e81b2.69c7e",
        "name": "h",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.humidity",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "Humidity",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 870,
        "y": 400,
        "wires": [
            [
                "20f8884f.324858"
            ]
        ]
    },
    {
        "id": "4755b0f4.9eca9",
        "type": "switch",
        "z": "811e81b2.69c7e",
        "name": "",
        "property": "thesensor",
        "propertyType": "flow",
        "rules": [
            {
                "t": "neq",
                "v": "1",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 510,
        "y": 440,
        "wires": [
            [
                "705f9b52.25c644"
            ]
        ]
    },
    {
        "id": "5a63b6e6.effad8",
        "type": "change",
        "z": "811e81b2.69c7e",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "status.text",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "BLE sensor",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 680,
        "y": 520,
        "wires": [
            [
                "b1921aef.c3c278"
            ]
        ]
    },
    {
        "id": "dc233e96.2b614",
        "type": "ui_chart",
        "z": "811e81b2.69c7e",
        "name": "",
        "group": "6245aa9a.edfeb4",
        "order": 2,
        "width": "12",
        "height": "2",
        "label": "battery",
        "chartType": "horizontalBar",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "0",
        "ymax": "100",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "3600",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "x": 1010,
        "y": 440,
        "wires": [
            [],
            []
        ]
    },
    {
        "id": "30839133.de252e",
        "type": "change",
        "z": "811e81b2.69c7e",
        "name": "b",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.battery",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "battery",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 870,
        "y": 440,
        "wires": [
            [
                "dc233e96.2b614"
            ]
        ]
    },
    {
        "id": "6245aa9a.edfeb4",
        "type": "ui_group",
        "z": "",
        "name": "Group 1",
        "tab": "1f5551d0.53992e",
        "order": 1,
        "disp": true,
        "width": "12",
        "collapse": false
    },
    {
        "id": "1f5551d0.53992e",
        "type": "ui_tab",
        "z": "",
        "name": "sensor",
        "icon": "dashboard",
        "order": 2,
        "disabled": false,
        "hidden": false
    }
]



再來是小燈的flow

[
    {
        "id": "e2d596d3.87ddd8",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "c0e60a8c.e4c308",
        "type": "ui_switch",
        "z": "e2d596d3.87ddd8",
        "name": "",
        "label": "switch",
        "tooltip": "",
        "group": "382f008a.8deb6",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": false,
        "decouple": "true",
        "topic": "",
        "style": "",
        "onvalue": "ON",
        "onvalueType": "str",
        "onicon": "",
        "oncolor": "",
        "offvalue": "OFF",
        "offvalueType": "str",
        "officon": "",
        "offcolor": "",
        "x": 570,
        "y": 160,
        "wires": [
            [
                "f539ae50.3dd6b"
            ]
        ]
    },
    {
        "id": "fa050e70.b67db",
        "type": "http request",
        "z": "e2d596d3.87ddd8",
        "name": "",
        "method": "POST",
        "ret": "txt",
        "url": "esp8266.local/led?LED=GET",
        "tls": "",
        "x": 550,
        "y": 320,
        "wires": [
            [
                "974baed1.cdd7"
            ]
        ]
    },
    {
        "id": "f2edab96.0fdfb8",
        "type": "ui_button",
        "z": "e2d596d3.87ddd8",
        "name": "",
        "group": "382f008a.8deb6",
        "order": 2,
        "width": 0,
        "height": 0,
        "passthru": true,
        "label": "refresh",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "",
        "x": 320,
        "y": 320,
        "wires": [
            [
                "fa050e70.b67db"
            ]
        ]
    },
    {
        "id": "974baed1.cdd7",
        "type": "change",
        "z": "e2d596d3.87ddd8",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "LEDisON",
                "fromt": "str",
                "to": "ON",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "LEDisOFF",
                "fromt": "str",
                "to": "OFF",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 800,
        "y": 320,
        "wires": [
            [
                "c0e60a8c.e4c308"
            ]
        ]
    },
    {
        "id": "f539ae50.3dd6b",
        "type": "http request",
        "z": "e2d596d3.87ddd8",
        "name": "",
        "method": "POST",
        "ret": "txt",
        "url": "esp8266.local/led?LED={{{payload}}}",
        "tls": "",
        "x": 790,
        "y": 160,
        "wires": [
            [
                "974baed1.cdd7"
            ]
        ]
    },
    {
        "id": "769f6dd8.979354",
        "type": "inject",
        "z": "e2d596d3.87ddd8",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "str",
        "repeat": "10",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 320,
        "y": 240,
        "wires": [
            [
                "f2edab96.0fdfb8"
            ]
        ]
    },
    {
        "id": "382f008a.8deb6",
        "type": "ui_group",
        "name": "Group 1",
        "tab": "e57a8198.94e2d",
        "order": 1,
        "disp": true,
        "width": 6
    },
    {
        "id": "e57a8198.94e2d",
        "type": "ui_tab",
        "z": "",
        "name": "lamp",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

說來好玩,有部份功能像是switch那個,我之前都用function手刻。放假慢慢摸才知道其實有相同功能的節點了

之後還想弄資料庫,不過看這個圖表一次出一天的資料點就要卡個幾秒...要是資料庫拿出來一次整年的不知道要裝死多久,之後再想怎麼做吧

沒有留言: