mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Merge pull request #9 from hardillb/master
Added support for specifying a specific sensortag by mac address
This commit is contained in:
commit
4f45d768a5
@ -33,9 +33,13 @@
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Topic</label>
|
||||
<label for="node-input-topic"><i class="icon-tag"></i> Topic</label>
|
||||
<input type="text" id="node-input-topic" >
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-uuid"><i class="icon-tag"></i> UUID</label>
|
||||
<input type="text" id="node-input-uuid" >
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="icon-tag"></i> Temperature</label>
|
||||
<input type="checkbox" id="node-input-temperature" placeholder="">
|
||||
@ -85,6 +89,7 @@
|
||||
defaults: { // defines the editable properties of the node
|
||||
name: {value:"sensorTag"}, // along with default values.
|
||||
topic: {value:"sensorTag"},
|
||||
uuid: {value:undefined},
|
||||
temperature: {value:true},
|
||||
humidity: {value:true},
|
||||
pressure: {value:true},
|
||||
@ -101,6 +106,16 @@
|
||||
},
|
||||
labelStyle: function() { // sets the class to apply to the label
|
||||
return this.name?"node_label_italic":"";
|
||||
},
|
||||
oneditsave: function() {
|
||||
var mac = $("#node-input-uuid").val();
|
||||
//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>
|
||||
|
@ -25,6 +25,7 @@ function sensorTagNode(n) {
|
||||
RED.nodes.createNode(this,n);
|
||||
this.name = n.name;
|
||||
this.topic = n.topic;
|
||||
this.uuid = n.uuid;
|
||||
this.temperature = n.temperature;
|
||||
this.pressure = n.pressure;
|
||||
this.humidity = n.humidity;
|
||||
@ -32,6 +33,12 @@ function sensorTagNode(n) {
|
||||
this.magnetometer = n.magnetometer;
|
||||
this.gyroscope = n.gyroscope;
|
||||
this.keys = n.keys;
|
||||
|
||||
if (this.uuid === "") {
|
||||
this.uuid = undefined;
|
||||
}
|
||||
console.log(this.uuid);
|
||||
|
||||
node=this;
|
||||
|
||||
if ( typeof stag == "undefined") {
|
||||
@ -90,7 +97,7 @@ function sensorTagNode(n) {
|
||||
enable();
|
||||
});
|
||||
});
|
||||
});
|
||||
},node.uuid);
|
||||
} else {
|
||||
//console.log("reconfig");
|
||||
enable();
|
||||
|
@ -1,5 +1,5 @@
|
||||
This currently requires a slightly modified sensortag library
|
||||
This currently requires the sensortag library
|
||||
|
||||
To install use the following command in the Node-Red directory
|
||||
|
||||
npm install sensortag@https://api.github.com/repos/hardillb/node-sensortag/tarball
|
||||
npm install sensortag
|
||||
|
Loading…
Reference in New Issue
Block a user