node-red-contrib-xiaomi-smart-devices
Version:
Xiaomi Home Automation for NodeRed
87 lines (80 loc) • 2.38 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('xiaomi-human-body-sensor', {
category: 'xiaomi',
color: 'rgb(192, 222, 237)',
defaults: {
gateway: {value: '', type: 'xiaomi-gateway-config'},
name: {value: ''},
sid: {value: '', required: true},
key: {value: "", required: true}
},
inputs: 0,
outputs: 1,
paletteLabel: 'motion',
icon: 'human-body-sensor.png',
label: function () {
return this.name || 'Xiaomi Human Body Sensor';
}
});
</script>
<script type="text/x-red" data-template-name="xiaomi-human-body-sensor">
<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-human-body-sensor">
<p>The Xiaomi Human Body Sensor node</p>
<h3>Details</h3>
<p>The incoming json message is parsed if the type model is <code>human-body-sensor</code> and the <code>sid</code> matches the configured value for this device.</p>
<h3>Outputs</h3>
<p>Sample message if there is some motion:</p>
<p>
<pre>
{
"fromip":"192.168.0.110:4321",
"ip":"192.168.0.110",
"port":4321,
"payload":{
"status":"motion",
"lux":2,
"time":1556988708585,
"device":"motion_room_1",
"sid":"158d0001a24d0a",
"model":"sensor_motion.aq2"
}
}
</pre>
</p>
<p>Sample message if no motion:</p>
<p>
<pre>
{
"fromip":"192.168.0.110:4321",
"ip":"192.168.0.110",
"port":4321,
"payload":{
"status":"no_motion",
"duration":"120",
"lux":2,
"time":1556988839656,
"device":"motion_room_1",
"sid":"158d0001a24d0a",
"model":"sensor_motion.aq2"
}
}
</pre>
</p>
</script>