forked from Harsch-Systems/node-red-contrib-pi-plates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
temp.js
23 lines (22 loc) · 789 Bytes
/
temp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module.exports = function (RED) {
function TEMPNode(config) {
RED.nodes.createNode(this, config);
var node = this;
node.plate = RED.nodes.getNode(config.config_plate).plate;
node.input = parseInt(config.input, 10);
node.scale = config.scale;
node.temp = 0;
node.on('input', function (msg) {
const obj = {cmd: "getTEMP", args: {bit: node.input, scale: node.scale}};
node.plate.send(obj, (reply) => {
node.temp = reply.temp;
node.status({text: node.temp});
node.send({payload: node.temp});
});
});
this.on('close', function () {
// cleanup goes here
});
}
RED.nodes.registerType("ppTEMP", TEMPNode);
}