diff --git a/README.md b/README.md index a1aea26..1dd1251 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,13 @@ Tip: use the configurator from the side-panel (hamburger menu, configuration nod ### 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 (screenshot of [importable flows-overview.json](flows-overview.json "Mi Devices overview")): ![Mi devices example in node-red](resources/mi-devices-overview.png?raw=true "Mi devices example in node-red") ### Sample flows -Here are different flow (screenshot of [importable sample-flows.json](sample-flows.json "Different flows using Mi Devices")): +Here are different flow (screenshot of [importable flows-sample.json](flows-sample.json "Different flows using Mi Devices")): ![Mi devices example in node-red](resources/mi-devices-sample.png?raw=true "Mi devices flow sample") ## Enable LAN mode @@ -79,7 +79,7 @@ If you change here something, you lose your password! - [ ] Add filter on "all" node - [ ] Set action status when no token available - [ ] Add gateway status -- [ ] Update icons +- [X] Update icons - [X] Refactor socket and add on/off actions - [X] Add device SID in output - [X] Remove different output styles @@ -92,3 +92,13 @@ If you change here something, you lose your password! * [louisZl Gateway Local API](https://github.com/louisZL/lumi-gateway-local-api) * [Domoticz Gateway Code](https://github.com/domoticz/domoticz/blob/development/hardware/XiaomiGateway.cpp) * [Node-red UDP nodes](https://github.com/node-red/node-red/blob/master/nodes/core/io/32-udp.js) + +## Credits + +* [Switch icons by Setyo Ari Wibowo](https://thenounproject.com/seochan.art/) +* ["All" icon by Fatahillah](https://thenounproject.com/fatahillah/) +* [Bulb icon by Mello](https://thenounproject.com/stonuiiuntk/) +* [Glasses icon by Agrahara](https://thenounproject.com/agrahara4/) +* [Volume icons by krishna](https://thenounproject.com/krishanayuga/) +* [List icon by Landan Lloyd](https://thenounproject.com/landan/) +* [Clicks icons by Adrien Coquet](https://thenounproject.com/coquet_adrien/) diff --git a/flows-overview.json b/flows-overview.json new file mode 100644 index 0000000..a4cb092 --- /dev/null +++ b/flows-overview.json @@ -0,0 +1,475 @@ +[ + { + "id": "a27cc591.60157", + "type": "tab", + "label": "Flow 1" + }, + { + "id": "98fadf6b.93ace8", + "type": "xiaomi-gateway in", + "z": "a27cc591.60157", + "name": "", + "gateway": "", + "ip": "", + "x": 100, + "y": 260, + "wires": [ + [ + "81afc500.7aaa3", + "cb33991f.f28cf", + "c99b4545.b1c2a", + "64dca666.0bfbd", + "89e83211.c691b", + "76067c35.ffa28c" + ] + ] + }, + { + "id": "81afc500.7aaa3", + "type": "xiaomi-ht", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "sid": "", + "x": 420, + "y": 120, + "wires": [ + [ + "b9a37252.56508" + ] + ] + }, + { + "id": "cb33991f.f28cf", + "type": "xiaomi-magnet", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "sid": "", + "x": 440, + "y": 180, + "wires": [ + [ + "b9a37252.56508" + ] + ] + }, + { + "id": "c99b4545.b1c2a", + "type": "xiaomi-motion", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "sid": "", + "motionmsg": "", + "nomotionmsg": "", + "output": "0", + "x": 440, + "y": 240, + "wires": [ + [ + "b9a37252.56508" + ] + ] + }, + { + "id": "64dca666.0bfbd", + "type": "xiaomi-switch", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "sid": "", + "outmsg": "{{click}}", + "outmsgdbcl": "{{double_click}}", + "output": "0", + "x": 440, + "y": 300, + "wires": [ + [ + "b9a37252.56508" + ] + ] + }, + { + "id": "89e83211.c691b", + "type": "xiaomi-gateway", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "x": 440, + "y": 360, + "wires": [ + [ + "b9a37252.56508" + ] + ] + }, + { + "id": "76067c35.ffa28c", + "type": "xiaomi-plug", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "sid": "", + "onmsg": "", + "offmsg": "", + "output": "0", + "x": 430, + "y": 420, + "wires": [ + [ + "b9a37252.56508" + ] + ] + }, + { + "id": "b9a37252.56508", + "type": "debug", + "z": "a27cc591.60157", + "name": "", + "active": true, + "console": "false", + "complete": "true", + "x": 790, + "y": 280, + "wires": [] + }, + { + "id": "67b347e2.6a534", + "type": "xiaomi-ht", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "sid": "", + "x": 480, + "y": 580, + "wires": [ + [ + "80913b13.6abde8" + ] + ] + }, + { + "id": "4d7101c0.34b03", + "type": "xiaomi-magnet", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "sid": "", + "x": 500, + "y": 640, + "wires": [ + [ + "80913b13.6abde8" + ] + ] + }, + { + "id": "d693568c.d4361", + "type": "xiaomi-motion", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "sid": "", + "motionmsg": "", + "nomotionmsg": "", + "output": "0", + "x": 500, + "y": 700, + "wires": [ + [ + "80913b13.6abde8" + ] + ] + }, + { + "id": "698abb61.5abd4c", + "type": "xiaomi-switch", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "sid": "", + "outmsg": "{{click}}", + "outmsgdbcl": "{{double_click}}", + "output": "0", + "x": 500, + "y": 760, + "wires": [ + [ + "80913b13.6abde8", + "478d086b.03d228", + "15e41dc2.040d2a" + ] + ] + }, + { + "id": "7d859dfb.4b9654", + "type": "xiaomi-gateway", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "x": 500, + "y": 820, + "wires": [ + [ + "80913b13.6abde8", + "70587543.82d5e4", + "575fa4d4.fc33a4", + "ebe3b7c3.e992a", + "1d0a8872.4d0768" + ] + ] + }, + { + "id": "a5e8199.79366e8", + "type": "inject", + "z": "a27cc591.60157", + "name": "", + "topic": "", + "payload": "", + "payloadType": "date", + "repeat": "", + "crontab": "", + "once": false, + "x": 100, + "y": 700, + "wires": [ + [ + "67b347e2.6a534", + "4d7101c0.34b03", + "d693568c.d4361", + "698abb61.5abd4c", + "7d859dfb.4b9654", + "14721d5a.c43ffb", + "c537654a.b43598", + "2c89de3d.6e4982", + "e4012d10.dc47b8" + ] + ] + }, + { + "id": "14721d5a.c43ffb", + "type": "xiaomi-plug", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "sid": "", + "onmsg": "", + "offmsg": "", + "output": "0", + "x": 490, + "y": 880, + "wires": [ + [ + "80913b13.6abde8", + "66151627.9213d8", + "373c3dc7.ca5912" + ] + ] + }, + { + "id": "c537654a.b43598", + "type": "xiaomi-plug-wifi", + "z": "a27cc591.60157", + "name": "", + "ip": "", + "onmsg": "", + "offmsg": "", + "output": "0", + "x": 500, + "y": 940, + "wires": [ + [] + ] + }, + { + "id": "80913b13.6abde8", + "type": "xiaomi-actions read", + "z": "a27cc591.60157", + "name": "", + "x": 810, + "y": 580, + "wires": [ + [ + "70314d8a.34e17c" + ] + ] + }, + { + "id": "70587543.82d5e4", + "type": "xiaomi-actions get_id_list", + "z": "a27cc591.60157", + "name": "", + "x": 820, + "y": 800, + "wires": [ + [ + "70314d8a.34e17c" + ] + ] + }, + { + "id": "575fa4d4.fc33a4", + "type": "xiaomi-actions gateway_light", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "brightness": 100, + "hexRgbColor": "#ffffff", + "color": { + "red": 255, + "green": 255, + "blue": 255 + }, + "x": 820, + "y": 840, + "wires": [ + [ + "70314d8a.34e17c" + ] + ] + }, + { + "id": "ebe3b7c3.e992a", + "type": "xiaomi-actions gateway_sound", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "mid": "", + "volume": "", + "x": 830, + "y": 880, + "wires": [ + [ + "70314d8a.34e17c" + ] + ] + }, + { + "id": "1d0a8872.4d0768", + "type": "xiaomi-actions gateway_stop_sound", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "x": 830, + "y": 920, + "wires": [ + [ + "70314d8a.34e17c" + ] + ] + }, + { + "id": "66151627.9213d8", + "type": "xiaomi-actions on", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "x": 820, + "y": 980, + "wires": [ + [ + "70314d8a.34e17c" + ] + ] + }, + { + "id": "373c3dc7.ca5912", + "type": "xiaomi-actions off", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "x": 820, + "y": 1020, + "wires": [ + [ + "70314d8a.34e17c" + ] + ] + }, + { + "id": "478d086b.03d228", + "type": "xiaomi-actions click", + "z": "a27cc591.60157", + "name": "", + "x": 810, + "y": 680, + "wires": [ + [ + "70314d8a.34e17c" + ] + ] + }, + { + "id": "15e41dc2.040d2a", + "type": "xiaomi-actions double_click", + "z": "a27cc591.60157", + "name": "", + "x": 830, + "y": 720, + "wires": [ + [ + "70314d8a.34e17c" + ] + ] + }, + { + "id": "70314d8a.34e17c", + "type": "xiaomi-gateway out", + "z": "a27cc591.60157", + "name": "", + "gateway": "", + "ip": "", + "x": 1200, + "y": 780, + "wires": [] + }, + { + "id": "2c89de3d.6e4982", + "type": "xiaomi-actions on", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "x": 280, + "y": 920, + "wires": [ + [ + "c537654a.b43598" + ] + ] + }, + { + "id": "e4012d10.dc47b8", + "type": "xiaomi-actions off", + "z": "a27cc591.60157", + "gateway": "", + "name": "", + "x": 280, + "y": 960, + "wires": [ + [ + "c537654a.b43598" + ] + ] + }, + { + "id": "f475f762.1c84a", + "type": "comment", + "z": "a27cc591.60157", + "name": "Filter incoming", + "info": "", + "x": 420, + "y": 40, + "wires": [] + }, + { + "id": "1692dd61.5f4893", + "type": "comment", + "z": "a27cc591.60157", + "name": "Outgoing", + "info": "", + "x": 420, + "y": 500, + "wires": [] + } +] diff --git a/sample-flows.json b/flows-sample.json similarity index 100% rename from sample-flows.json rename to flows-sample.json diff --git a/node-red-contrib-xiaomi-actions/icons/mi-bulb.png b/node-red-contrib-xiaomi-actions/icons/mi-bulb.png new file mode 100644 index 0000000..5eae146 Binary files /dev/null and b/node-red-contrib-xiaomi-actions/icons/mi-bulb.png differ diff --git a/node-red-contrib-xiaomi-actions/icons/mi-click.png b/node-red-contrib-xiaomi-actions/icons/mi-click.png new file mode 100644 index 0000000..f04c2cf Binary files /dev/null and b/node-red-contrib-xiaomi-actions/icons/mi-click.png differ diff --git a/node-red-contrib-xiaomi-actions/icons/mi-double-click.png b/node-red-contrib-xiaomi-actions/icons/mi-double-click.png new file mode 100644 index 0000000..23313ed Binary files /dev/null and b/node-red-contrib-xiaomi-actions/icons/mi-double-click.png differ diff --git a/node-red-contrib-xiaomi-actions/icons/mi-list.png b/node-red-contrib-xiaomi-actions/icons/mi-list.png new file mode 100644 index 0000000..af9bb2f Binary files /dev/null and b/node-red-contrib-xiaomi-actions/icons/mi-list.png differ diff --git a/node-red-contrib-xiaomi-actions/icons/mi-mute.png b/node-red-contrib-xiaomi-actions/icons/mi-mute.png new file mode 100644 index 0000000..0a97e87 Binary files /dev/null and b/node-red-contrib-xiaomi-actions/icons/mi-mute.png differ diff --git a/node-red-contrib-xiaomi-actions/icons/mi-off.png b/node-red-contrib-xiaomi-actions/icons/mi-off.png new file mode 100644 index 0000000..2bce1bb Binary files /dev/null and b/node-red-contrib-xiaomi-actions/icons/mi-off.png differ diff --git a/node-red-contrib-xiaomi-actions/icons/mi-on.png b/node-red-contrib-xiaomi-actions/icons/mi-on.png new file mode 100644 index 0000000..ff48563 Binary files /dev/null and b/node-red-contrib-xiaomi-actions/icons/mi-on.png differ diff --git a/node-red-contrib-xiaomi-actions/icons/mi-read.png b/node-red-contrib-xiaomi-actions/icons/mi-read.png new file mode 100644 index 0000000..3acc601 Binary files /dev/null and b/node-red-contrib-xiaomi-actions/icons/mi-read.png differ diff --git a/node-red-contrib-xiaomi-actions/icons/mi-sound.png b/node-red-contrib-xiaomi-actions/icons/mi-sound.png new file mode 100644 index 0000000..5327f59 Binary files /dev/null and b/node-red-contrib-xiaomi-actions/icons/mi-sound.png differ diff --git a/node-red-contrib-xiaomi-actions/xiaomi-actions.html b/node-red-contrib-xiaomi-actions/xiaomi-actions.html index 861bd65..b600998 100644 --- a/node-red-contrib-xiaomi-actions/xiaomi-actions.html +++ b/node-red-contrib-xiaomi-actions/xiaomi-actions.html @@ -33,7 +33,7 @@ inputs:1, outputs:1, paletteLabel: "read", - icon: "function.png", + icon: "mi-read.png", label: function() { return this.name||"read"; } @@ -68,7 +68,7 @@ inputs:1, outputs:1, paletteLabel: "get id list", - icon: "function.png", + icon: "mi-list.png", label: function() { return this.name||"get id list"; } @@ -119,7 +119,7 @@ inputs:1, outputs:1, paletteLabel: "click", - icon: "function.png", + icon: "mi-click.png", label: function() { return this.name||"click"; } @@ -169,7 +169,7 @@ inputs:1, outputs:1, paletteLabel: "double click", - icon: "function.png", + icon: "mi-double-click.png", label: function() { return this.name||"double click"; } @@ -192,7 +192,7 @@ inputs: 1, outputs: 1, paletteLabel: "set light", - icon: "light-icon.png", + icon: "mi-bulb.png", label: function () { return this.name || "set light"; }, @@ -279,7 +279,7 @@ inputs: 1, outputs: 1, paletteLabel: "play sound", - icon: "function.png", + icon: "mi-sound.png", label: function () { return this.name || "play sound"; } @@ -365,7 +365,7 @@ inputs:1, outputs:1, paletteLabel: "stop sound", - icon: "function.png", + icon: "mi-mute.png", label: function() { return this.name||"stop sound"; } @@ -407,7 +407,7 @@ inputs:1, outputs:1, paletteLabel: "on", - icon: "function.png", + icon: "mi-on.png", label: function() { return this.name||"power on"; } @@ -449,7 +449,7 @@ inputs:1, outputs:1, paletteLabel: "off", - icon: "function.png", + icon: "mi-off.png", label: function() { return this.name||"power off"; } diff --git a/node-red-contrib-xiaomi-actions/xiaomi-actions.js b/node-red-contrib-xiaomi-actions/xiaomi-actions.js index 186700a..5f825c0 100644 --- a/node-red-contrib-xiaomi-actions/xiaomi-actions.js +++ b/node-red-contrib-xiaomi-actions/xiaomi-actions.js @@ -111,7 +111,13 @@ module.exports = (RED) => { this.gateway = RED.nodes.getNode(config.gateway); this.on('input', (msg) => { - miDevicesUtils.sendWritePayloadToGateway(this, msg, { status: "on", sid: msg.sid}); + if(msg.sid){ + miDevicesUtils.sendWritePayloadToGateway(this, msg, { status: "on", sid: msg.sid}); + } + else { + msg.payload = "off"; + this.send(msg); + } }); } RED.nodes.registerType("xiaomi-actions on", XiaomiActionPowerOn); @@ -124,7 +130,13 @@ module.exports = (RED) => { this.gateway = RED.nodes.getNode(config.gateway); this.on('input', (msg) => { - miDevicesUtils.sendWritePayloadToGateway(this, msg, { status: "off", sid: msg.sid}); + if(msg.sid){ + miDevicesUtils.sendWritePayloadToGateway(this, msg, { status: "off", sid: msg.sid}); + } + else { + msg.payload = "off"; + this.send(msg); + } }); } RED.nodes.registerType("xiaomi-actions off", XiaomiActionPowerOff); diff --git a/node-red-contrib-xiaomi-all/icons/mi-all.png b/node-red-contrib-xiaomi-all/icons/mi-all.png new file mode 100644 index 0000000..b2c29af Binary files /dev/null and b/node-red-contrib-xiaomi-all/icons/mi-all.png differ diff --git a/node-red-contrib-xiaomi-all/icons/xiaomi-all-icon.png b/node-red-contrib-xiaomi-all/icons/xiaomi-all-icon.png deleted file mode 100644 index 62ac357..0000000 Binary files a/node-red-contrib-xiaomi-all/icons/xiaomi-all-icon.png and /dev/null differ diff --git a/node-red-contrib-xiaomi-all/xiaomi-all.html b/node-red-contrib-xiaomi-all/xiaomi-all.html index a9cf956..b1c6289 100644 --- a/node-red-contrib-xiaomi-all/xiaomi-all.html +++ b/node-red-contrib-xiaomi-all/xiaomi-all.html @@ -10,7 +10,7 @@ outputs: 1, outputLabels: ["All devices"], paletteLabel: "all", - icon: "xiaomi-all-icon.png", + icon: "mi-all.png", label: function () { return this.name || "xiaomi-all"; } diff --git a/node-red-contrib-xiaomi-gateway/icons/mijia-io.png b/node-red-contrib-xiaomi-gateway/icons/mijia-io.png new file mode 100644 index 0000000..7058afb Binary files /dev/null and b/node-red-contrib-xiaomi-gateway/icons/mijia-io.png differ diff --git a/node-red-contrib-xiaomi-gateway/xiaomi-gateway.html b/node-red-contrib-xiaomi-gateway/xiaomi-gateway.html index 04dbcd0..b5059a2 100644 --- a/node-red-contrib-xiaomi-gateway/xiaomi-gateway.html +++ b/node-red-contrib-xiaomi-gateway/xiaomi-gateway.html @@ -81,7 +81,7 @@ inputs:0, outputs:1, paletteLabel: "gateway in", - icon: "bridge-dash.png", + icon: "mijia-io.png", label: function() { return this.name||"xiaomi-gateway"; }, @@ -142,7 +142,7 @@ inputs:1, outputs:0, paletteLabel: "gateway out", - icon: "bridge-dash.png", + icon: "mijia-io.png", align: "right", label: function() { return this.name||"xiaomi-gateway"; diff --git a/node-red-contrib-xiaomi-switch/icons/light-icon.png b/node-red-contrib-xiaomi-switch/icons/light-icon.png deleted file mode 100644 index 020b8a0..0000000 Binary files a/node-red-contrib-xiaomi-switch/icons/light-icon.png and /dev/null differ diff --git a/node-red-contrib-xiaomi-switch/icons/mi-switch.png b/node-red-contrib-xiaomi-switch/icons/mi-switch.png new file mode 100644 index 0000000..8ee44b2 Binary files /dev/null and b/node-red-contrib-xiaomi-switch/icons/mi-switch.png differ diff --git a/node-red-contrib-xiaomi-switch/xiaomi-switch.html b/node-red-contrib-xiaomi-switch/xiaomi-switch.html index cceefb7..6992084 100644 --- a/node-red-contrib-xiaomi-switch/xiaomi-switch.html +++ b/node-red-contrib-xiaomi-switch/xiaomi-switch.html @@ -13,7 +13,7 @@ inputs: 1, outputs: 1, paletteLabel: "switch", - icon: "light-icon.png", + icon: "mi-switch.png", label: function () { return this.name || "xiaomi-switch"; }, diff --git a/resources/mi-devices-sample.png b/resources/mi-devices-sample.png index f4601ef..c844562 100644 Binary files a/resources/mi-devices-sample.png and b/resources/mi-devices-sample.png differ