forked from Mirrors/node-red-contrib-mi-devices
587 lines
13 KiB
JSON
587 lines
13 KiB
JSON
[
|
|
{
|
|
"id": "821cff63.382248",
|
|
"type": "tab",
|
|
"label": "Mi Devices Sample",
|
|
"disabled": false,
|
|
"info": ""
|
|
},
|
|
{
|
|
"id": "6caf94b0.f846f4",
|
|
"type": "comment",
|
|
"z": "821cff63.382248",
|
|
"name": "Get all sensors and gateway statuses",
|
|
"info": "",
|
|
"x": 390,
|
|
"y": 40,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "e28ead99.c33338",
|
|
"type": "inject",
|
|
"z": "821cff63.382248",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": true,
|
|
"x": 107.14285714285711,
|
|
"y": 95,
|
|
"wires": [
|
|
[
|
|
"db3b7e35.9432a8",
|
|
"eae70f40.0c904"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "db3b7e35.9432a8",
|
|
"type": "xiaomi-all",
|
|
"z": "821cff63.382248",
|
|
"gateway": "",
|
|
"name": "",
|
|
"x": 300,
|
|
"y": 100,
|
|
"wires": [
|
|
[
|
|
"2e706194.3c27ee"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "eae70f40.0c904",
|
|
"type": "xiaomi-gateway",
|
|
"z": "821cff63.382248",
|
|
"gateway": "",
|
|
"name": "",
|
|
"x": 320,
|
|
"y": 160,
|
|
"wires": [
|
|
[
|
|
"aa109dae.2d9438"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "2e706194.3c27ee",
|
|
"type": "split",
|
|
"z": "821cff63.382248",
|
|
"name": "",
|
|
"splt": "\\n",
|
|
"spltType": "str",
|
|
"arraySplt": 1,
|
|
"arraySpltType": "len",
|
|
"stream": false,
|
|
"addname": "",
|
|
"x": 490,
|
|
"y": 100,
|
|
"wires": [
|
|
[
|
|
"e1cbbde3.9a2ab8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "e1cbbde3.9a2ab8",
|
|
"type": "change",
|
|
"z": "821cff63.382248",
|
|
"name": "set id",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "sid",
|
|
"pt": "msg",
|
|
"to": "payload.sid",
|
|
"tot": "msg"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 650,
|
|
"y": 100,
|
|
"wires": [
|
|
[
|
|
"aa109dae.2d9438"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "aa109dae.2d9438",
|
|
"type": "xiaomi-actions read",
|
|
"z": "821cff63.382248",
|
|
"name": "",
|
|
"x": 810,
|
|
"y": 100,
|
|
"wires": [
|
|
[
|
|
"d42a0577.a9bbb"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "d42a0577.a9bbb",
|
|
"type": "xiaomi-gateway out",
|
|
"z": "821cff63.382248",
|
|
"name": "",
|
|
"gateway": "",
|
|
"ip": "",
|
|
"x": 1000,
|
|
"y": 100,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "43eaf652.25b4b8",
|
|
"type": "comment",
|
|
"z": "821cff63.382248",
|
|
"name": "Check if a window at least one window open",
|
|
"info": "",
|
|
"x": 410,
|
|
"y": 300,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "2df06b27.29db24",
|
|
"type": "xiaomi-all",
|
|
"z": "821cff63.382248",
|
|
"gateway": "",
|
|
"name": "",
|
|
"x": 300,
|
|
"y": 360,
|
|
"wires": [
|
|
[
|
|
"219409ac.757b0e",
|
|
"b6ad7f55.18f99"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "e1ff739f.b36108",
|
|
"type": "split",
|
|
"z": "821cff63.382248",
|
|
"name": "",
|
|
"splt": "\\n",
|
|
"spltType": "str",
|
|
"arraySplt": 1,
|
|
"arraySpltType": "len",
|
|
"stream": false,
|
|
"addname": "",
|
|
"x": 630,
|
|
"y": 360,
|
|
"wires": [
|
|
[
|
|
"f03d4922.cee86"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "219409ac.757b0e",
|
|
"type": "function",
|
|
"z": "821cff63.382248",
|
|
"name": "filter windows",
|
|
"func": "let windowSensors = msg.payload.filter((e) => {\n return e.model === \"magnet\";\n});\nmsg.payload = windowSensors;\nreturn msg;",
|
|
"outputs": 1,
|
|
"noerr": 0,
|
|
"x": 460,
|
|
"y": 360,
|
|
"wires": [
|
|
[
|
|
"e1ff739f.b36108"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "f03d4922.cee86",
|
|
"type": "change",
|
|
"z": "821cff63.382248",
|
|
"name": "set id",
|
|
"rules": [
|
|
{
|
|
"t": "set",
|
|
"p": "sid",
|
|
"pt": "msg",
|
|
"to": "payload.sid",
|
|
"tot": "msg"
|
|
}
|
|
],
|
|
"action": "",
|
|
"property": "",
|
|
"from": "",
|
|
"to": "",
|
|
"reg": false,
|
|
"x": 770,
|
|
"y": 360,
|
|
"wires": [
|
|
[
|
|
"fc9ceef6.4b5ab"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "fc9ceef6.4b5ab",
|
|
"type": "xiaomi-actions read",
|
|
"z": "821cff63.382248",
|
|
"name": "",
|
|
"x": 910,
|
|
"y": 360,
|
|
"wires": [
|
|
[
|
|
"5b0ada34.5af104"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "5b0ada34.5af104",
|
|
"type": "xiaomi-gateway out",
|
|
"z": "821cff63.382248",
|
|
"name": "",
|
|
"gateway": "",
|
|
"ip": "",
|
|
"x": 1100,
|
|
"y": 360,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "d9ffa93a.e40638",
|
|
"type": "xiaomi-gateway in",
|
|
"z": "821cff63.382248",
|
|
"name": "",
|
|
"gateway": "",
|
|
"ip": "",
|
|
"x": 100,
|
|
"y": 480,
|
|
"wires": [
|
|
[
|
|
"1c6df817.0a0bb"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "1c6df817.0a0bb",
|
|
"type": "function",
|
|
"z": "821cff63.382248",
|
|
"name": "set window sensor value",
|
|
"func": "if ([\"magnet\", \"sensor_magnet.aq2\"].indexOf(msg.payload.model) >= 0 && msg.payload.sid !== \"158d0001ab1fa8\") {\n let globalKey = `windowSensorStatus-${msg.payload.sid}`;\n global.set(globalKey, msg.payload.data.status);\n}\n",
|
|
"outputs": "0",
|
|
"noerr": 0,
|
|
"x": 330,
|
|
"y": 480,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "e030edc3.f85a18",
|
|
"type": "function",
|
|
"z": "821cff63.382248",
|
|
"name": "get window sensors values",
|
|
"func": "let windowSensors = {};\nmsg.payload.filter((e) => {\n return e.model === \"magnet\";\n}).forEach((e) => {\n let globalKey = `windowSensorStatus-${e.sid}`;\n let value = global.get(globalKey);\n if(!value || value == \"open\") {\n windowSensors[e.sid] = value || \"na\";\n }\n});\n\nmsg.payload = windowSensors;\nif(Object.keys(windowSensors).length) {\n return [msg, null];\n}\nreturn [null, msg];",
|
|
"outputs": "2",
|
|
"noerr": 0,
|
|
"x": 680,
|
|
"y": 420,
|
|
"wires": [
|
|
[],
|
|
[]
|
|
],
|
|
"outputLabels": [
|
|
"at least one window is open",
|
|
"all windows are close"
|
|
]
|
|
},
|
|
{
|
|
"id": "b6ad7f55.18f99",
|
|
"type": "delay",
|
|
"z": "821cff63.382248",
|
|
"name": "",
|
|
"pauseType": "delay",
|
|
"timeout": "500",
|
|
"timeoutUnits": "milliseconds",
|
|
"rate": "1",
|
|
"nbRateUnits": "1",
|
|
"rateUnits": "second",
|
|
"randomFirst": "1",
|
|
"randomLast": "5",
|
|
"randomUnits": "seconds",
|
|
"drop": false,
|
|
"x": 450,
|
|
"y": 420,
|
|
"wires": [
|
|
[
|
|
"e030edc3.f85a18"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "7838f0b6.d0ea5",
|
|
"type": "comment",
|
|
"z": "821cff63.382248",
|
|
"name": "Doorbell",
|
|
"info": "",
|
|
"x": 300,
|
|
"y": 580,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "8de3e2f.b76f2a",
|
|
"type": "xiaomi-gateway in",
|
|
"z": "821cff63.382248",
|
|
"name": "",
|
|
"gateway": "",
|
|
"ip": "",
|
|
"x": 100,
|
|
"y": 660,
|
|
"wires": [
|
|
[
|
|
"f96c8911.21e9"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "26684d11.692aa2",
|
|
"type": "function",
|
|
"z": "821cff63.382248",
|
|
"name": "is click",
|
|
"func": "if(msg.payload.cmd === \"report\" && msg.payload.data.status == \"click\") {\n return msg;\n}\nreturn null;",
|
|
"outputs": "1",
|
|
"noerr": 0,
|
|
"x": 470,
|
|
"y": 660,
|
|
"wires": [
|
|
[
|
|
"2be5185d.959f2",
|
|
"1d76619d.106536",
|
|
"1afbffce.6c1d2"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "2be5185d.959f2",
|
|
"type": "xiaomi-actions gateway_sound",
|
|
"z": "821cff63.382248",
|
|
"gateway": "",
|
|
"name": "",
|
|
"mid": "10",
|
|
"volume": "20",
|
|
"x": 650,
|
|
"y": 640,
|
|
"wires": [
|
|
[
|
|
"7fa04a92.0851dc"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "7fa04a92.0851dc",
|
|
"type": "xiaomi-gateway out",
|
|
"z": "821cff63.382248",
|
|
"name": "",
|
|
"gateway": "",
|
|
"ip": "",
|
|
"x": 1260,
|
|
"y": 640,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "21b53d98.e9ecca",
|
|
"type": "template",
|
|
"z": "821cff63.382248",
|
|
"name": "off",
|
|
"field": "brightness",
|
|
"fieldType": "msg",
|
|
"format": "handlebars",
|
|
"syntax": "plain",
|
|
"template": "0",
|
|
"output": "str",
|
|
"x": 850,
|
|
"y": 800,
|
|
"wires": [
|
|
[
|
|
"7bac4ce.ffef434"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "1d76619d.106536",
|
|
"type": "template",
|
|
"z": "821cff63.382248",
|
|
"name": "on",
|
|
"field": "brightness",
|
|
"fieldType": "msg",
|
|
"format": "handlebars",
|
|
"syntax": "plain",
|
|
"template": "100",
|
|
"output": "str",
|
|
"x": 850,
|
|
"y": 760,
|
|
"wires": [
|
|
[
|
|
"7bac4ce.ffef434"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "7bac4ce.ffef434",
|
|
"type": "xiaomi-actions gateway_light",
|
|
"z": "821cff63.382248",
|
|
"gateway": "",
|
|
"name": "",
|
|
"x": 1000,
|
|
"y": 760,
|
|
"wires": [
|
|
[
|
|
"7fa04a92.0851dc"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "1afbffce.6c1d2",
|
|
"type": "delay",
|
|
"z": "821cff63.382248",
|
|
"name": "500ms",
|
|
"pauseType": "delay",
|
|
"timeout": "500",
|
|
"timeoutUnits": "milliseconds",
|
|
"rate": "1",
|
|
"nbRateUnits": "1",
|
|
"rateUnits": "second",
|
|
"randomFirst": "1",
|
|
"randomLast": "5",
|
|
"randomUnits": "seconds",
|
|
"drop": false,
|
|
"x": 650,
|
|
"y": 720,
|
|
"wires": [
|
|
[
|
|
"21b53d98.e9ecca",
|
|
"ad79b644.f7e05"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "ad79b644.f7e05",
|
|
"type": "delay",
|
|
"z": "821cff63.382248",
|
|
"name": "500ms",
|
|
"pauseType": "delay",
|
|
"timeout": "500",
|
|
"timeoutUnits": "milliseconds",
|
|
"rate": "1",
|
|
"nbRateUnits": "1",
|
|
"rateUnits": "second",
|
|
"randomFirst": "1",
|
|
"randomLast": "5",
|
|
"randomUnits": "seconds",
|
|
"drop": false,
|
|
"x": 650,
|
|
"y": 760,
|
|
"wires": [
|
|
[
|
|
"1d76619d.106536",
|
|
"8916da4a.6aeb58"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "8916da4a.6aeb58",
|
|
"type": "delay",
|
|
"z": "821cff63.382248",
|
|
"name": "500ms",
|
|
"pauseType": "delay",
|
|
"timeout": "500",
|
|
"timeoutUnits": "milliseconds",
|
|
"rate": "1",
|
|
"nbRateUnits": "1",
|
|
"rateUnits": "second",
|
|
"randomFirst": "1",
|
|
"randomLast": "5",
|
|
"randomUnits": "seconds",
|
|
"drop": false,
|
|
"x": 650,
|
|
"y": 800,
|
|
"wires": [
|
|
[
|
|
"21b53d98.e9ecca",
|
|
"b83a24c8.4d0f38"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "b83a24c8.4d0f38",
|
|
"type": "delay",
|
|
"z": "821cff63.382248",
|
|
"name": "500ms",
|
|
"pauseType": "delay",
|
|
"timeout": "500",
|
|
"timeoutUnits": "milliseconds",
|
|
"rate": "1",
|
|
"nbRateUnits": "1",
|
|
"rateUnits": "second",
|
|
"randomFirst": "1",
|
|
"randomLast": "5",
|
|
"randomUnits": "seconds",
|
|
"drop": false,
|
|
"x": 650,
|
|
"y": 840,
|
|
"wires": [
|
|
[
|
|
"1d76619d.106536",
|
|
"ce69d5d.693d4a8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "ce69d5d.693d4a8",
|
|
"type": "delay",
|
|
"z": "821cff63.382248",
|
|
"name": "500ms",
|
|
"pauseType": "delay",
|
|
"timeout": "500",
|
|
"timeoutUnits": "milliseconds",
|
|
"rate": "1",
|
|
"nbRateUnits": "1",
|
|
"rateUnits": "second",
|
|
"randomFirst": "1",
|
|
"randomLast": "5",
|
|
"randomUnits": "seconds",
|
|
"drop": false,
|
|
"x": 650,
|
|
"y": 880,
|
|
"wires": [
|
|
[
|
|
"21b53d98.e9ecca"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "b7526133.93348",
|
|
"type": "comment",
|
|
"z": "821cff63.382248",
|
|
"name": "gateway light flick 3 times",
|
|
"info": "",
|
|
"x": 890,
|
|
"y": 720,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "f96c8911.21e9",
|
|
"type": "xiaomi-switch",
|
|
"z": "821cff63.382248",
|
|
"gateway": "",
|
|
"name": "",
|
|
"sid": "",
|
|
"outmsg": "{{click}}",
|
|
"outmsgdbcl": "{{double_click}}",
|
|
"output": "0",
|
|
"x": 300,
|
|
"y": 660,
|
|
"wires": [
|
|
[
|
|
"26684d11.692aa2"
|
|
]
|
|
]
|
|
}
|
|
]
|