node-red-contrib-xiaomi-miio
Version:
miIO device library for node red
52 lines (48 loc) • 1.84 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('miio-switch', {
category: 'Xiaomi miIO',
color: '#a6bbcf',
defaults: {
name: {value:""},
deviceId: {value:""},
devices: {value:[{t:""}]}
},
inputs:0,
outputs:4,
icon: "debug.png",
label: function() {
return this.name||"miio-switch";
},
paletteLabel: "switch",
outputLabels: ['On All Events', 'On Click', 'On DbClick', 'On Long Click'],
oneditprepare: function() {
var node = this;
for (key in RED.settings.miioSwitchDevices) {
var device = RED.settings.miioSwitchDevices[key];
if (device.model.indexOf('switch') !== -1) {
$('#node-input-deviceId').append('<option value="' + device.id + '">' + device.id + ' ' + device.model + '</option>');
}
}
$('#node-input-deviceId').val(node.deviceId);
},
oneditsave: function() {
var node = this;
node.deviceId = $('#node-input-deviceId').val();
}
});
</script>
<script type="text/x-red" data-template-name="miio-switch">
<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-deviceId"><i class="icon-tag"></i> Device</label>
<select type="text" id="node-input-deviceId" placeholder="ex: 158d0001a2ca33"></select>
</div>
</script>
<script type="text/x-red" data-help-name="miio-switch">
<p>Xiaomi Switch/Button.</p>
Input device, captures switch events.
Use debug node to see the output.
</script>