stibi / node-red-contrib-ds18b20

7 stars 2 forks source link

Suggestion - pass sensor id #2

Open juggledad opened 9 years ago

juggledad commented 9 years ago

A suggestion, pass the sensor ID. You can do it very easily by editing 98-ds18b20.js and between the lines: var msg = { payload: value }; node.send(msg); add a new line so you have

                var msg = { payload: value };
                msg.sensorid = node.sensorid;
                node.send(msg);

Very simple case. Let's say you have multiple sensors and want to display the sensorid and the temperature in the debug log. Currently you would have the

ds18b20(sensor1) node->function (to add sensor1 ID to the payload)->debug

ds18b20(sensor2) node->function (to add sensor2  ID to the payload)->debug

if you pass the sensorid you could have

ds18b20(sensor1) node\
                       --->function (to add the ID to the payload)->debug
ds18b20(sensor2) node/

making the flow more compact and reusable.

kenci commented 8 years ago

+1

bestlibre commented 8 years ago

It would be nice also to send the human readable name, if it is set in the node config.

 var msg = { payload: value };
 msg.sensorid = node.sensorid;
 msg.topic = node.name;
 node.send(msg);