Added info notes
This commit is contained in:
29
README.md
Normal file
29
README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# node-red-contrib-xiaomi-devices
|
||||
|
||||
This module contains the following nodes to provide easy integration of the Xiaomi devices into node-red.
|
||||
|
||||
The following devices are currently supported:
|
||||
|
||||
* Temperature/humidity sensor
|
||||
* Magnet switch
|
||||
* Button switch
|
||||
* Motion sensor
|
||||
* Power plug (zigbee)
|
||||
|
||||
## Preperation
|
||||
To receive the gateway json messages on your network you need to enable the developer mode, aka LAN mode in the gateway.
|
||||
|
||||
A UDP input node is needed to receive the json messages. An UDP output node to send command's to the gateway.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
cd ~\.node-red
|
||||
npm install node-red-contrib-xiaomi-devices
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Below a screenshot of an example use of all nodes.
|
||||
|
||||
@@ -94,28 +94,49 @@
|
||||
<script type="text/x-red" data-help-name="xiaomi-ht">
|
||||
<p>The Xiaomi Humidity & Temperature sensor node</p>
|
||||
|
||||
<h3>Inputs</h3>
|
||||
<dl class="message-properties">
|
||||
<dt class="mandatory">Gateway</dt>
|
||||
<dd>The Gateway configuration node this sensor is attached.</dd>
|
||||
<dt class="optional">Name</dt>
|
||||
<dd>A descriptive name for this sensor.</dd>
|
||||
<dt class="mandatory">Device</dt>
|
||||
<dd>The device to associate this node with. This device is configured in the Gateway configuration.</dd>
|
||||
<dt class="mandatory">Output</dt>
|
||||
<dd>Three output types are supported:</dd>
|
||||
<dt>payload
|
||||
<span class="property-type">json</span>
|
||||
</dt>
|
||||
<dd>Gateway <code>sensor_ht</code> message of type <code>read_ack</code>, <code>heartbeat</code> or <code>report</code></dd>
|
||||
</dl>
|
||||
|
||||
<h3>Outputs</h3>
|
||||
<ol class="node-ports">
|
||||
<li>Temperature output
|
||||
<dl class="message-properties">
|
||||
<dt>payload <span class="property-type">string | json</span></dt>
|
||||
<dd>raw data, value or template.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li>Humidity output
|
||||
<dl class="message-properties">
|
||||
<dt>payload <span class="property-type">string | json</span></dt>
|
||||
<dd>raw data, value or template.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<h3>Details</h3>
|
||||
<p>The incoming json message is parsed if the type model is <code>sensor_ht</code> and
|
||||
the <code>sid</code> matches the configured value for this device.</p>
|
||||
<p>Three output types are supported:
|
||||
<ul>
|
||||
<li>Full data</li>
|
||||
<li>Just values</li>
|
||||
<li>Template</li>
|
||||
</ul>
|
||||
<dt class="mandatory">Full data</dt>
|
||||
<dd>Passes the complete object received from the gateway. Use this if you need the raw data.</dd>
|
||||
<dt class="mandatory">Just values</dt>
|
||||
<dd>Only passes the values for humidity and temperature.</dd>
|
||||
<dt class="mandatory">Template</dt>
|
||||
<dd>Use your own template to pass the values on. The template can contain <a href="http://mustache.github.io/mustache.5.html">mustache-style</a> tags.
|
||||
Any property from the data section of the full object can be used.</dd>
|
||||
</dl>
|
||||
</p>
|
||||
|
||||
<h4>Full data</h4>
|
||||
<p>Passes the complete json object received from the gateway on output 1. Use this if you need the raw data.</p>
|
||||
<h4>Just values</h4>
|
||||
<p>Only passes the string values for temperature on output 1 and humidity on output 2.</p>
|
||||
<h4>Template</h4>
|
||||
<p>Use your own template to pass the values on. The template can contain <a href="http://mustache.github.io/mustache.5.html">mustache-style</a> tags.
|
||||
Any property from the data section of the full object can be used.</p>
|
||||
|
||||
<p>Sample message:</p>
|
||||
<p><pre>
|
||||
{
|
||||
|
||||
@@ -87,28 +87,43 @@
|
||||
<script type="text/x-red" data-help-name="xiaomi-magnet">
|
||||
<p>The Xiaomi contact sensor node</p>
|
||||
|
||||
<h3>Inputs</h3>
|
||||
<dl class="message-properties">
|
||||
<dt class="mandatory">Gateway</dt>
|
||||
<dd>The Gateway configuration node this sensor is attached.</dd>
|
||||
<dt class="optional">Name</dt>
|
||||
<dd>A descriptive name for this sensor.</dd>
|
||||
<dt class="mandatory">Device</dt>
|
||||
<dd>The device to associate this node with. This device is configured in the Gateway configuration.</dd>
|
||||
<dt class="mandatory">Output</dt>
|
||||
<dd>Three output types are supported:</dd>
|
||||
<dt>payload
|
||||
<span class="property-type">json</span>
|
||||
</dt>
|
||||
<dd>Gateway <code>magnet</code> message of type <code>read_ack</code>, <code>heartbeat</code> or <code>report</code></dd>
|
||||
</dl>
|
||||
|
||||
<h3>Outputs</h3>
|
||||
<ol class="node-ports">
|
||||
<li>State output
|
||||
<dl class="message-properties">
|
||||
<dt>payload <span class="property-type">string | json</span></dt>
|
||||
<dd>raw data, value or template.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<h3>Details</h3>
|
||||
<p>The incoming json message is parsed if the type model is <code>magnet</code> and
|
||||
the <code>sid</code> matches the configured value for this device.</p>
|
||||
<p>Three output types are supported:
|
||||
<ul>
|
||||
<li>Full data</li>
|
||||
<li>Just values</li>
|
||||
<li>Template</li>
|
||||
</ul>
|
||||
<dt class="mandatory">Full data</dt>
|
||||
<dd>Passes the complete object received from the gateway. Use this if you need the raw data.</dd>
|
||||
<dt class="mandatory">Just values</dt>
|
||||
<dd>Only passes the values <code>open</code> or <code>close</code></dd>
|
||||
<dt class="mandatory">Template</dt>
|
||||
<dd>Use your own template to pass the values on. The template can contain <a href="http://mustache.github.io/mustache.5.html">mustache-style</a> tags.
|
||||
Any property from the data section of the full object can be used.</dd>
|
||||
</dl>
|
||||
</p>
|
||||
|
||||
<h4>Full data</h4>
|
||||
<p>Passes the complete json object received from the gateway. Use this if you need the raw data.</p>
|
||||
<h4>Just values</h4>
|
||||
<p>Only passes the sting values <code>open</code> or <code>close</code>.</p>
|
||||
<h4>Template</h4>
|
||||
<p>Use your own template to pass the values on. The template can contain <a href="http://mustache.github.io/mustache.5.html">mustache-style</a> tags.
|
||||
Any property from the data section of the full object can be used.</p>
|
||||
|
||||
<p>Sample message:</p>
|
||||
<p><pre>
|
||||
{
|
||||
|
||||
@@ -87,28 +87,49 @@
|
||||
<script type="text/x-red" data-help-name="xiaomi-motion">
|
||||
<p>The Xiaomi body motion sensor node</p>
|
||||
|
||||
<h3>Inputs</h3>
|
||||
<dl class="message-properties">
|
||||
<dt class="mandatory">Gateway</dt>
|
||||
<dd>The Gateway configuration node this sensor is attached.</dd>
|
||||
<dt class="optional">Name</dt>
|
||||
<dd>A descriptive name for this sensor.</dd>
|
||||
<dt class="mandatory">Device</dt>
|
||||
<dd>The device to associate this node with. This device is configured in the Gateway configuration.</dd>
|
||||
<dt class="mandatory">Output</dt>
|
||||
<dd>Three output types are supported:</dd>
|
||||
<dt>payload
|
||||
<span class="property-type">json</span>
|
||||
</dt>
|
||||
<dd>Gateway <code>motion</code> message of type <code>read_ack</code>, <code>heartbeat</code> or <code>report</code></dd>
|
||||
</dl>
|
||||
|
||||
<h3>Outputs</h3>
|
||||
<ol class="node-ports">
|
||||
<li>Motion output
|
||||
<dl class="message-properties">
|
||||
<dt>payload <span class="property-type">string | json</span></dt>
|
||||
<dd>raw data, value or template.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li>Duration output
|
||||
<dl class="message-properties">
|
||||
<dt>payload <span class="property-type">json</span></dt>
|
||||
<dd>raw data</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<h3>Details</h3>
|
||||
<p>The incoming json message is parsed if the type model is <code>motion</code> and
|
||||
the <code>sid</code> matches the configured value for this device.</p>
|
||||
<p>Three output types are supported for output 1:
|
||||
<ul>
|
||||
<li>Full data</li>
|
||||
<li>Just values</li>
|
||||
<li>Template</li>
|
||||
</ul>
|
||||
<dt class="mandatory">Full data</dt>
|
||||
<dd>Passes the complete object received from the gateway. Use this if you need the raw data.</dd>
|
||||
<dt class="mandatory">Just values</dt>
|
||||
<dd>Only passes the values <code>motion</code> or <code>no_motion</code>. In case of <code>no_motion</code> also the duration is passed on the second output.</dd>
|
||||
<dt class="mandatory">Template</dt>
|
||||
<dd>Use your own template to pass the values on. The template can contain <a href="http://mustache.github.io/mustache.5.html">mustache-style</a> tags.
|
||||
Any property from the data section of the full object can be used.</dd>
|
||||
</dl>
|
||||
</p>
|
||||
|
||||
<h4>Full data</h4>
|
||||
<p>Passes the complete json object received from the gateway. Use this if you need the raw data.</p>
|
||||
<h4>Just values</h4>
|
||||
<p>Only passes the values <code>motion</code> or <code>no_motion</code>. In case of <code>no_motion</code> also the duration object is passed on output 2.</p>
|
||||
<h4>Template</h4>
|
||||
<p>Use your own template to pass the values on. The template can contain <a href="http://mustache.github.io/mustache.5.html">mustache-style</a> tags.
|
||||
Any property from the data section of the full object can be used.</p>
|
||||
|
||||
<p>Sample message:</p>
|
||||
<p><pre>
|
||||
{
|
||||
|
||||
@@ -85,34 +85,58 @@
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="xiaomi-plug">
|
||||
<p>The Xiaomi plug (zigbee) sensor node</p>
|
||||
<p>The Xiaomi plug (zigbee) node</p>
|
||||
|
||||
<p>This is the plug (socket) version which is attached to a Xiaomi gateway. The Wifi version is not yet supported.</p>
|
||||
<p>To switch an output you need to specify the key of the gateway in the gateway configuration; without the key
|
||||
no output can be switched. To retrieve the gateway key consult the Xiaomi Mi Home App.</p>
|
||||
<p>On the input you can send <code>on</code> to switch the plug on. To turn it off just send <code>off</code></p>
|
||||
<p>Output 1 reports the status, output 2 is the write command for the plug.</p>
|
||||
no output can be switched. To retrieve the gateway key consult the Xiaomi Mi Home App.</p>
|
||||
|
||||
<h3>Inputs</h3>
|
||||
<dl class="message-properties">
|
||||
<dt class="mandatory">Gateway</dt>
|
||||
<dd>The Gateway configuration node this sensor is attached.</dd>
|
||||
<dt class="optional">Name</dt>
|
||||
<dd>A descriptive name for this sensor.</dd>
|
||||
<dt class="mandatory">Device</dt>
|
||||
<dd>The device to associate this node with. This device is configured in the Gateway configuration.</dd>
|
||||
<dt class="mandatory">Output</dt>
|
||||
<dd>Three output types are supported:</dd>
|
||||
<dt>payload
|
||||
<span class="property-type">string | json</span>
|
||||
</dt>
|
||||
<dd>Gateway <code>plug</code> message of type <code>read_ack</code>, <code>heartbeat</code> or <code>report</code>. Or <code>on</code> or <code>off</code>.</dd>
|
||||
</dl>
|
||||
|
||||
<h3>Outputs</h3>
|
||||
<ol class="node-ports">
|
||||
<li>Status output
|
||||
<dl class="message-properties">
|
||||
<dt>payload <span class="property-type">string | json</span></dt>
|
||||
<dd>raw data, value or template.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li>Control output
|
||||
<dl class="message-properties">
|
||||
<dt>payload <span class="property-type">json</span></dt>
|
||||
<dd>Gateway <code>write_cmd</code> to switch the output on or off.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<h3>Details</h3>
|
||||
<p>The incoming json message is parsed if the type model is <code>plug</code> and
|
||||
the <code>sid</code> matches the configured value for this device.</p>
|
||||
<p>On the input you can send the string <code>on</code> to switch the plug on. To turn it off just send the string <code>off</code></p>
|
||||
<p>Output 1 reports the status, output 2 is the write command for the plug.</p>
|
||||
|
||||
<p>Three output types are supported:
|
||||
<ul>
|
||||
<li>Full data</li>
|
||||
<li>Just values</li>
|
||||
<li>Template</li>
|
||||
</ul>
|
||||
<dt class="mandatory">Full data</dt>
|
||||
<dd>Passes the complete object received from the gateway. Use this if you need the raw data.</dd>
|
||||
<dt class="mandatory">Just values</dt>
|
||||
<dd>Only passes the values <code>on</code> or <code>off</code>.</dd>
|
||||
<dt class="mandatory">Template</dt>
|
||||
<dd>Use your own template to pass the values on. The template can contain <a href="http://mustache.github.io/mustache.5.html">mustache-style</a> tags.
|
||||
Any property from the data section of the full object can be used.</dd>
|
||||
</dl>
|
||||
</p>
|
||||
|
||||
<h4>Full data</h4>
|
||||
<p>Passes the complete json object received from the gateway on output 1. Use this if you need the raw data.</p>
|
||||
<h4>Just values</h4>
|
||||
<p>Only passes the values <code>on</code> or <code>off</code> on output 1.</p>
|
||||
<h4>Template</h4>
|
||||
<p>Use your own template to pass the values on. The template can contain <a href="http://mustache.github.io/mustache.5.html">mustache-style</a> tags.
|
||||
Any property from the data section of the full object can be used.</p>
|
||||
|
||||
<p>Sample message:</p>
|
||||
<p><pre>
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@ module.exports = function(RED) {
|
||||
|
||||
node.status({fill:"yellow", shape:"ring", text:"waiting for key"});
|
||||
|
||||
if (this.gateway) {
|
||||
if (this.gateway && this.key != "") {
|
||||
node.on('input', function(msg) {
|
||||
// var payload = JSON.parse(msg);
|
||||
var payload = msg.payload;
|
||||
@@ -98,6 +98,9 @@ module.exports = function(RED) {
|
||||
|
||||
} else {
|
||||
// no gateway configured
|
||||
if (this.key == "") {
|
||||
node.status({fill:"red", shape:"dot", text:"no key configured"});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -87,7 +87,62 @@
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="xiaomi-ht">
|
||||
<p>A simple node that converts the message payloads from a switch into an output message</p>
|
||||
<script type="text/x-red" data-help-name="xiaomi-switch">
|
||||
<p>The Xiaomi Switch node</p>
|
||||
|
||||
<h3>Inputs</h3>
|
||||
<dl class="message-properties">
|
||||
<dt>payload
|
||||
<span class="property-type">json</span>
|
||||
</dt>
|
||||
<dd>Gateway <code>switch</code> message of type <code>read_ack</code>, <code>heartbeat</code> or <code>report</code></dd>
|
||||
</dl>
|
||||
|
||||
<h3>Outputs</h3>
|
||||
<ol class="node-ports">
|
||||
<li>Single click output
|
||||
<dl class="message-properties">
|
||||
<dt>payload <span class="property-type">string | json</span></dt>
|
||||
<dd>raw data, value or template.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li>Double click output
|
||||
<dl class="message-properties">
|
||||
<dt>payload <span class="property-type">string | json</span></dt>
|
||||
<dd>raw data, value or template.</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<h3>Details</h3>
|
||||
<p>The incoming json message is parsed if the type model is <code>switch</code> and
|
||||
the <code>sid</code> matches the configured value for this device.</p>
|
||||
<p>Three output types are supported:
|
||||
<ul>
|
||||
<li>Full data</li>
|
||||
<li>Just values</li>
|
||||
<li>Template</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h4>Full data</h4>
|
||||
<p>Passes the complete json object received from the gateway on output 1. Use this if you need the raw data.</p>
|
||||
<h4>Just values</h4>
|
||||
<p>Only passes the string values <code>single_click</code> on output 1 and <code>double_click</code> on output 2.</p>
|
||||
<h4>Template</h4>
|
||||
<p>Use your own template to pass the values on. The template can contain <a href="http://mustache.github.io/mustache.5.html">mustache-style</a> tags.
|
||||
Any property from the data section of the full object can be used.</p>
|
||||
|
||||
<p>Sample message:</p>
|
||||
<p><pre>
|
||||
{
|
||||
cmd: "report"
|
||||
model: "switch"
|
||||
sid: "158d000128b124"
|
||||
short_id: 56773
|
||||
data: "{
|
||||
"status":"click"
|
||||
}"
|
||||
}</pre></p>
|
||||
|
||||
</script>
|
||||
|
||||
14
package.json
14
package.json
@@ -1,22 +1,16 @@
|
||||
{
|
||||
"name": "node-red",
|
||||
"name": "node-red-contrib-xiaomi-devices",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"description": "A set of nodes to control some of the popular Xiaomi sensors which are connected to the Xiaomi Gateway.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/h-rietman/xiaomi-devices-node-red.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Harald Rietman <harald.rietman@portofrotterdam.com> (http://blog.example.com)",
|
||||
"license": "ISC",
|
||||
"keywords": [Xiaomi],
|
||||
"author": "Harald Rietman <h.rietman@gmail.com>",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/h-rietman/xiaomi-devices-node-red/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/h-rietman/xiaomi-devices-node-red#README",
|
||||
"dependencies": {
|
||||
"cryptojs": "^2.5.3",
|
||||
"mustache": "^2.3.0"
|
||||
|
||||
BIN
xiaomi-devices-overview.png
Normal file
BIN
xiaomi-devices-overview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 184 KiB |
Reference in New Issue
Block a user