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">
|
<input type="text" id="node-input-name" placeholder="Name">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<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" >
|
<input type="text" id="node-input-topic" >
|
||||||
</div>
|
</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">
|
<div class="form-row">
|
||||||
<label for="node-input-name"><i class="icon-tag"></i> Temperature</label>
|
<label for="node-input-name"><i class="icon-tag"></i> Temperature</label>
|
||||||
<input type="checkbox" id="node-input-temperature" placeholder="">
|
<input type="checkbox" id="node-input-temperature" placeholder="">
|
||||||
@ -85,6 +89,7 @@
|
|||||||
defaults: { // defines the editable properties of the node
|
defaults: { // defines the editable properties of the node
|
||||||
name: {value:"sensorTag"}, // along with default values.
|
name: {value:"sensorTag"}, // along with default values.
|
||||||
topic: {value:"sensorTag"},
|
topic: {value:"sensorTag"},
|
||||||
|
uuid: {value:undefined},
|
||||||
temperature: {value:true},
|
temperature: {value:true},
|
||||||
humidity: {value:true},
|
humidity: {value:true},
|
||||||
pressure: {value:true},
|
pressure: {value:true},
|
||||||
@ -101,6 +106,16 @@
|
|||||||
},
|
},
|
||||||
labelStyle: function() { // sets the class to apply to the label
|
labelStyle: function() { // sets the class to apply to the label
|
||||||
return this.name?"node_label_italic":"";
|
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>
|
</script>
|
||||||
|
@ -25,6 +25,7 @@ function sensorTagNode(n) {
|
|||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
this.name = n.name;
|
this.name = n.name;
|
||||||
this.topic = n.topic;
|
this.topic = n.topic;
|
||||||
|
this.uuid = n.uuid;
|
||||||
this.temperature = n.temperature;
|
this.temperature = n.temperature;
|
||||||
this.pressure = n.pressure;
|
this.pressure = n.pressure;
|
||||||
this.humidity = n.humidity;
|
this.humidity = n.humidity;
|
||||||
@ -32,6 +33,12 @@ function sensorTagNode(n) {
|
|||||||
this.magnetometer = n.magnetometer;
|
this.magnetometer = n.magnetometer;
|
||||||
this.gyroscope = n.gyroscope;
|
this.gyroscope = n.gyroscope;
|
||||||
this.keys = n.keys;
|
this.keys = n.keys;
|
||||||
|
|
||||||
|
if (this.uuid === "") {
|
||||||
|
this.uuid = undefined;
|
||||||
|
}
|
||||||
|
console.log(this.uuid);
|
||||||
|
|
||||||
node=this;
|
node=this;
|
||||||
|
|
||||||
if ( typeof stag == "undefined") {
|
if ( typeof stag == "undefined") {
|
||||||
@ -90,7 +97,7 @@ function sensorTagNode(n) {
|
|||||||
enable();
|
enable();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
},node.uuid);
|
||||||
} else {
|
} else {
|
||||||
//console.log("reconfig");
|
//console.log("reconfig");
|
||||||
enable();
|
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
|
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…
x
Reference in New Issue
Block a user