585 lines
13 KiB
JSON
585 lines
13 KiB
JSON
[
|
|
{
|
|
"id": "ade6666b.a390c8",
|
|
"type": "tab",
|
|
"label": "Flow 1"
|
|
},
|
|
{
|
|
"id": "524f7aeb.c784cc",
|
|
"type": "comment",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "Get all sensors and gateway statuses",
|
|
"info": "",
|
|
"x": 390,
|
|
"y": 40,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "629029ec.ac6cf8",
|
|
"type": "inject",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "",
|
|
"topic": "",
|
|
"payload": "",
|
|
"payloadType": "date",
|
|
"repeat": "",
|
|
"crontab": "",
|
|
"once": true,
|
|
"x": 107.14285714285711,
|
|
"y": 95,
|
|
"wires": [
|
|
[
|
|
"9e997e5e.27b76",
|
|
"2fbcb15b.776afe"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "9e997e5e.27b76",
|
|
"type": "xiaomi-all",
|
|
"z": "ade6666b.a390c8",
|
|
"gateway": "",
|
|
"name": "",
|
|
"x": 300,
|
|
"y": 100,
|
|
"wires": [
|
|
[
|
|
"c0c7989f.68b528"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "2fbcb15b.776afe",
|
|
"type": "xiaomi-gateway",
|
|
"z": "ade6666b.a390c8",
|
|
"gateway": "",
|
|
"name": "",
|
|
"x": 320,
|
|
"y": 160,
|
|
"wires": [
|
|
[
|
|
"cde190e9.0964d"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "c0c7989f.68b528",
|
|
"type": "split",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "",
|
|
"splt": "\\n",
|
|
"spltType": "str",
|
|
"arraySplt": 1,
|
|
"arraySpltType": "len",
|
|
"stream": false,
|
|
"addname": "",
|
|
"x": 490,
|
|
"y": 100,
|
|
"wires": [
|
|
[
|
|
"40a6c2e5.f08c5c"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "40a6c2e5.f08c5c",
|
|
"type": "change",
|
|
"z": "ade6666b.a390c8",
|
|
"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": [
|
|
[
|
|
"cde190e9.0964d"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "cde190e9.0964d",
|
|
"type": "xiaomi-actions read",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "",
|
|
"x": 810,
|
|
"y": 100,
|
|
"wires": [
|
|
[
|
|
"f867af40.57ba08"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "f867af40.57ba08",
|
|
"type": "xiaomi-gateway out",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "",
|
|
"gateway": "",
|
|
"ip": "",
|
|
"x": 1000,
|
|
"y": 100,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "a0b884dc.c53688",
|
|
"type": "comment",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "Check if a window at least one window open",
|
|
"info": "",
|
|
"x": 410,
|
|
"y": 300,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "46856121.3b579",
|
|
"type": "xiaomi-all",
|
|
"z": "ade6666b.a390c8",
|
|
"gateway": "",
|
|
"name": "",
|
|
"x": 300,
|
|
"y": 360,
|
|
"wires": [
|
|
[
|
|
"11205903.0cc817",
|
|
"3bac4cbb.04ddb4"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "c9823238.f0de8",
|
|
"type": "split",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "",
|
|
"splt": "\\n",
|
|
"spltType": "str",
|
|
"arraySplt": 1,
|
|
"arraySpltType": "len",
|
|
"stream": false,
|
|
"addname": "",
|
|
"x": 630,
|
|
"y": 360,
|
|
"wires": [
|
|
[
|
|
"242201e2.f80c66"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "11205903.0cc817",
|
|
"type": "function",
|
|
"z": "ade6666b.a390c8",
|
|
"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": [
|
|
[
|
|
"c9823238.f0de8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "242201e2.f80c66",
|
|
"type": "change",
|
|
"z": "ade6666b.a390c8",
|
|
"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": [
|
|
[
|
|
"922d6ca6.96b83"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "922d6ca6.96b83",
|
|
"type": "xiaomi-actions read",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "",
|
|
"x": 910,
|
|
"y": 360,
|
|
"wires": [
|
|
[
|
|
"de2a89d1.8e32c8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "de2a89d1.8e32c8",
|
|
"type": "xiaomi-gateway out",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "",
|
|
"gateway": "",
|
|
"ip": "",
|
|
"x": 1100,
|
|
"y": 360,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "8139cbfb.cb0d1",
|
|
"type": "xiaomi-gateway in",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "",
|
|
"gateway": "",
|
|
"ip": "",
|
|
"x": 100,
|
|
"y": 480,
|
|
"wires": [
|
|
[
|
|
"b5f98d8a.5e8298"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "b5f98d8a.5e8298",
|
|
"type": "function",
|
|
"z": "ade6666b.a390c8",
|
|
"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": "3812ee82.85f612",
|
|
"type": "function",
|
|
"z": "ade6666b.a390c8",
|
|
"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": "3bac4cbb.04ddb4",
|
|
"type": "delay",
|
|
"z": "ade6666b.a390c8",
|
|
"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": [
|
|
[
|
|
"3812ee82.85f612"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "4172e627.352338",
|
|
"type": "comment",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "Doorbell",
|
|
"info": "",
|
|
"x": 300,
|
|
"y": 580,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "24cf3af8.5d14ae",
|
|
"type": "xiaomi-gateway in",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "",
|
|
"gateway": "",
|
|
"ip": "",
|
|
"x": 100,
|
|
"y": 660,
|
|
"wires": [
|
|
[
|
|
"6f68150a.27ebd4"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "303dbf84.93647",
|
|
"type": "function",
|
|
"z": "ade6666b.a390c8",
|
|
"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": [
|
|
[
|
|
"5f7b5c66.a6aae4",
|
|
"d030347d.988258",
|
|
"b6476cff.be3b08"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "5f7b5c66.a6aae4",
|
|
"type": "xiaomi-actions gateway_sound",
|
|
"z": "ade6666b.a390c8",
|
|
"gateway": "",
|
|
"name": "",
|
|
"mid": "10",
|
|
"volume": "20",
|
|
"x": 650,
|
|
"y": 640,
|
|
"wires": [
|
|
[
|
|
"6e37698a.70dda"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "6e37698a.70dda",
|
|
"type": "xiaomi-gateway out",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "",
|
|
"gateway": "",
|
|
"ip": "",
|
|
"x": 1260,
|
|
"y": 640,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "1aea30f.c00254f",
|
|
"type": "template",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "off",
|
|
"field": "brightness",
|
|
"fieldType": "msg",
|
|
"format": "handlebars",
|
|
"syntax": "plain",
|
|
"template": "0",
|
|
"output": "str",
|
|
"x": 850,
|
|
"y": 800,
|
|
"wires": [
|
|
[
|
|
"464cf932.2d56"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "d030347d.988258",
|
|
"type": "template",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "on",
|
|
"field": "brightness",
|
|
"fieldType": "msg",
|
|
"format": "handlebars",
|
|
"syntax": "plain",
|
|
"template": "100",
|
|
"output": "str",
|
|
"x": 850,
|
|
"y": 760,
|
|
"wires": [
|
|
[
|
|
"464cf932.2d56"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "464cf932.2d56",
|
|
"type": "xiaomi-actions gateway_light",
|
|
"z": "ade6666b.a390c8",
|
|
"gateway": "",
|
|
"name": "",
|
|
"x": 1000,
|
|
"y": 760,
|
|
"wires": [
|
|
[
|
|
"6e37698a.70dda"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "b6476cff.be3b08",
|
|
"type": "delay",
|
|
"z": "ade6666b.a390c8",
|
|
"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": [
|
|
[
|
|
"1aea30f.c00254f",
|
|
"4673a161.b816d8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "4673a161.b816d8",
|
|
"type": "delay",
|
|
"z": "ade6666b.a390c8",
|
|
"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": [
|
|
[
|
|
"d030347d.988258",
|
|
"e07cace.7d37c5"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "e07cace.7d37c5",
|
|
"type": "delay",
|
|
"z": "ade6666b.a390c8",
|
|
"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": [
|
|
[
|
|
"1aea30f.c00254f",
|
|
"f12b5663.1a82c8"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "f12b5663.1a82c8",
|
|
"type": "delay",
|
|
"z": "ade6666b.a390c8",
|
|
"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": [
|
|
[
|
|
"d030347d.988258",
|
|
"4b1d8119.5d292"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "4b1d8119.5d292",
|
|
"type": "delay",
|
|
"z": "ade6666b.a390c8",
|
|
"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": [
|
|
[
|
|
"1aea30f.c00254f"
|
|
]
|
|
]
|
|
},
|
|
{
|
|
"id": "7db6953.95a0cec",
|
|
"type": "comment",
|
|
"z": "ade6666b.a390c8",
|
|
"name": "gateway light flick 3 times",
|
|
"info": "",
|
|
"x": 890,
|
|
"y": 720,
|
|
"wires": []
|
|
},
|
|
{
|
|
"id": "6f68150a.27ebd4",
|
|
"type": "xiaomi-switch",
|
|
"z": "ade6666b.a390c8",
|
|
"gateway": "",
|
|
"name": "",
|
|
"sid": "",
|
|
"outmsg": "{{click}}",
|
|
"outmsgdbcl": "{{double_click}}",
|
|
"output": "0",
|
|
"x": 300,
|
|
"y": 660,
|
|
"wires": [
|
|
[
|
|
"303dbf84.93647"
|
|
]
|
|
]
|
|
}
|
|
]
|