node-red-nodes/hardware/sensorTag/79-sensorTag.html

104 lines
4.8 KiB
HTML

<!--
Copyright 2014.2016 IBM Corp.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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. <b>Note</b>:you can only have one SensorTag
per Node-RED instance at the moment.</p>
<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> Only 1 sensorTag can be read from 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:"sensorTag"},
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>