UNPKG

node-red-node-sensortag

Version:

A Node-RED node to read data from a TI SensorTag

88 lines (84 loc) 4.29 kB
<script type="text/x-red" data-template-name="sensorTag"> <div class="form-row"> <label for="node-input-uuid"><i class="fa fa-ellipsis-h"></i> UUID</label> <input type="text" id="node-input-uuid" placeholder="optional device bluetooth id"> </div> <div class="form-row"> <label for="node-input-name"><i class="fa fa-external-link"></i> Outputs</label> <input type="checkbox" id="node-input-humidity" style="display:inline-block; width:auto; vertical-align:top;"> Temperature and Humidity<br/> <label>&nbsp;</label> <input type="checkbox" id="node-input-temperature" style="display:inline-block; width:auto; vertical-align:top;"> IR Temperature<br/> <label>&nbsp;</label> <input type="checkbox" id="node-input-pressure" style="display:inline-block; width:auto; vertical-align:top;"> Pressure<br/> <label>&nbsp;</label> <input type="checkbox" id="node-input-magnetometer" style="display:inline-block; width:auto; vertical-align:top;"> Magnetometer<br/> <label>&nbsp;</label> <input type="checkbox" id="node-input-accelerometer" style="display:inline-block; width:auto; vertical-align:top;"> Accelerometer<br/> <label>&nbsp;</label> <input type="checkbox" id="node-input-gyroscope" style="display:inline-block; width:auto; vertical-align:top;"> Gyroscope<br/> <label>&nbsp;</label> <input type="checkbox" id="node-input-luxometer" style="display:inline-block; width:auto; vertical-align:top;"> Luminosity (CC2650 only)<br/> <label>&nbsp;</label> <input type="checkbox" id="node-input-keys" style="display:inline-block; width:auto; vertical-align:top;"> Button press<br/> </div> <div class="form-row"> <label for="node-input-topic"><i class="fa fa-tasks"></i> Topic</label> <input type="text" id="node-input-topic" placeholder="optional topic prefix - defaults to device id"> </div> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> </script> <script type="text/x-red" data-help-name="sensorTag"> <p>Node to read from the Ti SensorTag</p> <p>The UUID field is the bluetooth mac address of the sensor tag, this is optional and can be used to bind to a specific SensorTag if you have more than one active in range at the same time. <p>The <i>topic</i> setting is a prefix that will be pre-pended to the name of the sensor that creates the reading. e.g. <i>sensorTag/temperature</i>. If blank it will be set to the UUID of the sensor tag.</p> <p><strong>Note:</strong> Currently the node can only read from 1 sensorTag at a time, if you add more than one to the canvas then only the first to connect will work.</p> <p>Linux users should <a href="https://github.com/sandeepmistry/bleno#running-on-linux" target="_new">READ THIS</a>.</p> </script> <script type="text/javascript"> RED.nodes.registerType('sensorTag',{ category:'advanced-function', color:"GoldenRod", defaults:{ name:{value:""}, topic:{value:"sensorTag"}, uuid:{value:undefined}, temperature:{value:true}, humidity:{value:true}, pressure:{value:true}, magnetometer:{value:true}, accelerometer:{value:true}, gyroscope:{value:true}, keys:{value:true}, luxometer:{value:false} }, inputs:0, outputs:1, icon:"bluetooth.png", label:function() { return this.name||this.topic||"sensorTag"; }, labelStyle:function() { return this.name?"node_label_italic":""; }, oneditsave:function() { var mac = $("#node-input-uuid").val(); mac = mac.toLowerCase(); // nasty hack as I can't get global replace to work mac = mac.replace(/:/gi,''); mac = mac.replace(/:/gi,''); mac = mac.replace(/:/gi,''); mac = mac.replace(/:/gi,''); mac = mac.toLowerCase(); $("#node-input-uuid").val(mac); } }); </script>