feat(devices): handle yeelight basic support
Delete gateway in action config. Close #4, close #8 and close #9
No files matched your search
@@ -14,6 +14,8 @@ The following devices are currently supported:
|
|||||||
* Motion sensor
|
* Motion sensor
|
||||||
* Power plug (zigbee)
|
* Power plug (zigbee)
|
||||||
* Power plug (wifi)
|
* Power plug (wifi)
|
||||||
|
* Yeelight White (mono)
|
||||||
|
* Yeelight RGB
|
||||||
|
|
||||||
## Preperation
|
## Preperation
|
||||||
|
|
||||||
@@ -42,13 +44,13 @@ Tip: use the configurator from the side-panel (hamburger menu, configuration nod
|
|||||||
|
|
||||||
### How to use different nodes
|
### How to use different nodes
|
||||||
|
|
||||||
Here an example of how to use the different nodes (screenshot of [importable flows-overview.json](flows-overview.json "Mi Devices overview")):
|
Here an example of how to use the different nodes (screenshot of [importable flows-overview.json](flows-overview.json?raw=true "Mi Devices overview")):
|
||||||

|

|
||||||
|
|
||||||
|
|
||||||
### Sample flows
|
### Sample flows
|
||||||
|
|
||||||
Here are different flow (screenshot of [importable flows-sample.json](flows-sample.json "Different flows using Mi Devices")):
|
Here are different flow (screenshot of [importable flows-sample.json](flows-sample.json?raw=true "Different flows using Mi Devices")):
|
||||||

|

|
||||||
|
|
||||||
## Enable LAN mode
|
## Enable LAN mode
|
||||||
@@ -59,7 +61,7 @@ Here are different flow (screenshot of [importable flows-sample.json](flows-samp
|
|||||||
2. Make sure you set your region to: Mainland China under settings -> Locale - required for the moment.
|
2. Make sure you set your region to: Mainland China under settings -> Locale - required for the moment.
|
||||||
Mainland China and language can set on English.
|
Mainland China and language can set on English.
|
||||||
3. Select your Gateway in Mi Home
|
3. Select your Gateway in Mi Home
|
||||||
4. Then the 3 dots at the top right of the screen
|
4. Then click 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 (like the first screenshot below, 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!)
|
||||||
@@ -72,6 +74,19 @@ If you change here something, you lose your password!
|
|||||||

|

|
||||||

|

|
||||||
|
|
||||||
|
### Yeelight
|
||||||
|
|
||||||
|
1. Install Yeelight App
|
||||||
|
2. Select your Yeelight in Mi Home
|
||||||
|
3. Then click the third icon at the bottom of the screen
|
||||||
|
4. Then click on the lightning icon "LAN control"
|
||||||
|
5. In the new panel, toggle the switch to "on"
|
||||||
|
|
||||||
|
The lightning icon should be underline un yellow.
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
## Sources
|
## Sources
|
||||||
|
|
||||||
* [Harald Rietman node-red module](https://github.com/hrietman/node-red-contrib-xiaomi-devices)
|
* [Harald Rietman node-red module](https://github.com/hrietman/node-red-contrib-xiaomi-devices)
|
||||||
@@ -79,6 +94,7 @@ If you change here something, you lose your password!
|
|||||||
* [louisZl Gateway Local API](https://github.com/louisZL/lumi-gateway-local-api)
|
* [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)
|
* [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)
|
* [Node-red UDP nodes](https://github.com/node-red/node-red/blob/master/nodes/core/io/32-udp.js)
|
||||||
|
* [Yeelight specs](http://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf)
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
|
|||||||
@@ -1,477 +1 @@
|
|||||||
[
|
[{"id":"b7132358.47476","type":"tab","label":"Mi Devices Overview","disabled":false,"info":""},{"id":"37ac569b.b3ef02","type":"xiaomi-gateway in","z":"b7132358.47476","name":"","gateway":"","ip":"","x":100,"y":220,"wires":[["b7bdc18a.4b45","94672654.872fb","b03e7c0c.d344e","540ce4ae.b5a26c","a6d2ae60.7ee088","bb36a54.ac665d8","3229d6fd.1e35fa"]]},{"id":"b7bdc18a.4b45","type":"xiaomi-ht","z":"b7132358.47476","gateway":"","name":"","sid":"","x":420,"y":140,"wires":[["37052c54.e2b62c"]]},{"id":"94672654.872fb","type":"xiaomi-magnet","z":"b7132358.47476","gateway":"","name":"","sid":"","x":440,"y":180,"wires":[["37052c54.e2b62c"]]},{"id":"b03e7c0c.d344e","type":"xiaomi-motion","z":"b7132358.47476","gateway":"","name":"","sid":"","motionmsg":"","nomotionmsg":"","output":"0","x":440,"y":220,"wires":[["37052c54.e2b62c"]]},{"id":"540ce4ae.b5a26c","type":"xiaomi-switch","z":"b7132358.47476","gateway":"","name":"","sid":"","x":440,"y":260,"wires":[["37052c54.e2b62c"]]},{"id":"a6d2ae60.7ee088","type":"xiaomi-gateway","z":"b7132358.47476","gateway":"","name":"","x":440,"y":300,"wires":[["37052c54.e2b62c"]]},{"id":"bb36a54.ac665d8","type":"xiaomi-plug","z":"b7132358.47476","gateway":"","name":"","sid":"","onmsg":"","offmsg":"","output":"0","x":430,"y":340,"wires":[["37052c54.e2b62c"]]},{"id":"37052c54.e2b62c","type":"debug","z":"b7132358.47476","name":"","active":true,"console":"false","complete":"true","x":710,"y":220,"wires":[]},{"id":"a2db7256.81c91","type":"xiaomi-ht","z":"b7132358.47476","gateway":"","name":"","sid":"","x":480,"y":560,"wires":[["ee6734f2.6e1e6"]]},{"id":"1f15867.488737a","type":"xiaomi-magnet","z":"b7132358.47476","gateway":"","name":"","sid":"","x":500,"y":600,"wires":[["ee6734f2.6e1e6"]]},{"id":"36a62693.5c11b2","type":"xiaomi-motion","z":"b7132358.47476","gateway":"","name":"","sid":"","motionmsg":"","nomotionmsg":"","output":"0","x":500,"y":640,"wires":[["ee6734f2.6e1e6"]]},{"id":"79681c1e.90ebdc","type":"xiaomi-switch","z":"b7132358.47476","gateway":"","name":"","sid":"","x":500,"y":700,"wires":[["ee6734f2.6e1e6","9e60c17d.8a64a8","6d2591a6.89d498"]]},{"id":"d5fb64b6.8e94e8","type":"xiaomi-gateway","z":"b7132358.47476","gateway":"","name":"","x":500,"y":760,"wires":[["ee6734f2.6e1e6","ff64227b.22f8a","92cbad8e.098568","520452ff.0f57e4","87e164af.8c453"]]},{"id":"6f3e29cc.ab17e","type":"inject","z":"b7132358.47476","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":100,"y":700,"wires":[["a2db7256.81c91","1f15867.488737a","36a62693.5c11b2","79681c1e.90ebdc","d5fb64b6.8e94e8","3ae7a6cd.805cda","61d3e354.cc9f7c","f9105b74.d9fc5","48720e7b.df608","2e3bfe95.2f5a9a","39683881.e496b8","1e24075e.7c64a9","e3216d45.144648"]]},{"id":"3ae7a6cd.805cda","type":"xiaomi-plug","z":"b7132358.47476","gateway":"","name":"","sid":"","onmsg":"","offmsg":"","output":"0","x":490,"y":820,"wires":[["ee6734f2.6e1e6","b46eec04.6a401","53516e47.bdb338"]]},{"id":"61d3e354.cc9f7c","type":"xiaomi-plug-wifi","z":"b7132358.47476","name":"","ip":"","onmsg":"","offmsg":"","output":"0","x":500,"y":880,"wires":[[]]},{"id":"ee6734f2.6e1e6","type":"xiaomi-actions read","z":"b7132358.47476","name":"","x":810,"y":580,"wires":[["1aa456d0.dea0e9"]]},{"id":"ff64227b.22f8a","type":"xiaomi-actions get_id_list","z":"b7132358.47476","name":"","x":820,"y":800,"wires":[["1aa456d0.dea0e9"]]},{"id":"92cbad8e.098568","type":"xiaomi-actions gateway_light","z":"b7132358.47476","name":"","brightness":100,"hexRgbColor":"#ffffff","color":{"red":255,"green":255,"blue":255},"x":820,"y":840,"wires":[["1aa456d0.dea0e9"]]},{"id":"520452ff.0f57e4","type":"xiaomi-actions gateway_sound","z":"b7132358.47476","name":"","mid":"","volume":"","x":830,"y":880,"wires":[["1aa456d0.dea0e9"]]},{"id":"87e164af.8c453","type":"xiaomi-actions gateway_stop_sound","z":"b7132358.47476","name":"","x":830,"y":920,"wires":[["1aa456d0.dea0e9"]]},{"id":"b46eec04.6a401","type":"xiaomi-actions on","z":"b7132358.47476","name":"","x":820,"y":980,"wires":[["1aa456d0.dea0e9"]]},{"id":"53516e47.bdb338","type":"xiaomi-actions off","z":"b7132358.47476","name":"","x":820,"y":1020,"wires":[["1aa456d0.dea0e9"]]},{"id":"9e60c17d.8a64a8","type":"xiaomi-actions click","z":"b7132358.47476","name":"","x":810,"y":680,"wires":[["1aa456d0.dea0e9"]]},{"id":"6d2591a6.89d498","type":"xiaomi-actions double_click","z":"b7132358.47476","name":"","x":830,"y":720,"wires":[["1aa456d0.dea0e9"]]},{"id":"1aa456d0.dea0e9","type":"xiaomi-gateway out","z":"b7132358.47476","name":"","gateway":"","ip":"","x":1200,"y":780,"wires":[]},{"id":"f9105b74.d9fc5","type":"xiaomi-actions on","z":"b7132358.47476","name":"","x":280,"y":860,"wires":[["61d3e354.cc9f7c"]]},{"id":"48720e7b.df608","type":"xiaomi-actions off","z":"b7132358.47476","name":"","x":280,"y":900,"wires":[["61d3e354.cc9f7c"]]},{"id":"29bb58e2.28de","type":"comment","z":"b7132358.47476","name":"Filter incoming","info":"","x":420,"y":40,"wires":[]},{"id":"33967b37.6d4e44","type":"comment","z":"b7132358.47476","name"Line truncated
|
||||||
{
|
|
||||||
"id": "d6af659e.672c78",
|
|
||||||
"type": "tab",
|
|
||||||
"label": "Mi Devices Overview",
|
|
||||||
"disabled": false,
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "8b46a76a.3750f8",
|
|
||||||
"type": "xiaomi-gateway in",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"name": "",
|
|
||||||
"gateway": "",
|
|
||||||
"ip": "",
|
|
||||||
"x": 100,
|
|
||||||
"y": 260,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"c6c7895f.ca9ed",
|
|
||||||
"fff96479.f72ff8",
|
|
||||||
"896173ae.aff0c",
|
|
||||||
"55f81bbe.cdf944",
|
|
||||||
"e3bc2a33.7bc178",
|
|
||||||
"6b4e0181.7aac38"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "c6c7895f.ca9ed",
|
|
||||||
"type": "xiaomi-ht",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"sid": "",
|
|
||||||
"x": 420,
|
|
||||||
"y": 120,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"a196a200.9d0ca8"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "fff96479.f72ff8",
|
|
||||||
"type": "xiaomi-magnet",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"sid": "",
|
|
||||||
"x": 440,
|
|
||||||
"y": 180,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"a196a200.9d0ca8"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "896173ae.aff0c",
|
|
||||||
"type": "xiaomi-motion",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"sid": "",
|
|
||||||
"motionmsg": "",
|
|
||||||
"nomotionmsg": "",
|
|
||||||
"output": "0",
|
|
||||||
"x": 440,
|
|
||||||
"y": 240,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"a196a200.9d0ca8"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "55f81bbe.cdf944",
|
|
||||||
"type": "xiaomi-switch",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"sid": "",
|
|
||||||
"outmsg": "{{click}}",
|
|
||||||
"outmsgdbcl": "{{double_click}}",
|
|
||||||
"output": "0",
|
|
||||||
"x": 440,
|
|
||||||
"y": 300,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"a196a200.9d0ca8"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "e3bc2a33.7bc178",
|
|
||||||
"type": "xiaomi-gateway",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"x": 440,
|
|
||||||
"y": 360,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"a196a200.9d0ca8"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "6b4e0181.7aac38",
|
|
||||||
"type": "xiaomi-plug",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"sid": "",
|
|
||||||
"onmsg": "",
|
|
||||||
"offmsg": "",
|
|
||||||
"output": "0",
|
|
||||||
"x": 430,
|
|
||||||
"y": 420,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"a196a200.9d0ca8"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "a196a200.9d0ca8",
|
|
||||||
"type": "debug",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"name": "",
|
|
||||||
"active": true,
|
|
||||||
"console": "false",
|
|
||||||
"complete": "true",
|
|
||||||
"x": 790,
|
|
||||||
"y": 280,
|
|
||||||
"wires": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "fced461e.36cda",
|
|
||||||
"type": "xiaomi-ht",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"sid": "",
|
|
||||||
"x": 480,
|
|
||||||
"y": 580,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"f2d6b99.0cc43c8"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "5f9390f2.5a3798",
|
|
||||||
"type": "xiaomi-magnet",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"sid": "",
|
|
||||||
"x": 500,
|
|
||||||
"y": 640,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"f2d6b99.0cc43c8"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "727ea237.226064",
|
|
||||||
"type": "xiaomi-motion",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"sid": "",
|
|
||||||
"motionmsg": "",
|
|
||||||
"nomotionmsg": "",
|
|
||||||
"output": "0",
|
|
||||||
"x": 500,
|
|
||||||
"y": 700,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"f2d6b99.0cc43c8"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "9b7afab9.3b9d28",
|
|
||||||
"type": "xiaomi-switch",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"sid": "",
|
|
||||||
"outmsg": "{{click}}",
|
|
||||||
"outmsgdbcl": "{{double_click}}",
|
|
||||||
"output": "0",
|
|
||||||
"x": 500,
|
|
||||||
"y": 760,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"f2d6b99.0cc43c8",
|
|
||||||
"87e3d24d.dca938",
|
|
||||||
"17f55e85.67fa39"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "56b84611.e528d",
|
|
||||||
"type": "xiaomi-gateway",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"x": 500,
|
|
||||||
"y": 820,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"f2d6b99.0cc43c8",
|
|
||||||
"63506419.25ea9c",
|
|
||||||
"802789b5.325168",
|
|
||||||
"f5d2d9a.c0cfaa8",
|
|
||||||
"714e9c81.a6814c"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "f56c4e2.98543b",
|
|
||||||
"type": "inject",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"name": "",
|
|
||||||
"topic": "",
|
|
||||||
"payload": "",
|
|
||||||
"payloadType": "date",
|
|
||||||
"repeat": "",
|
|
||||||
"crontab": "",
|
|
||||||
"once": false,
|
|
||||||
"x": 100,
|
|
||||||
"y": 700,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"fced461e.36cda",
|
|
||||||
"5f9390f2.5a3798",
|
|
||||||
"727ea237.226064",
|
|
||||||
"9b7afab9.3b9d28",
|
|
||||||
"56b84611.e528d",
|
|
||||||
"cde54564.5db488",
|
|
||||||
"2e035ef8.13ee12",
|
|
||||||
"6e073d99.348974",
|
|
||||||
"5d917375.467da4"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "cde54564.5db488",
|
|
||||||
"type": "xiaomi-plug",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"sid": "",
|
|
||||||
"onmsg": "",
|
|
||||||
"offmsg": "",
|
|
||||||
"output": "0",
|
|
||||||
"x": 490,
|
|
||||||
"y": 880,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"f2d6b99.0cc43c8",
|
|
||||||
"6dde3295.cc1f94",
|
|
||||||
"bc27b766.47eb"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "2e035ef8.13ee12",
|
|
||||||
"type": "xiaomi-plug-wifi",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"name": "",
|
|
||||||
"ip": "",
|
|
||||||
"onmsg": "",
|
|
||||||
"offmsg": "",
|
|
||||||
"output": "0",
|
|
||||||
"x": 500,
|
|
||||||
"y": 940,
|
|
||||||
"wires": [
|
|
||||||
[]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "f2d6b99.0cc43c8",
|
|
||||||
"type": "xiaomi-actions read",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"name": "",
|
|
||||||
"x": 810,
|
|
||||||
"y": 580,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"39eb644e.a67c94"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "63506419.25ea9c",
|
|
||||||
"type": "xiaomi-actions get_id_list",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"name": "",
|
|
||||||
"x": 820,
|
|
||||||
"y": 800,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"39eb644e.a67c94"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "802789b5.325168",
|
|
||||||
"type": "xiaomi-actions gateway_light",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"brightness": 100,
|
|
||||||
"hexRgbColor": "#ffffff",
|
|
||||||
"color": {
|
|
||||||
"red": 255,
|
|
||||||
"green": 255,
|
|
||||||
"blue": 255
|
|
||||||
},
|
|
||||||
"x": 820,
|
|
||||||
"y": 840,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"39eb644e.a67c94"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "f5d2d9a.c0cfaa8",
|
|
||||||
"type": "xiaomi-actions gateway_sound",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"mid": "",
|
|
||||||
"volume": "",
|
|
||||||
"x": 830,
|
|
||||||
"y": 880,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"39eb644e.a67c94"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "714e9c81.a6814c",
|
|
||||||
"type": "xiaomi-actions gateway_stop_sound",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"x": 830,
|
|
||||||
"y": 920,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"39eb644e.a67c94"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "6dde3295.cc1f94",
|
|
||||||
"type": "xiaomi-actions on",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"x": 820,
|
|
||||||
"y": 980,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"39eb644e.a67c94"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "bc27b766.47eb",
|
|
||||||
"type": "xiaomi-actions off",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"x": 820,
|
|
||||||
"y": 1020,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"39eb644e.a67c94"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "87e3d24d.dca938",
|
|
||||||
"type": "xiaomi-actions click",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"name": "",
|
|
||||||
"x": 810,
|
|
||||||
"y": 680,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"39eb644e.a67c94"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "17f55e85.67fa39",
|
|
||||||
"type": "xiaomi-actions double_click",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"name": "",
|
|
||||||
"x": 830,
|
|
||||||
"y": 720,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"39eb644e.a67c94"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "39eb644e.a67c94",
|
|
||||||
"type": "xiaomi-gateway out",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"name": "",
|
|
||||||
"gateway": "",
|
|
||||||
"ip": "",
|
|
||||||
"x": 1200,
|
|
||||||
"y": 780,
|
|
||||||
"wires": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "6e073d99.348974",
|
|
||||||
"type": "xiaomi-actions on",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"x": 280,
|
|
||||||
"y": 920,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"2e035ef8.13ee12"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "5d917375.467da4",
|
|
||||||
"type": "xiaomi-actions off",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"gateway": "",
|
|
||||||
"name": "",
|
|
||||||
"x": 280,
|
|
||||||
"y": 960,
|
|
||||||
"wires": [
|
|
||||||
[
|
|
||||||
"2e035ef8.13ee12"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "bd81cdbf.1964",
|
|
||||||
"type": "comment",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"name": "Filter incoming",
|
|
||||||
"info": "",
|
|
||||||
"x": 420,
|
|
||||||
"y": 40,
|
|
||||||
"wires": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "99d83097.bf0968",
|
|
||||||
"type": "comment",
|
|
||||||
"z": "d6af659e.672c78",
|
|
||||||
"name": "Outgoing",
|
|
||||||
"info": "",
|
|
||||||
"x": 420,
|
|
||||||
"y": 500,
|
|
||||||
"wires": []
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,586 +1 @@
|
|||||||
[
|
[{"id":"42c840ac.0d4088","type":"tab","label":"Mi Devices Sample","disabled":false,"info":""},{"id":"a2d5e2c3.b92fd","type":"comment","z":"42c840ac.0d4088","name":"Get all sensors and gateway statuses","info":"","x":390,"y":40,"wires":[]},{"id":"c53c673b.414f28","type":"inject","z":"42c840ac.0d4088","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":true,"x":107.14285714285711,"y":95,"wires":[["41eb0695.e63408","eafddced.3b04a"]]},{"id":"41eb0695.e63408","type":"xiaomi-all","z":"42c840ac.0d4088","gateway":"","name":"","x":300,"y":100,"wires":[["91c1bb66.39253"]]},{"id":"eafddced.3b04a","type":"xiaomi-gateway","z":"42c840ac.0d4088","gateway":"","name":"","x":320,"y":160,"wires":[["d19fb980.133f68"]]},{"id":"91c1bb66.39253","type":"split","z":"42c840ac.0d4088","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":490,"y":100,"wires":[["3185cd39.74c96a"]]},{"id":"3185cd39.74c96a","type":"change","z":"42c840ac.0d4088","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":[["d19fb980.133f68"]]},{"id":"d19fb980.133f68","type":"xiaomi-actions read","z":"42c840ac.0d4088","name":"","x":810,"y":100,"wires":[["257a96ea.456742"]]},{"id":"257a96ea.456742","type":"xiaomi-gateway out","z":"42c840ac.0d4088","name":"","gateway":"","ip":"","x":1000,"y":100,"wires":[]},{"id":"15a7a55c.ee2a13","type":"comment","z":"42c840ac.0d4088","name":"Check if a window at least one window open","info":"","x":410,"y":300,"wires":[]},{"id":"6444fdcc.e8d0b4","type":"xiaomi-all","z":"42c840ac.0d4088","gateway":"","name":"","x":300,"y":360,"wires":[["f3ac9439.133d68","47f2046.6bea47c"]]},{"id":"c04374e6.58de3","type":"split","z":"42c840ac.0d4088","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":630,"y":360,"wires":[["97dc0a89.8f2808"]]},{"id":"f3ac9439.133d68","type":"function","z":"42c840ac.0d4088","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":[["c04374e6.58de3"]]},{"id":"97dc0a89.8f2808","type":"change","z":"42c840ac.0d4088","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":[["c92e4522.5f451"]]},{"id":"c92e4522.5f451","type":"xiaomi-actions read","z":"42c840ac.0d4088","name":"","x":910,"y":360,"wires":[["faa7cd47.2f0ed"]]},{"id":"faa7cd47.2f0ed","type":"xiaomi-gateway out","z":"42c840ac.0d4088","name":"","gateway":"","ip":"","x":1100,"y":360,"wires":[]},{"id":"a354a2db.a472c8","type":"xiaomi-gateway in","z":"42c840ac.0d4088","name":"","gateway":"","ip":"","x":100,"y":480,"wires":[["c888e01a.97754"]]},{"id":"c888e01a.97754","type":"function","z":"42c840ac.0d4088","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":"b6ce1add.fd8098","type":"function","z":"42c840ac.0d4088","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":"47f2046.6bea47c","type":"delay","z":"42c840ac.0d4088","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":[["b6ce1add.fd8098"]]},{"id":"d85b4cea.a9e338","type":"comment","z":"42c840ac.0d4088","name":"Doorbell","info":"","x":300,"y":580,"wires":[]},{"id":"f1a76c90.712d08","type":"xiaomi-gateway in","z":"42c840ac.0d4088","name":"","gateway":"","ip":"","x":100,"y":660,"wires":[["2418c093.cc257"]]},{"id":"b11d36c7.eac58","type":"function","z":"42c840ac.0d4088","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":[["f7756ac2.ebcec","b82c564e.b4d968","65bfdf1e.559d48"]]},{"id":"f7756ac2.ebcec","type":"xiaomi-actions gateway_sound","z":"42c840ac.0d4088","name":"","mid":"10",Line truncated
|
||||||
{
|
|
||||||
"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"
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -86,10 +86,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-help-name="xiaomi-actions click">
|
<script type="text/x-red" data-help-name="xiaomi-actions click">
|
||||||
<p>
|
<p>Virtual single click for switch.</p>
|
||||||
Virtual single click for switch.
|
|
||||||
Note: a gateway input node must be present and have receive a message to get gateway tokens and be able to do the action.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
@@ -136,10 +133,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-help-name="xiaomi-actions double_click">
|
<script type="text/x-red" data-help-name="xiaomi-actions double_click">
|
||||||
<p>
|
<p>Virtual double click for switch.</p>
|
||||||
Virtual double click for switch.
|
|
||||||
Note: a gateway input node must be present and have receive a message to get gateway tokens and be able to do the action.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
@@ -183,7 +177,6 @@
|
|||||||
category: 'xiaomi actions',
|
category: 'xiaomi actions',
|
||||||
color: '#64C4CD',
|
color: '#64C4CD',
|
||||||
defaults: {
|
defaults: {
|
||||||
gateway: {value:"", type:"xiaomi-configurator"},
|
|
||||||
name: {value: ""},
|
name: {value: ""},
|
||||||
brightness: {value: 100},
|
brightness: {value: 100},
|
||||||
hexRgbColor: {value: "#ffffff"},
|
hexRgbColor: {value: "#ffffff"},
|
||||||
@@ -211,10 +204,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-template-name="xiaomi-actions gateway_light">
|
<script type="text/x-red" data-template-name="xiaomi-actions gateway_light">
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-gateway"><i class="icon-tag"></i> Gateway</label>
|
|
||||||
<input type="text" id="node-input-gateway" placeholder="xiaomi gateway">
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||||
<input type="text" id="node-input-name" placeholder="Name">
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
@@ -230,9 +219,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-help-name="xiaomi-actions gateway_light">
|
<script type="text/x-red" data-help-name="xiaomi-actions gateway_light">
|
||||||
<p>Change the light of the gateway.
|
<p>Change the light of the gateway.</p>
|
||||||
Note: a gateway input node must be present and have receive a message to get gateway tokens and be able to do the action.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
@@ -271,7 +258,6 @@
|
|||||||
category: 'xiaomi actions',
|
category: 'xiaomi actions',
|
||||||
color: '#64C4CD',
|
color: '#64C4CD',
|
||||||
defaults: {
|
defaults: {
|
||||||
gateway: {value:"", type:"xiaomi-configurator"},
|
|
||||||
name: {value: ""},
|
name: {value: ""},
|
||||||
mid: {value: ""},
|
mid: {value: ""},
|
||||||
volume: {value: ""}
|
volume: {value: ""}
|
||||||
@@ -287,10 +273,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-template-name="xiaomi-actions gateway_sound">
|
<script type="text/x-red" data-template-name="xiaomi-actions gateway_sound">
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-gateway"><i class="icon-tag"></i> Gateway</label>
|
|
||||||
<input type="text" id="node-input-gateway" placeholder="xiaomi gateway">
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||||
<input type="text" id="node-input-name" placeholder="Name">
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
@@ -330,9 +312,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/x-red" data-help-name="xiaomi-actions gateway_sound">
|
<script type="text/x-red" data-help-name="xiaomi-actions gateway_sound">
|
||||||
<p>Play a sound on the gateway.
|
<p>Play a sound on the gateway.</p>
|
||||||
Note: a gateway input node must be present and have receive a message to get gateway tokens and be able to do the action.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h3>Inputs</h3>
|
<h3>Inputs</h3>
|
||||||
<dl class="message-properties">
|
<dl class="message-properties">
|
||||||
@@ -359,7 +339,6 @@
|
|||||||
category: 'xiaomi actions',
|
category: 'xiaomi actions',
|
||||||
color: '#64C4CD',
|
color: '#64C4CD',
|
||||||
defaults: {
|
defaults: {
|
||||||
gateway: {value:"", type:"xiaomi-configurator"},
|
|
||||||
name: {value:""}
|
name: {value:""}
|
||||||
},
|
},
|
||||||
inputs:1,
|
inputs:1,
|
||||||
@@ -372,10 +351,6 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script type="text/x-red" data-template-name="xiaomi-actions gateway_stop_sound">
|
<script type="text/x-red" data-template-name="xiaomi-actions gateway_stop_sound">
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-gateway"><i class="icon-tag"></i> Gateway</label>
|
|
||||||
<input type="text" id="node-input-gateway" placeholder="xiaomi gateway">
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||||
<input type="text" id="node-input-name" placeholder="Name">
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
@@ -385,7 +360,6 @@
|
|||||||
<script type="text/x-red" data-help-name="xiaomi-actions gateway_stop_sound">
|
<script type="text/x-red" data-help-name="xiaomi-actions gateway_stop_sound">
|
||||||
<p>
|
<p>
|
||||||
Stop current playing sound on the gateway.
|
Stop current playing sound on the gateway.
|
||||||
Note: a gateway input node must be present and have receive a message to get gateway tokens and be able to do the action.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3>Outputs</h3>
|
<h3>Outputs</h3>
|
||||||
@@ -395,13 +369,12 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<!-- The plug "on" Node -->
|
<!-- The "on" Node -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('xiaomi-actions on',{
|
RED.nodes.registerType('xiaomi-actions on',{
|
||||||
category: 'xiaomi actions',
|
category: 'xiaomi actions',
|
||||||
color: '#64C4CD',
|
color: '#64C4CD',
|
||||||
defaults: {
|
defaults: {
|
||||||
gateway: {value:"", type:"xiaomi-configurator"},
|
|
||||||
name: {value:""}
|
name: {value:""}
|
||||||
},
|
},
|
||||||
inputs:1,
|
inputs:1,
|
||||||
@@ -414,10 +387,6 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script type="text/x-red" data-template-name="xiaomi-actions on">
|
<script type="text/x-red" data-template-name="xiaomi-actions on">
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-gateway"><i class="icon-tag"></i> Gateway</label>
|
|
||||||
<input type="text" id="node-input-gateway" placeholder="xiaomi gateway">
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||||
<input type="text" id="node-input-name" placeholder="Name">
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
@@ -427,23 +396,21 @@
|
|||||||
<script type="text/x-red" data-help-name="xiaomi-actions on">
|
<script type="text/x-red" data-help-name="xiaomi-actions on">
|
||||||
<p>
|
<p>
|
||||||
Turn input device to on.
|
Turn input device to on.
|
||||||
Note: a gateway input node must be present and have receive a message to get gateway tokens and be able to do the action.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3>Outputs</h3>
|
<h3>Outputs</h3>
|
||||||
<ol class="node-ports">
|
<ol class="node-ports">
|
||||||
<li>Message to connect to a gateway out node.</li>
|
<li>Message to connect to a gateway/yeelight out node.</li>
|
||||||
</ol>
|
</ol>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<!-- The plug "off" Node -->
|
<!-- The "off" Node -->
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
RED.nodes.registerType('xiaomi-actions off',{
|
RED.nodes.registerType('xiaomi-actions off',{
|
||||||
category: 'xiaomi actions',
|
category: 'xiaomi actions',
|
||||||
color: '#64C4CD',
|
color: '#64C4CD',
|
||||||
defaults: {
|
defaults: {
|
||||||
gateway: {value:"", type:"xiaomi-configurator"},
|
|
||||||
name: {value:""}
|
name: {value:""}
|
||||||
},
|
},
|
||||||
inputs:1,
|
inputs:1,
|
||||||
@@ -456,10 +423,6 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script type="text/x-red" data-template-name="xiaomi-actions off">
|
<script type="text/x-red" data-template-name="xiaomi-actions off">
|
||||||
<div class="form-row">
|
|
||||||
<label for="node-input-gateway"><i class="icon-tag"></i> Gateway</label>
|
|
||||||
<input type="text" id="node-input-gateway" placeholder="xiaomi gateway">
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||||
<input type="text" id="node-input-name" placeholder="Name">
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
@@ -469,11 +432,44 @@
|
|||||||
<script type="text/x-red" data-help-name="xiaomi-actions off">
|
<script type="text/x-red" data-help-name="xiaomi-actions off">
|
||||||
<p>
|
<p>
|
||||||
Turn input device to off.
|
Turn input device to off.
|
||||||
Note: a gateway input node must be present and have receive a message to get gateway tokens and be able to do the action.
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h3>Outputs</h3>
|
<h3>Outputs</h3>
|
||||||
<ol class="node-ports">
|
<ol class="node-ports">
|
||||||
<li>Message to connect to a gateway out node.</li>
|
<li>Message to connect to a gateway/yeelight out node.</li>
|
||||||
|
</ol>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- The "toggle" Node -->
|
||||||
|
<script type="text/javascript">
|
||||||
|
RED.nodes.registerType('xiaomi-actions toggle',{
|
||||||
|
category: 'xiaomi actions',
|
||||||
|
color: '#64C4CD',
|
||||||
|
defaults: {
|
||||||
|
name: {value:""}
|
||||||
|
},
|
||||||
|
inputs:1,
|
||||||
|
outputs:1,
|
||||||
|
paletteLabel: "toggle",
|
||||||
|
icon: "mi-toggle.png",
|
||||||
|
label: function() {
|
||||||
|
return this.name||"toggle power";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<script type="text/x-red" data-template-name="xiaomi-actions toggle">
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||||
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/x-red" data-help-name="xiaomi-actions toggle">
|
||||||
|
<p>Toggle device.</p>
|
||||||
|
|
||||||
|
<h3>Outputs</h3>
|
||||||
|
<ol class="node-ports">
|
||||||
|
<li>Message to connect to a gateway/yeelight out node.</li>
|
||||||
</ol>
|
</ol>
|
||||||
</script>
|
</script>
|
||||||
@@ -36,8 +36,11 @@ module.exports = (RED) => {
|
|||||||
RED.nodes.createNode(this, config);
|
RED.nodes.createNode(this, config);
|
||||||
|
|
||||||
this.on('input', (msg) => {
|
this.on('input', (msg) => {
|
||||||
this.gateway = msg.gateway;
|
msg.payload = {
|
||||||
miDevicesUtils.sendWritePayloadToGateway(this, msg, {status: "click", sid: msg.sid});
|
cmd: "write",
|
||||||
|
data: { status: "click", sid: msg.sid }
|
||||||
|
};
|
||||||
|
this.send(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("xiaomi-actions click", XiaomiActionSingleClick);
|
RED.nodes.registerType("xiaomi-actions click", XiaomiActionSingleClick);
|
||||||
@@ -49,7 +52,11 @@ module.exports = (RED) => {
|
|||||||
RED.nodes.createNode(this, config);
|
RED.nodes.createNode(this, config);
|
||||||
|
|
||||||
this.on('input', (msg) => {
|
this.on('input', (msg) => {
|
||||||
miDevicesUtils.sendWritePayloadToGateway(this, msg, {status: "double_click", sid: msg.sid});
|
msg.payload = {
|
||||||
|
cmd: "write",
|
||||||
|
data: { status: "double_click", sid: msg.sid }
|
||||||
|
};
|
||||||
|
this.send(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("xiaomi-actions double_click", XiaomiActionDoubleClick);
|
RED.nodes.registerType("xiaomi-actions double_click", XiaomiActionDoubleClick);
|
||||||
@@ -59,15 +66,26 @@ module.exports = (RED) => {
|
|||||||
*********************************************/
|
*********************************************/
|
||||||
function XiaomiActionGatewayLight(config) {
|
function XiaomiActionGatewayLight(config) {
|
||||||
RED.nodes.createNode(this, config);
|
RED.nodes.createNode(this, config);
|
||||||
this.gateway = RED.nodes.getNode(config.gateway);
|
this.color = config.color;
|
||||||
this.color = RED.nodes.getNode(config.color);
|
this.brightness = config.brightness;
|
||||||
this.brightness = RED.nodes.getNode(config.brightness);
|
|
||||||
|
|
||||||
this.on('input', (msg) => {
|
this.on('input', (msg) => {
|
||||||
let color = msg.color || this.color;
|
let color = msg.color || this.color;
|
||||||
let brightness = msg.brightness || this.brightness;
|
let brightness = msg.brightness || this.brightness;
|
||||||
let rgb = miDevicesUtils.computeColorValue(brightness, color.red, color.green, color.blue);
|
if(msg.sid) {
|
||||||
miDevicesUtils.sendWritePayloadToGateway(this, msg, {rgb: rgb});
|
let rgb = miDevicesUtils.computeColorValue(color.red, color.green, color.blue, brightness);
|
||||||
|
msg.payload = {
|
||||||
|
cmd: "write",
|
||||||
|
data: { rgb: rgb, sid: msg.sid }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
msg.payload = {
|
||||||
|
color: miDevicesUtils.computeColorValue(color.red, color.green, color.blue),
|
||||||
|
brightness: brightness
|
||||||
|
};
|
||||||
|
}
|
||||||
|
this.send(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("xiaomi-actions gateway_light", XiaomiActionGatewayLight);
|
RED.nodes.registerType("xiaomi-actions gateway_light", XiaomiActionGatewayLight);
|
||||||
@@ -77,15 +95,19 @@ module.exports = (RED) => {
|
|||||||
*********************************************/
|
*********************************************/
|
||||||
function XiaomiActionGatewaySound(config) {
|
function XiaomiActionGatewaySound(config) {
|
||||||
RED.nodes.createNode(this, config);
|
RED.nodes.createNode(this, config);
|
||||||
this.gateway = RED.nodes.getNode(config.gateway);
|
|
||||||
this.mid = config.mid;
|
this.mid = config.mid;
|
||||||
this.volume = config.volume;
|
this.volume = config.volume;
|
||||||
|
|
||||||
this.on('input', (msg) => {
|
this.on('input', (msg) => {
|
||||||
miDevicesUtils.sendWritePayloadToGateway(this, msg, {
|
msg.payload = {
|
||||||
|
cmd: "write",
|
||||||
|
data: {
|
||||||
mid: parseInt(msg.mid || this.mid),
|
mid: parseInt(msg.mid || this.mid),
|
||||||
volume: parseInt(msg.volume || this.volume)
|
volume: parseInt(msg.volume || this.volume),
|
||||||
});
|
sid: msg.sid
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.send(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("xiaomi-actions gateway_sound", XiaomiActionGatewaySound);
|
RED.nodes.registerType("xiaomi-actions gateway_sound", XiaomiActionGatewaySound);
|
||||||
@@ -95,10 +117,13 @@ module.exports = (RED) => {
|
|||||||
*********************************************/
|
*********************************************/
|
||||||
function XiaomiActionGatewayStopSound(config) {
|
function XiaomiActionGatewayStopSound(config) {
|
||||||
RED.nodes.createNode(this, config);
|
RED.nodes.createNode(this, config);
|
||||||
this.gateway = RED.nodes.getNode(config.gateway);
|
|
||||||
|
|
||||||
this.on('input', (msg) => {
|
this.on('input', (msg) => {
|
||||||
miDevicesUtils.sendWritePayloadToGateway(this, msg, { mid: 1000 });
|
msg.payload = {
|
||||||
|
cmd: "write",
|
||||||
|
data: { mid: 1000, sid: msg.sid }
|
||||||
|
};
|
||||||
|
this.send(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("xiaomi-actions gateway_stop_sound", XiaomiActionGatewayStopSound);
|
RED.nodes.registerType("xiaomi-actions gateway_stop_sound", XiaomiActionGatewayStopSound);
|
||||||
@@ -108,16 +133,18 @@ module.exports = (RED) => {
|
|||||||
*********************************************/
|
*********************************************/
|
||||||
function XiaomiActionPowerOn(config) {
|
function XiaomiActionPowerOn(config) {
|
||||||
RED.nodes.createNode(this, config);
|
RED.nodes.createNode(this, config);
|
||||||
this.gateway = RED.nodes.getNode(config.gateway);
|
|
||||||
|
|
||||||
this.on('input', (msg) => {
|
this.on('input', (msg) => {
|
||||||
if(msg.sid){
|
if(msg.sid){
|
||||||
miDevicesUtils.sendWritePayloadToGateway(this, msg, { status: "on", sid: msg.sid});
|
msg.payload = {
|
||||||
|
cmd: "write",
|
||||||
|
data: { status: "on", sid: msg.sid }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg.payload = "off";
|
msg.payload = "on";
|
||||||
this.send(msg);
|
|
||||||
}
|
}
|
||||||
|
this.send(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("xiaomi-actions on", XiaomiActionPowerOn);
|
RED.nodes.registerType("xiaomi-actions on", XiaomiActionPowerOn);
|
||||||
@@ -127,17 +154,32 @@ module.exports = (RED) => {
|
|||||||
*********************************************/
|
*********************************************/
|
||||||
function XiaomiActionPowerOff(config) {
|
function XiaomiActionPowerOff(config) {
|
||||||
RED.nodes.createNode(this, config);
|
RED.nodes.createNode(this, config);
|
||||||
this.gateway = RED.nodes.getNode(config.gateway);
|
|
||||||
|
|
||||||
this.on('input', (msg) => {
|
this.on('input', (msg) => {
|
||||||
if(msg.sid){
|
if(msg.sid){
|
||||||
miDevicesUtils.sendWritePayloadToGateway(this, msg, { status: "off", sid: msg.sid});
|
msg.payload = {
|
||||||
|
cmd: "write",
|
||||||
|
data: { status: "off", sid: msg.sid }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
msg.payload = "off";
|
msg.payload = "off";
|
||||||
this.send(msg);
|
|
||||||
}
|
}
|
||||||
|
this.send(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("xiaomi-actions off", XiaomiActionPowerOff);
|
RED.nodes.registerType("xiaomi-actions off", XiaomiActionPowerOff);
|
||||||
|
|
||||||
|
/*********************************************
|
||||||
|
Toggle device
|
||||||
|
*********************************************/
|
||||||
|
function XiaomiActionToggle(config) {
|
||||||
|
RED.nodes.createNode(this, config);
|
||||||
|
|
||||||
|
this.on('input', (msg) => {
|
||||||
|
msg.payload = "toggle";
|
||||||
|
this.send(msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
RED.nodes.registerType("xiaomi-actions toggle", XiaomiActionToggle);
|
||||||
}
|
}
|
||||||
@@ -12,11 +12,9 @@ module.exports = (RED) => {
|
|||||||
this.gateway = RED.nodes.getNode(config.gateway);
|
this.gateway = RED.nodes.getNode(config.gateway);
|
||||||
this.onlyModels = getOnlyModelsValue(config.onlyModels || []);
|
this.onlyModels = getOnlyModelsValue(config.onlyModels || []);
|
||||||
this.excludedSids = config.excludedSids;
|
this.excludedSids = config.excludedSids;
|
||||||
console.log(this.onlyModels);
|
|
||||||
|
|
||||||
|
|
||||||
this.isDeviceValid = (device) => {
|
this.isDeviceValid = (device) => {
|
||||||
console.log(device.sid, device.model, this.onlyModels, this.excludeSids);
|
|
||||||
if((!this.onlyModels || this.onlyModels.length == 0) && (!this.excludedSids || this.excludedSids.length == 0)) {
|
if((!this.onlyModels || this.onlyModels.length == 0) && (!this.excludedSids || this.excludedSids.length == 0)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,18 +88,21 @@ module.exports = (RED) => {
|
|||||||
}
|
}
|
||||||
msg = { payload: jsonMsg };
|
msg = { payload: jsonMsg };
|
||||||
if(this.gateway && jsonMsg.data.ip && jsonMsg.data.ip === this.gateway.ip) {
|
if(this.gateway && jsonMsg.data.ip && jsonMsg.data.ip === this.gateway.ip) {
|
||||||
RED.nodes.eachNode((tmpNode) => {
|
|
||||||
if(tmpNode.type.indexOf("xiaomi-gateway") === 0 && tmpNode.gateway == this.gatewayNodeId) {
|
|
||||||
let tmpNodeInst = RED.nodes.getNode(tmpNode.id);
|
|
||||||
tmpNodeInst.status({fill:"blue", shape:"dot", text: "online"});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if(jsonMsg.token) {
|
if(jsonMsg.token) {
|
||||||
this.gateway.lastToken = jsonMsg.token;
|
this.gateway.lastToken = jsonMsg.token;
|
||||||
if(!this.gateway.sid) {
|
if(!this.gateway.sid) {
|
||||||
this.gateway.sid = jsonMsg.sid;
|
this.gateway.sid = jsonMsg.sid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
RED.nodes.eachNode((tmpNode) => {
|
||||||
|
if(tmpNode.type.indexOf("xiaomi-gateway") === 0 && tmpNode.gateway == this.gatewayNodeId) {
|
||||||
|
let tmpNodeInst = RED.nodes.getNode(tmpNode.id);
|
||||||
|
if(tmpNode.type === "xiaomi-gateway out" && !this.gateway.lastToken) {
|
||||||
|
tmpNodeInst.status({fill:"yellow", shape:"ring", text: "waiting input"});
|
||||||
|
}
|
||||||
|
tmpNodeInst.status({fill:"blue", shape:"dot", text: "online"});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
this.send(msg);
|
this.send(msg);
|
||||||
}
|
}
|
||||||
@@ -155,6 +158,9 @@ module.exports = (RED) => {
|
|||||||
this.ipv = this.ip && this.ip.indexOf(":") >= 0 ? "udp6" : "udp4";
|
this.ipv = this.ip && this.ip.indexOf(":") >= 0 ? "udp6" : "udp4";
|
||||||
this.multicast = false;
|
this.multicast = false;
|
||||||
|
|
||||||
|
this.gatewayNodeId = n.gateway;
|
||||||
|
this.gateway = RED.nodes.getNode(n.gateway);
|
||||||
|
|
||||||
this.status({fill:"red", shape:"ring", text: "offline"});
|
this.status({fill:"red", shape:"ring", text: "offline"});
|
||||||
|
|
||||||
var opts = {type:this.ipv, reuseAddr:true};
|
var opts = {type:this.ipv, reuseAddr:true};
|
||||||
@@ -193,6 +199,9 @@ module.exports = (RED) => {
|
|||||||
} else if (isNaN(por) || (por < 1) || (por > 65535)) {
|
} else if (isNaN(por) || (por < 1) || (por > 65535)) {
|
||||||
this.warn(RED._("udp.errors.port-invalid"));
|
this.warn(RED._("udp.errors.port-invalid"));
|
||||||
} else {
|
} else {
|
||||||
|
if(msg.payload.cmd === "write" && !msg.payload.data.key && this.gateway && this.gateway.sid && this.gateway.key && this.gateway.lastToken) {
|
||||||
|
msg.payload.data.key = miDevicesUtils.getGatewayKey(this.gateway.key, this.gateway.lastToken);
|
||||||
|
}
|
||||||
var message = Buffer.from(JSON.stringify(msg.payload));
|
var message = Buffer.from(JSON.stringify(msg.payload));
|
||||||
sock.send(message, 0, message.length, por, add, (err, bytes) => {
|
sock.send(message, 0, message.length, por, add, (err, bytes) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -5,10 +5,7 @@
|
|||||||
defaults: {
|
defaults: {
|
||||||
gateway: {value:"", type:"xiaomi-configurator"},
|
gateway: {value:"", type:"xiaomi-configurator"},
|
||||||
name: {value: ""},
|
name: {value: ""},
|
||||||
sid: {value: "", required: true},
|
sid: {value: "", required: true}
|
||||||
outmsg: {value: "{{click}}"},
|
|
||||||
outmsgdbcl: {value: "{{double_click}}"},
|
|
||||||
output: {value: "0"}
|
|
||||||
},
|
},
|
||||||
inputs: 1,
|
inputs: 1,
|
||||||
outputs: 1,
|
outputs: 1,
|
||||||
|
|||||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,79 @@
|
|||||||
|
<script type="text/javascript">
|
||||||
|
RED.nodes.registerType('xiaomi-yeelight out', {
|
||||||
|
category: 'xiaomi in out',
|
||||||
|
color: '#087F8A',
|
||||||
|
defaults: {
|
||||||
|
name: {value: ""},
|
||||||
|
ip: {value: ""},
|
||||||
|
port: {value:55443, required: true}
|
||||||
|
},
|
||||||
|
inputs: 1,
|
||||||
|
outputs: 0,
|
||||||
|
paletteLabel: "yeelight out",
|
||||||
|
icon: "mi-yeelight.png",
|
||||||
|
align: "right",
|
||||||
|
label: function () {
|
||||||
|
return this.name || "yeelight out";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/x-red" data-template-name="xiaomi-yeelight out">
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
||||||
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-ip"><i class="icon-tag"></i> IP</label>
|
||||||
|
<input type="text" id="node-input-ip" placeholder="IP">
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<label for="node-input-port"><i class="icon-tag"></i> Port</label>
|
||||||
|
<input type="text" id="node-input-port" placeholder="Port">
|
||||||
|
</div>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script type="text/x-red" data-help-name="xiaomi-yeelight out">
|
||||||
|
<p>The Xiaomi Yeelight node</p>
|
||||||
|
|
||||||
|
<h3>Inputs</h3>
|
||||||
|
<dl class="message-properties">
|
||||||
|
<dt>payload
|
||||||
|
<span class="property-type">object</span>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
When the message contains a <code>sid</code> field, the node will filter the input and output only if the <code>sid</code> is the device's sid.<br>
|
||||||
|
<hr>
|
||||||
|
If the message doesn't contain a <code>sid</code> field, the node will be used to inject <code>sid</code> and <code>gateway</code> fields in the incoming <code>msg</code>.<br>
|
||||||
|
<hr>
|
||||||
|
Input Gateway node produces message of type <code>read_ack</code>, <code>heartbeat</code> or <code>report</code>.
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<h3>Outputs</h3>
|
||||||
|
<ol class="node-ports">
|
||||||
|
<dl class="message-properties">
|
||||||
|
<dt>payload <span class="property-type">object</span></dt>
|
||||||
|
<dd>Data from gateway when used as a filter (see below).</dd>
|
||||||
|
<dt>sid <span class="property-type">string</span></dt>
|
||||||
|
<dd>Device SID.</dd>
|
||||||
|
<dt>gateway <span class="property-type">object</span></dt>
|
||||||
|
<dd>The <code>xiaomi-configurator</code> object where the device is registred.</dd>
|
||||||
|
</dl>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
<h4>Details</h4>
|
||||||
|
<p>The incoming message is processed if the input <code>sid</code> matches the configured value for this device.</p>
|
||||||
|
<p>Sample message:</p>
|
||||||
|
<p><pre>{
|
||||||
|
cmd: "report"
|
||||||
|
model: "switch"
|
||||||
|
sid: "158d000128b124"
|
||||||
|
short_id: 56773
|
||||||
|
data: {
|
||||||
|
status: "click",
|
||||||
|
batteryLevel: 23
|
||||||
|
}
|
||||||
|
}</pre></p>
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
const miDevicesUtils = require('../src/utils');
|
||||||
|
const Yeelight = require("yeelight2");
|
||||||
|
|
||||||
|
module.exports = (RED) => {
|
||||||
|
function XiaomiYeelightOutputNode(config) {
|
||||||
|
RED.nodes.createNode(this, config);
|
||||||
|
this.ip = config.ip;
|
||||||
|
this.port = config.port;
|
||||||
|
|
||||||
|
this.status({fill:"grey", shape:"ring", text:"na"});
|
||||||
|
|
||||||
|
this.setupConnection = function(){
|
||||||
|
try {
|
||||||
|
this.light = Yeelight(`yeelight://${this.ip}:${this.port}`);
|
||||||
|
this.status({fill:"blue", shape:"dot", text:"connected"});
|
||||||
|
} catch(err) {
|
||||||
|
this.status({fill:"red",shape:"ring",text:err.message});
|
||||||
|
this.light = null;
|
||||||
|
this.error(err);
|
||||||
|
|
||||||
|
// try to reconnect in 5 minutes
|
||||||
|
window.setTimeout((function(self) {
|
||||||
|
return function() {
|
||||||
|
self.setupConnection.apply(self, arguments);
|
||||||
|
}
|
||||||
|
})(this), 1000*60*5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.ip && this.port) {
|
||||||
|
this.setupConnection();
|
||||||
|
this.on('input', (msg) => {
|
||||||
|
if(msg.payload === "on") {
|
||||||
|
this.light && this.light.set_power('on');
|
||||||
|
}
|
||||||
|
else if(msg.payload === "off") {
|
||||||
|
this.light && this.light.set_power('off');
|
||||||
|
}
|
||||||
|
else if(msg.payload === "toggle") {
|
||||||
|
this.light && this.light.toggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(msg.payload.color !== undefined) {
|
||||||
|
this.light && this.light.set_rgb(msg.payload.color);
|
||||||
|
}
|
||||||
|
if(msg.payload.brightness !== undefined) {
|
||||||
|
this.light && this.light.set_bright(msg.payload.brightness);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.on('close', () => {
|
||||||
|
this.light && this.light.exit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RED.nodes.registerType("xiaomi-yeelight out", XiaomiYeelightOutputNode);
|
||||||
|
};
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-contrib-mi-devices",
|
"name": "node-red-contrib-mi-devices",
|
||||||
"version": "1.0.6",
|
"version": "1.1.0",
|
||||||
"description": "A set of nodes to control some of the popular Xiaomi sensors which are connected to the Xiaomi Gateway, and the Gateway itself.",
|
"description": "A set of nodes to control some of the popular Xiaomi sensors which are connected to the Xiaomi Gateway, and the Gateway itself.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -23,7 +23,8 @@
|
|||||||
"xiaomi-all": "node-red-contrib-xiaomi-all/xiaomi-all.js",
|
"xiaomi-all": "node-red-contrib-xiaomi-all/xiaomi-all.js",
|
||||||
"xiaomi-configurator": "node-red-contrib-xiaomi-configurator/xiaomi-configurator.js",
|
"xiaomi-configurator": "node-red-contrib-xiaomi-configurator/xiaomi-configurator.js",
|
||||||
"xiaomi-gateway": "node-red-contrib-xiaomi-gateway/xiaomi-gateway.js",
|
"xiaomi-gateway": "node-red-contrib-xiaomi-gateway/xiaomi-gateway.js",
|
||||||
"xiaomi-actions": "node-red-contrib-xiaomi-actions/xiaomi-actions.js"
|
"xiaomi-actions": "node-red-contrib-xiaomi-actions/xiaomi-actions.js",
|
||||||
|
"xiaomi-yeelight": "node-red-contrib-xiaomi-yeelight/xiaomi-yeelight.js"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"author": "Pierre CLEMENT",
|
"author": "Pierre CLEMENT",
|
||||||
@@ -32,7 +33,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cryptojs": "^2.5.3",
|
"cryptojs": "^2.5.3",
|
||||||
"miio": "0.13.0"
|
"miio": "0.13.0",
|
||||||
|
"yeelight2": "^1.3.5"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4.4.5"
|
"node": ">=4.4.5"
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 122 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 14 KiB |
@@ -39,24 +39,12 @@ module.exports = {
|
|||||||
|
|
||||||
return key;
|
return key;
|
||||||
},
|
},
|
||||||
sendWritePayloadToGateway: function(node, msg, data) {
|
|
||||||
let gateway = node.gateway;
|
|
||||||
if(gateway && gateway.sid && gateway.key && gateway.lastToken) {
|
|
||||||
data.sid = data.sid || gateway.sid;
|
|
||||||
data.key = this.getGatewayKey(gateway.key, gateway.lastToken);
|
|
||||||
msg.payload = {
|
|
||||||
cmd: "write",
|
|
||||||
data: data
|
|
||||||
};
|
|
||||||
node.send(msg);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
prepareForGatewayRequest: function(node, msg) {
|
prepareForGatewayRequest: function(node, msg) {
|
||||||
msg.sid = node.sid;
|
msg.sid = node.sid;
|
||||||
msg.gateway = node.gateway;
|
msg.gateway = node.gateway;
|
||||||
},
|
},
|
||||||
computeColorValue: function (brightness, red, green, blue) {
|
computeColorValue: function (red, green, blue, brightness) {
|
||||||
return Math.round(256*256*256*brightness) + (256*256*red) + (256*green) + blue;
|
return (brightness !== undefined ? 256*256*256*brightness : 0) + (256*256*red) + (256*green) + blue;
|
||||||
},
|
},
|
||||||
computeColor: function (rgb) {
|
computeColor: function (rgb) {
|
||||||
var blue = rgb % 256;
|
var blue = rgb % 256;
|
||||||
|
|||||||