feat(doc): update readme to integrate sample flow

This commit is contained in:
Pierre CLEMENT committed 2018-01-02 12:39:00 +01:00
1 parent 950cccb6dc
commit 24ef7012f9
6 files changed
+15 -8

No files matched your search

+14 -8
View File
@@ -36,14 +36,20 @@ Note that the Wifi power plug is not configured through the configurator as it i
The Xiaomi configurator screen with ease of use to configure your different devices. The Xiaomi configurator screen with ease of use to configure your different devices.
![Xiaomi configurator in node-red](https://raw.githubusercontent.com/pierrecle/node-red-contrib-mi-devices/master/xiaomi-configurator.png) ![Mi configurator in node-red](mi-configurator.png?raw=true "Mi configurator in node-red")
Tip: use the configurator from the side-panel (hamburger menu, configuration nodes) to manage your devices. Node-red doesn't update underlying edit screens if the configuration panel is opened / closed from the edit node screen. (If you do, you need to first close the edit node screen and reopen it by double-clicking the node you want to edit the properties for.) Tip: use the configurator from the side-panel (hamburger menu, configuration nodes) to manage your devices. Node-red doesn't update underlying edit screens if the configuration panel is opened / closed from the edit node screen. (If you do, you need to first close the edit node screen and reopen it by double-clicking the node you want to edit the properties for.)
### How to use different nodes
Here an example of how to use the different nodes. Here an example of how to use the different nodes:
![Mi devices example in node-red](mi-devices-overview.png?raw=true "Mi devices example in node-red")
![Xiaomi devices example in node-red](/xiaomi-devices-overview.png?raw=true)
### Sample flows
Here are different flow (screenshot of [importable sample-flows.json](sample-flows.json "Different flows using Mi Devices")):
![Mi devices example in node-red](mi-devices-sample.png?raw=true "Mi devices flow sample")
## Enable LAN mode ## Enable LAN mode
@@ -56,15 +62,15 @@ Mainland China and language can set on English.
4. Then the 3 dots at the top right of the screen 4. Then the 3 dots at the top right of the screen
5. Then click on about 5. Then click on about
6. Tap under Tutorial menu (on the blank part) repeatedly 6. Tap under Tutorial menu (on the blank part) repeatedly
7. You should see now 3 extra options listed in Chinese until you did now enable the developer mode. [ if not try all steps again!] 7. You should see now 3 extra options listed in Chinese until you did now enable the developer mode (like the first screenshot below, if not try all steps again!)
8. Choose the second new option 8. Choose the second new option
9. Then tap the first toggle switch to enable LAN functions. Note down the password (`A4D81977ED8A4177` in the screenshot). 9. Then tap the first toggle switch to enable LAN functions. Note down the password (`A4D81977ED8A4177` in the second screenshot)
10. Make sure you hit the OK button (to the right of the cancel button) to save your changes. 10. Make sure you hit the OK button (to the right of the cancel button) to save your changes
If you change here something, you lose your password! If you change here something, you lose your password!
![Gateway advanced mode](/xiaomi-gateway-advanced-mode.png?raw=true "Gateway advanced mode") ![Gateway advanced mode](xiaomi-gateway-advanced-mode.png?raw=true "Gateway advanced mode")
![Gateway LAN mode enabled](/xiaomi-gateway-lan-enabled.png?raw=true "Gateway LAN mode enabled") ![Gateway LAN mode enabled](xiaomi-gateway-lan-enabled.png?raw=true "Gateway LAN mode enabled")
## Roadmap ## Roadmap
File renamed without changes.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

+1
View File
@@ -0,0 +1 @@
[{"id":"dc16e8cc.447c88","type":"comment","z":"29cca8d2.ba3ad","name":"Get all sensors and gateway statuses","info":"","x":410,"y":60,"wires":[]},{"id":"60ceea08.315bcc","type":"inject","z":"29cca8d2.ba3ad","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":127.14285714285711,"y":115,"wires":[["e9a9ee4d.a5be7","c80a86de.845188"]]},{"id":"e9a9ee4d.a5be7","type":"xiaomi-all","z":"29cca8d2.ba3ad","gateway":"","name":"","x":320,"y":120,"wires":[["afd4a38a.dd9108"]]},{"id":"c80a86de.845188","type":"xiaomi-gateway","z":"29cca8d2.ba3ad","gateway":"","name":"","x":340,"y":180,"wires":[["961cec1f.1b765"]]},{"id":"afd4a38a.dd9108","type":"split","z":"29cca8d2.ba3ad","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":510,"y":120,"wires":[["27e1c93.302c036"]]},{"id":"27e1c93.302c036","type":"change","z":"29cca8d2.ba3ad","name":"set id","rules":[{"t":"set","p":"sid","pt":"msg","to":"payload.sid","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":670,"y":120,"wires":[["961cec1f.1b765"]]},{"id":"961cec1f.1b765","type":"xiaomi-actions read","z":"29cca8d2.ba3ad","name":"","x":830,"y":120,"wires":[["5abdc8db.a1daa8"]]},{"id":"5abdc8db.a1daa8","type":"xiaomi-gateway out","z":"29cca8d2.ba3ad","name":"","gateway":"","ip":"","x":1020,"y":120,"wires":[]},{"id":"1bcbfc2c.08f714","type":"comment","z":"29cca8d2.ba3ad","name":"Check if a window at least one window open","info":"","x":430,"y":320,"wires":[]},{"id":"8bc218fb.73ac9","type":"xiaomi-all","z":"29cca8d2.ba3ad","gateway":"","name":"","x":320,"y":380,"wires":[["415fe6bd.11d4c8","5bd81268.5f9fd4"]]},{"id":"5812cfb0.d9eac8","type":"split","z":"29cca8d2.ba3ad","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":650,"y":380,"wires":[["ef37d1d6.887708"]]},{"id":"415fe6bd.11d4c8","type":"function","z":"29cca8d2.ba3ad","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":480,"y":380,"wires":[["5812cfb0.d9eac8"]]},{"id":"ef37d1d6.887708","type":"change","z":"29cca8d2.ba3ad","name":"set id","rules":[{"t":"set","p":"sid","pt":"msg","to":"payload.sid","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":380,"wires":[["98852ce9.aa735"]]},{"id":"98852ce9.aa735","type":"xiaomi-actions read","z":"29cca8d2.ba3ad","name":"","x":930,"y":380,"wires":[["be35bfa2.ec1a78"]]},{"id":"be35bfa2.ec1a78","type":"xiaomi-gateway out","z":"29cca8d2.ba3ad","name":"","gateway":"","ip":"","x":1120,"y":380,"wires":[]},{"id":"9805baa8.f32ba8","type":"xiaomi-gateway in","z":"29cca8d2.ba3ad","name":"","gateway":"","ip":"","x":120,"y":500,"wires":[["e203a4da.b336a"]]},{"id":"e203a4da.b336a","type":"function","z":"29cca8d2.ba3ad","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":350,"y":500,"wires":[]},{"id":"11814cf2.65f2ab","type":"function","z":"29cca8d2.ba3ad","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":700,"y":440,"wires":[[],[]],"outputLabels":["at least one window is open","all windows are close"]},{"id":"5bd81268.5f9fd4","type":"delay","z":"29cca8d2.ba3ad","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":470,"y":440,"wires":[["11814cf2.65f2ab"]]},{"id":"fdc425bb.c90ea","type":"comment","z":"29cca8d2.ba3ad","name":"Doorbell","info":"","x":320,"y":600,"wires":[]},{"id":"96d8c83c.dd8608","type":"xiaomi-gateway in","z":"29cca8d2.ba3ad","name":"","gateway":"","ip":"","x":120,"y":680,"wires":[["8d9fa43a.a28fd"]]},{"id":"8d9fa43a.a28fd","type":"xiaomi-switch","z":"29cca8d2.ba3ad","gateway":"","name":"","sid":"","outmsg":"{{click}}","outmsgdbcl":"{{double_click}}","output":"0","x":320,"y":680,"wires":[["ae8180c0.b83cf8"],[]]},{"id":"ae8180c0.b83cf8","type":"function","z":"29cca8d2.ba3ad","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":490,"y":680,"wires":[["f3982b42.7dbd48","ad55402.64a34c","a7f8875.e596578"]]},Line truncated
Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB