UNPKG

node-red-contrib-xiaomi-devices

Version:

A set of nodes to control some of the popular Xiaomi sensors which are connected to the Xiaomi Gateway.

120 lines (107 loc) 4.16 kB
<script type="text/javascript"> RED.nodes.registerType('xiaomi-plug-wifi', { category: 'xiaomi', color: '#3FADB5', defaults: { name: {value: ""}, ip: {value: "", required: true}, onmsg: {value: ""}, offmsg: {value: ""}, output: {value: "0"} }, inputs: 1, outputs: 1, outputLabels: ["Status"], paletteLabel: "plug (wifi)", icon: "outlet-wifi-icon.png", label: function () { return this.name || "xiaomi-plug-wifi"; }, oneditprepare: function() { var node = this; $("#node-input-output").change(function () { if ($(this).val() == "2") { $(".node-input-msg").show(); } else { $(".node-input-msg").hide(); } }); }, oneditsave: function() { } }); </script> <script type="text/x-red" data-template-name="xiaomi-plug-wifi"> <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 address"> </div> <div class="form-row"> <label for="node-input-output"><i class="icon-tag"></i> Output</label> <select id="node-input-output" style="width:70%;"> <option value="0">Full data</option> <option value="1">Just values</option> <option value="2">Template</option> </select> </div> <div class="form-row node-input-msg"> <label for="node-input-onmsg"><i class="fa fa-power-off"></i> On msg</label> <input type="text" id="node-input-onmsg"> </div> <div class="form-row node-input-msg"> <label for="node-input-offmsg"><i class="fa fa-power-off"></i> Off msg</label> <input type="text" id="node-input-offmsg"> </div> </script> <script type="text/x-red" data-help-name="xiaomi-plug-wifi"> <p>The Xiaomi plug (wifi) node</p> <p>This is the wiFi plug (socket). To control the Wifi-Plug, extensive use is made of the miio library created by <a href="https://github.com/aholstenson/miio">Andreas Holstenson</a>. Make sure to check his page for compatible devices.</p> <h3>Inputs</h3> <dl class="message-properties"> <dt>payload <span class="property-type">string</span> </dt> <dd><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> </ol> <h3>Details</h3> <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</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 a json object with detailed information about the plug. 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></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 full data:</p> <p><pre> { "type": "power-plug", "model": "chuangmi.plug.m1", "capabilities: [ {'0': "power-channels"} ], "address": "192.168.178.31", "port": 54321, "power": { '0': false } }" }</pre></p> </script>