node-red-contrib-xiaomi-smart-devices
Version:
Xiaomi Home Automation for NodeRed
66 lines (60 loc) • 1.88 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('xiaomi-switch', {
category: 'xiaomi',
color: 'rgb(192, 222, 237)',
defaults: {
gateway: {value: "", type: "xiaomi-gateway-config"},
name: {value: ""},
key: {value: "", required: true},
sid: {value: "", required: true}
},
inputs: 0,
outputs: 1,
paletteLabel: "switch",
icon: "switch.png",
label: function () {
return this.name || "Xiaomi Switch";
}
});
</script>
<script type="text/x-red" data-template-name="xiaomi-switch">
<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">
<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-sid"><i class="icon-tag"></i> SID</label>
<input type="text" id="node-input-sid" placeholder="SID"></input>
</div>
<div class="form-row">
<label for="node-input-key"><i class="icon-tag"></i> Device</label>
<input type="text" id="node-input-key" placeholder="Device Key/Name"></text>
</div>
</script>
<script type="text/x-red" data-help-name="xiaomi-switch">
<p>The Xiaomi Button node</p>
<h3>Details</h3>
<p>The incoming json message is parsed if the <code>sid</code> matches the configured value for this device.</p>
<h3>Outputs</h3>
<p>Sample message `Click`:</p>
<p>
<pre>
{
"fromip":"192.168.0.110:4321",
"ip":"192.168.0.110",
"port":4321,
"payload":{
"status":"click",
"time":1556989371213,
"device":"btn_room_1",
"sid":"158d00016c47ba",
"model":"sensor_switch.aq2"
}
}
</pre>
</p>
</script>