Hello,
for you perhaps something stupids, but for me a problem
Ho do i get decimal data from (wx)sensors
TEMP;'00f6' ; HUM;'62';
Dick
msg.payload.TEMP = parseInt(msg.payload.TEMP,16);
msg.payload.HUM = parseInt(msg.payload.HUM,16)
return msg;
in a function node
https://www.w3schools.com/jsref/jsref_parseint.asp
Assuming that ↑ is a single string,
In a function node,
- remove all spaces and apostrophes
- that makes the string
TEMP;00f6;HUM;62;
- that makes the string
- then use split function with
;
as a delimiter break the string into 4 parts.- now value is
['TEMP','00f6','HUM','62',]
- now value is
- Then loop through that array (stepping 2 places) and assign the name and the value to an object (using
parseInt(value, 16)
to make the hexadecimal into decimal)
e.g...
demo flow...
[{"id":"664e5b6b546a7850","type":"inject","z":"9af9141769558c7a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"TEMP;'00f6' ; HUM;'62';","payloadType":"str","x":2480,"y":220,"wires":[["e7128a7b36bb9235"]]},{"id":"e7128a7b36bb9235","type":"function","z":"9af9141769558c7a","name":"","func":"var str = msg.payload;\nstr = str.replace(/[ ']/g, ''); //remove spaces and single quotes\nvar parts = str.split(\";\");\nvar result = {};\n\nfor (let index = 0; index < parts.length; index = index+2) {\n const name = parts[index];\n const val = parts[index + 1];\n if (name && val) {\n result[name] = parseInt(val, 16);\n }\n}\nmsg.payload = result\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2530,"y":280,"wires":[["46d739b7dfe9d2a7"]]},{"id":"46d739b7dfe9d2a7","type":"debug","z":"9af9141769558c7a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":2570,"y":340,"wires":[]}]
the whole datarange is
20;0A;Cresta;ID=2C01;TEMP=00e8;HUM=63;BAT=OK;
with change is it reformed to:
20;05;Cresta;ID;2C01;TEMP;00f2;HUM;65;BAT;OK;
with function data split i got the information needed
temp: "00f3" hum: "65"
and then ?? Ho do i get decimal data from (wx)sensors
it is no working.
Dick
Try this you can add the values you want in the wanted array so you could add ID.
[{"id":"e9366ca3.d23888","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20;0A;Cresta;ID=2C01;TEMP=00e8;HUM=63;BAT=OK;","payloadType":"str","x":260,"y":4440,"wires":[["8b74d6ff.7a673"]]},{"id":"8b74d6ff.7a673","type":"function","z":"c74669a0.6a34f8","name":"","func":"const split_array = msg.payload.split(\";\");\nconst wanted = [\"TEMP\",\"HUM\"]\nmsg.payload={};\nfor(let i in split_array){\n let parts =split_array[i].split(\"=\");\n if(wanted.includes(parts[0]))\n msg.payload[parts[0]]=parseInt(parts[1], 16);\n}\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":420,"y":4440,"wires":[["183c25e0.2effaa"]]},{"id":"183c25e0.2effaa","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":4440,"wires":[]}]
const split_array = msg.payload.split(";");
const wanted = ["TEMP","HUM"]
msg.payload={};
for(let i in split_array){
let parts =split_array[i].split("=");
if(wanted.includes(parts[0]))
msg.payload[parts[0]]=parseInt(parts[1], 16);
}
return msg;
If payload string is always in the same order and always contains the same info you could do
msg.payload = msg.payload.split(/=|;/);
msg.payload = {
[msg.payload[5]]: parseInt(msg.payload[6],16),
[msg.payload[7]]: parseInt(msg.payload[8],16)
}
return msg;
thanks E1cid
that input gives needed data ,but the input for temp is '00e8' hex--> dec 246
that '00e8' is to high (perhaps even hum to high 99 !)
I can divide by 10, Is that the right solution for temp, but not for hum.?
Perhaps i made a mistake or is something else possible.
Dick
So what real values do those hex values represent?
As Colin said would need the real values.
Can not say for sure but it looks like the temp is hex and needs to be divided by 10, and the humidity is probably a decimal value already.
try
const split_array = msg.payload.split(";");
msg.payload={};
for(let i in split_array){
let parts =split_array[i].split("=");
if(parts.length === 2){
if(parts[0]==="HUM") msg.payload[parts[0]]=parseInt(parts[1]);
else if(parts[0] === "TEMP") msg.payload[parts[0]] = parseInt(parts[1], 16)/10;
else if(parts[0]==="ID") msg.payload [parts[0]] = parseInt(parts[1], 16);
else msg.payload[parts[0]] = parts[1];
}
}
/* or
msg.payload = msg.payload.split(/=|;/);
msg.payload = {
[msg.payload[5]]: parseInt(msg.payload[6],16)/10,
[msg.payload[7]]: parseInt(msg.payload[8])
}
*/
return msg;
Thanks GUYS
for this GOOD help.
Now i can go on with the other possibilities in Node-Red
e.g gauge and so on.
Dick
@dick
It may be a little late but may be useful.
I have the impression to recognize the data coming out of the Rflink?
Then I remembered that I use a flow to manage several probes or other radio frequencies at 433 Mhz.
So here is an extract of my flow which deals with a ThermPro probe.
You can remove the node concerning influxdb.
Oh yes, you must also have installed the node-red-contrib-convert.
/JL
[{"id":"6f4cb128.939ec8","type":"serial in","z":"a9e1c168.34a4a","name":"RFlink","serial":"25737c2e.cc1f2c","x":90,"y":120,"wires":[["5a2cbe93.deba8","bb86b8ee.825a08"]]},{"id":"5a2cbe93.deba8","type":"switch","z":"a9e1c168.34a4a","name":"Sonde OWL_CM180 ou ThermPro ?","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"OWL_CM180","vt":"str"},{"t":"cont","v":"Prologue","vt":"str"},{"t":"cont","v":"Pollin","vt":"str"},{"t":"cont","v":"Digitech","vt":"str"},{"t":"else"}],"checkall":"true","repair":true,"outputs":5,"x":370,"y":120,"wires":[["ab1f1a01.78957","884c8e43.8de71","4cc5e484.e6a7cc"],["af46a898.a464c","b7f6c495.0f8a98","24def373.15ef84"],["b166d934.c892f"],["551cce52.c9a3a"],["e6dd9539.5fcda"]],"outputLabels":["Sonde ampermétrique OWL180","Sonde Humidité+Temp Therm Pro","Sonde Pollin PFR-130 Pluie","Digitech Weather Station","Inconnu"]},{"id":"b7f6c495.0f8a98","type":"function","z":"a9e1c168.34a4a","name":"add timestamp","func":"msg.payload = new Date().toString() + \" - \" + msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":700,"y":80,"wires":[["1990c5ed.67c982"]]},{"id":"1990c5ed.67c982","type":"file","z":"a9e1c168.34a4a","name":"Log du Thermpro","filename":"/home/pi/Documents/ThermPro-Log_temp.dump","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"utf8","x":910,"y":80,"wires":[[]]},{"id":"38e5744e.fc6ccc","type":"comment","z":"a9e1c168.34a4a","name":"Les Sondes ThermPro de température & humidité","info":"**ThermPro **","x":240,"y":540,"wires":[]},{"id":"1268ba70.600b06","type":"comment","z":"a9e1c168.34a4a","name":"Sonde Vide Sanitaire","info":"","x":620,"y":580,"wires":[]},{"id":"af46a898.a464c","type":"string","z":"a9e1c168.34a4a","name":"SondeID","methods":[{"name":"between","params":[{"type":"str","value":";ID="},{"type":"str","value":";TEMP="}]}],"prop":"payload","propout":"sondeID","object":"msg","objectout":"msg","x":120,"y":640,"wires":[["35fc3439.6d4d2c"]]},{"id":"35fc3439.6d4d2c","type":"switch","z":"a9e1c168.34a4a","name":"quelle sonde","property":"sondeID","propertyType":"msg","rules":[{"t":"eq","v":"9171","vt":"str"},{"t":"eq","v":"9100","vt":"str"},{"t":"eq","v":"9142","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":270,"y":640,"wires":[["a906a7b4.e860b8","27d828bb.626bc"],["44c34056.d92ce","d6272baf.3c069","9eddd65a.5cc38"],["d0abd187.406e5","9f7203aa.e9563"]],"outputLabels":["Sonde extérieur - (9171)","Sonde vide sanitaire - (9100)","Sonde armoire PhotoVoltaique - (9142)"]},{"id":"44c34056.d92ce","type":"string","z":"a9e1c168.34a4a","name":"Température","methods":[{"name":"between","params":[{"type":"str","value":"TEMP="},{"type":"str","value":";HUM="}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":470,"y":640,"wires":[["b1976976.ac7098"]]},{"id":"b1976976.ac7098","type":"switch","z":"a9e1c168.34a4a","name":"Id not Null","property":"payload","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":620,"y":640,"wires":[["7f7894a3.3e3f04"]]},{"id":"7f7894a3.3e3f04","type":"function","z":"a9e1c168.34a4a","name":"Hex2Dec","func":"global.set('hex2dec', function(hexa) {\n return parseInt(hexa, 16);\n}, 'memoryOnly');\nvar msg2convert = msg.payload;\nmsg.payload = global.get('hex2dec', 'memoryOnly')(msg2convert)\n//msg.payload = {\n// dec: global.get('hex2dec', 'memoryOnly')(msg2convert) \n//}\nmsg.payload = msg.payload / 10\nreturn msg;","outputs":1,"noerr":0,"x":760,"y":640,"wires":[["89b9b966.dffbc8","b2546b8b.793998","5619ecf7.808654","36e2a997.dc5d76"]]},{"id":"89b9b966.dffbc8","type":"ui_gauge","z":"a9e1c168.34a4a","name":"","group":"e010ab31.a5b8e8","order":0,"width":"3","height":"2","gtype":"gage","title":"Température","label":"units","format":"{{value}}°C","min":"-10","max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":950,"y":640,"wires":[]},{"id":"5619ecf7.808654","type":"influxdb out","z":"a9e1c168.34a4a","influxdb":"f737d1a1.c06c08","name":"","measurement":"ThermPro_Temperature","precision":"","retentionPolicy":"","x":1110,"y":680,"wires":[]},{"id":"b2546b8b.793998","type":"file","z":"a9e1c168.34a4a","name":"Chart dump","filename":"/home/pi/Documents/ThermPro-01_temp.dump","appendNewline":true,"createDir":false,"overwriteFile":"true","x":950,"y":720,"wires":[[]]},{"id":"36e2a997.dc5d76","type":"ui_chart","z":"a9e1c168.34a4a","name":"","group":"99b72a6.83225d8","order":3,"width":"6","height":"3","label":"Température","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"...Attente des données (max 15s)","dot":false,"ymin":"","ymax":"","removeOlder":"12","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"x":950,"y":760,"wires":[[]]},{"id":"8be2ab74.cf3608","type":"file in","z":"a9e1c168.34a4a","name":"Chart dump","filename":"/home/pi/Documents/ThermPro-01_temp.dump","format":"utf8","sendError":true,"x":650,"y":760,"wires":[["36e2a997.dc5d76"]]},{"id":"9c78f903.9eece8","type":"inject","z":"a9e1c168.34a4a","name":"Startup","repeat":"","crontab":"","once":true,"topic":"","payload":"","payloadType":"date","x":480,"y":760,"wires":[["8be2ab74.cf3608"]]},{"id":"d6272baf.3c069","type":"string","z":"a9e1c168.34a4a","name":"Humidité","methods":[{"name":"between","params":[{"type":"str","value":";HUM="},{"type":"str","value":";"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":460,"y":820,"wires":[["901563b9.d7879","abcf17a2.cc6288"]]},{"id":"abcf17a2.cc6288","type":"convert","z":"a9e1c168.34a4a","name":"","convertTo":"number","x":670,"y":820,"wires":[["cf915f5d.283f4","d84a4dae.5e5e58","3465add8.d1a93a"]]},{"id":"cf915f5d.283f4","type":"ui_gauge","z":"a9e1c168.34a4a","name":"","group":"e010ab31.a5b8e8","order":0,"width":"3","height":"2","gtype":"gage","title":"Humidité","label":"units","format":"{{value}}%","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":940,"y":820,"wires":[]},{"id":"d84a4dae.5e5e58","type":"influxdb out","z":"a9e1c168.34a4a","influxdb":"f737d1a1.c06c08","name":"","measurement":"ThermPro_Humidity","precision":"","retentionPolicy":"","x":1100,"y":860,"wires":[]},{"id":"901563b9.d7879","type":"file","z":"a9e1c168.34a4a","name":"Chart dump","filename":"/home/pi/Documents/ThermPro-01_humidity.dump","appendNewline":true,"createDir":false,"overwriteFile":"true","x":650,"y":860,"wires":[[]]},{"id":"ac20f4f3.b1e63","type":"file in","z":"a9e1c168.34a4a","name":"Chart dump","filename":"/home/pi/Documents/ThermPro-01_humidity.dump","format":"utf8","sendError":true,"x":650,"y":900,"wires":[["3465add8.d1a93a"]]},{"id":"c742c0a2.e8035","type":"inject","z":"a9e1c168.34a4a","name":"Startup","repeat":"","crontab":"","once":true,"topic":"","payload":"","payloadType":"date","x":480,"y":900,"wires":[["ac20f4f3.b1e63"]]},{"id":"3465add8.d1a93a","type":"ui_chart","z":"a9e1c168.34a4a","name":"","group":"99b72a6.83225d8","order":4,"width":"6","height":"3","label":"Humidité","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"...Attente des données (max 15s)","dot":false,"ymin":"","ymax":"","removeOlder":"12","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"x":940,"y":900,"wires":[[]]},{"id":"9eddd65a.5cc38","type":"debug","z":"a9e1c168.34a4a","name":"humidité","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":460,"y":680,"wires":[]},{"id":"25737c2e.cc1f2c","type":"serial-port","serialport":"/dev/rflink","serialbaud":"57600","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"\\n","bin":"false","out":"char","addchar":"","responsetimeout":"10000"},{"id":"e010ab31.a5b8e8","type":"ui_group","name":"Vide-sanitaire","tab":"eb894080.edb56","order":7,"disp":true,"width":"6","collapse":false},{"id":"f737d1a1.c06c08","type":"influxdb","hostname":"192.168.1.200","port":"8086","protocol":"http","database":"CAPTEURS","name":"","usetls":false,"tls":"","influxdbVersion":"1.x"},{"id":"99b72a6.83225d8","type":"ui_group","name":"Vide-sanitaire","tab":"9d93e8f.e13c718","order":7,"disp":true,"width":"6","collapse":false},{"id":"eb894080.edb56","type":"ui_tab","name":"Temp. & Humidité","icon":"fa-thermometer-full ","order":19,"disabled":false,"hidden":false},{"id":"9d93e8f.e13c718","type":"ui_tab","name":"Graph. Temp.","icon":"fa-line-chart","order":6,"disabled":false,"hidden":false}]
Hallo Jean-Luc,
For good news it is never to late.
Please can you resend the node again.
I cannot read it , there is something wrong in one commando/ word .
I cannot copy this node
Thanks
Dick
Verzonden vanuit Mail voor Windows
Jean-Luc
You are rightit is data from RFlink /433Mhz.
I looked for the eroor.
But i cannot find
Gr
Dick
Verzonden vanuit Mail voor Windows
Hey Dick,
I imported the flow in another NR and it's ok. Anyway.
So I removed the nodes for influxdb. Not useful for the demo.
But you really have to import via the palette the node-red-contrib-convert before importing the flow.
I hope it will work this time
[{"id":"573bebda.551b3c","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"6f4cb128.939ec8","type":"serial in","z":"573bebda.551b3c","name":"RFlink","serial":"25737c2e.cc1f2c","x":150,"y":400,"wires":[["5a2cbe93.deba8"]]},{"id":"5a2cbe93.deba8","type":"switch","z":"573bebda.551b3c","name":"Sonde OWL_CM180 ou ThermPro ?","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"OWL_CM180","vt":"str"},{"t":"cont","v":"Prologue","vt":"str"},{"t":"cont","v":"Pollin","vt":"str"},{"t":"cont","v":"Digitech","vt":"str"},{"t":"else"}],"checkall":"true","repair":true,"outputs":5,"x":390,"y":400,"wires":[[],["af46a898.a464c","b7f6c495.0f8a98"],[],[],[]],"outputLabels":["Sonde ampermétrique OWL180","Sonde Humidité+Temp Therm Pro","Sonde Pollin PFR-130 Pluie","Digitech Weather Station","Inconnu"]},{"id":"b7f6c495.0f8a98","type":"function","z":"573bebda.551b3c","name":"add timestamp","func":"msg.payload = new Date().toString() + \" - \" + msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":720,"y":380,"wires":[["1990c5ed.67c982"]]},{"id":"1990c5ed.67c982","type":"file","z":"573bebda.551b3c","name":"Log du Thermpro","filename":"/home/pi/Documents/ThermPro-Log_temp.dump","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"utf8","x":930,"y":380,"wires":[[]]},{"id":"38e5744e.fc6ccc","type":"comment","z":"573bebda.551b3c","name":"Les Sondes ThermPro de température & humidité","info":"**ThermPro **","x":300,"y":540,"wires":[]},{"id":"1268ba70.600b06","type":"comment","z":"573bebda.551b3c","name":"Sonde Vide Sanitaire","info":"","x":700,"y":540,"wires":[]},{"id":"af46a898.a464c","type":"string","z":"573bebda.551b3c","name":"SondeID","methods":[{"name":"between","params":[{"type":"str","value":";ID="},{"type":"str","value":";TEMP="}]}],"prop":"payload","propout":"sondeID","object":"msg","objectout":"msg","x":200,"y":600,"wires":[["35fc3439.6d4d2c"]]},{"id":"35fc3439.6d4d2c","type":"switch","z":"573bebda.551b3c","name":"quelle sonde","property":"sondeID","propertyType":"msg","rules":[{"t":"eq","v":"9171","vt":"str"},{"t":"eq","v":"9100","vt":"str"},{"t":"eq","v":"9142","vt":"str"}],"checkall":"false","repair":false,"outputs":3,"x":350,"y":600,"wires":[[],["44c34056.d92ce","d6272baf.3c069","9eddd65a.5cc38"],[]],"outputLabels":["Sonde extérieur - (9171)","Sonde vide sanitaire - (9100)","Sonde armoire PhotoVoltaique - (9142)"]},{"id":"44c34056.d92ce","type":"string","z":"573bebda.551b3c","name":"Température","methods":[{"name":"between","params":[{"type":"str","value":"TEMP="},{"type":"str","value":";HUM="}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":550,"y":600,"wires":[["b1976976.ac7098"]]},{"id":"b1976976.ac7098","type":"switch","z":"573bebda.551b3c","name":"Id not Null","property":"payload","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":700,"y":600,"wires":[["7f7894a3.3e3f04"]]},{"id":"7f7894a3.3e3f04","type":"function","z":"573bebda.551b3c","name":"Hex2Dec","func":"global.set('hex2dec', function(hexa) {\n return parseInt(hexa, 16);\n}, 'memoryOnly');\nvar msg2convert = msg.payload;\nmsg.payload = global.get('hex2dec', 'memoryOnly')(msg2convert)\n//msg.payload = {\n// dec: global.get('hex2dec', 'memoryOnly')(msg2convert) \n//}\nmsg.payload = msg.payload / 10\nreturn msg;","outputs":1,"noerr":0,"x":840,"y":600,"wires":[["89b9b966.dffbc8","b2546b8b.793998","36e2a997.dc5d76"]]},{"id":"89b9b966.dffbc8","type":"ui_gauge","z":"573bebda.551b3c","name":"","group":"e010ab31.a5b8e8","order":0,"width":"3","height":"2","gtype":"gage","title":"Température","label":"units","format":"{{value}}°C","min":"-10","max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1030,"y":600,"wires":[]},{"id":"b2546b8b.793998","type":"file","z":"573bebda.551b3c","name":"Chart dump","filename":"/home/pi/Documents/ThermPro-01_temp.dump","appendNewline":true,"createDir":false,"overwriteFile":"true","x":1030,"y":680,"wires":[[]]},{"id":"36e2a997.dc5d76","type":"ui_chart","z":"573bebda.551b3c","name":"","group":"99b72a6.83225d8","order":3,"width":"6","height":"3","label":"Température","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"...Attente des données (max 15s)","dot":false,"ymin":"","ymax":"","removeOlder":"12","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"x":1030,"y":720,"wires":[[]]},{"id":"8be2ab74.cf3608","type":"file in","z":"573bebda.551b3c","name":"Chart dump","filename":"/home/pi/Documents/ThermPro-01_temp.dump","format":"utf8","sendError":true,"x":730,"y":720,"wires":[["36e2a997.dc5d76"]]},{"id":"9c78f903.9eece8","type":"inject","z":"573bebda.551b3c","name":"Startup","repeat":"","crontab":"","once":true,"topic":"","payload":"","payloadType":"date","x":560,"y":720,"wires":[["8be2ab74.cf3608"]]},{"id":"d6272baf.3c069","type":"string","z":"573bebda.551b3c","name":"Humidité","methods":[{"name":"between","params":[{"type":"str","value":";HUM="},{"type":"str","value":";"}]}],"prop":"payload","propout":"payload","object":"msg","objectout":"msg","x":540,"y":780,"wires":[["901563b9.d7879","abcf17a2.cc6288"]]},{"id":"cf915f5d.283f4","type":"ui_gauge","z":"573bebda.551b3c","name":"","group":"e010ab31.a5b8e8","order":0,"width":"3","height":"2","gtype":"gage","title":"Humidité","label":"units","format":"{{value}}%","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":1020,"y":780,"wires":[]},{"id":"901563b9.d7879","type":"file","z":"573bebda.551b3c","name":"Chart dump","filename":"/home/pi/Documents/ThermPro-01_humidity.dump","appendNewline":true,"createDir":false,"overwriteFile":"true","x":730,"y":820,"wires":[[]]},{"id":"ac20f4f3.b1e63","type":"file in","z":"573bebda.551b3c","name":"Chart dump","filename":"/home/pi/Documents/ThermPro-01_humidity.dump","format":"utf8","sendError":true,"x":730,"y":860,"wires":[["3465add8.d1a93a"]]},{"id":"c742c0a2.e8035","type":"inject","z":"573bebda.551b3c","name":"Startup","repeat":"","crontab":"","once":true,"topic":"","payload":"","payloadType":"date","x":560,"y":860,"wires":[["ac20f4f3.b1e63"]]},{"id":"3465add8.d1a93a","type":"ui_chart","z":"573bebda.551b3c","name":"","group":"99b72a6.83225d8","order":4,"width":"6","height":"3","label":"Humidité","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"...Attente des données (max 15s)","dot":false,"ymin":"","ymax":"","removeOlder":"12","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"x":1020,"y":860,"wires":[[]]},{"id":"9eddd65a.5cc38","type":"debug","z":"573bebda.551b3c","name":"humidité","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":540,"y":640,"wires":[]},{"id":"abcf17a2.cc6288","type":"convert","z":"573bebda.551b3c","name":"","convertTo":"number","x":750,"y":780,"wires":[["cf915f5d.283f4","3465add8.d1a93a"]]},{"id":"25737c2e.cc1f2c","type":"serial-port","serialport":"/dev/rflink","serialbaud":"57600","databits":"8","parity":"none","stopbits":"1","waitfor":"","newline":"\\n","bin":"false","out":"char","addchar":"","responsetimeout":"10000"},{"id":"e010ab31.a5b8e8","type":"ui_group","name":"Vide-sanitaire","tab":"eb894080.edb56","order":7,"disp":true,"width":"6","collapse":false},{"id":"99b72a6.83225d8","type":"ui_group","name":"Vide-sanitaire","tab":"9d93e8f.e13c718","order":7,"disp":true,"width":"6","collapse":false},{"id":"eb894080.edb56","type":"ui_tab","name":"Temp. & Humidité","icon":"fa-thermometer-full ","order":19,"disabled":false,"hidden":false},{"id":"9d93e8f.e13c718","type":"ui_tab","name":"Graph. Temp.","icon":"fa-line-chart","order":6,"disabled":false,"hidden":false}]
Ok Jean-Luc
I tried to insert
But there is an errori
(see picture)
But i made it
Thanks
Dick
Verzonden vanuit Mail voor Windows
Heeo,
here i come again
20;0A;Cresta;ID=2C01;TEMP=00e8;HUM=63;BAT=OK;
with change is it reformed to:
20;05;Cresta;ID;2C01;TEMP;00f2;HUM;65;BAT;OK
it is working till
{"ID":147,"TEMP":27,4,BAT":OK,"HUM":78}
what shall i do to get this information
in a eg gauge temperature , gauge humidity
ID in text for the dashboard?
thanks in advance.
gr
Dick
Most ui nodes allow you to select the property to show, using the Value Format field. So if you want a gauge with temperature then put in that field {{payload.TEMP}}
That assumes the the payload is a javascript object containing the property TEMP, which I think is what you say you have.
If that doesn't work then feed the message into a debug node and show us what you get there.
Colin thanks,
I follow the various advices during this data.
the debugs are as follows:
sensor gives:20;07;Cresta;ID=2C01;TEMP=00ef;HUM=64;BAT=OK;
with function {"ID":2C01,"TEMP":23,"HUM":100,"BAT":null}
with function temperature:20;3C;Cresta;ID=2C01;TEMP=00ef;HUM=64;BAT=OK;
{"TEMP":22,"HUM":98}
function temperature
msg.payload = msg.TEMP;
return msg; is the result undefined.
msg.payload = msg.HUM; gives also undefined.
(With other sensor eg dht11 gives with he same command i get the right temp and hum)
I think a made mistake during the whole process.
I hope this is enough for you to find a solution for me?
gr
Dick
You have "TEMP":27,4
- notice the comma (,
) between the 27
and 4
, that should be a period (.
) or the object will be messed up. It should be "TEMP":27.4
so you would have:
{"ID":147,"TEMP":27.4,BAT":OK,"HUM":78}
The sample code I posted leaves TEMP and HUM in msg.payload.
You should not need any further function nodes to move things around
As Colin said you should be able to just use {{payload.TEMP}}
e.g
[{"id":"114c43cf.aa1ea4","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20;0A;Cresta;ID=2C01;TEMP=00e8;HUM=63;BAT=OK;","payloadType":"str","x":90,"y":820,"wires":[["525b3f06.acd908"]]},{"id":"525b3f06.acd908","type":"function","z":"b779de97.b1b46","name":"","func":"const split_array = msg.payload.split(\";\");\nmsg.payload={};\nfor(let i in split_array){\n let parts =split_array[i].split(\"=\");\n if(parts.length === 2){\n if(parts[0]===\"HUM\") msg.payload[parts[0]]=parseInt(parts[1]);\n else if(parts[0] === \"TEMP\") msg.payload[parts[0]] = parseInt(parts[1], 16)/10;\n else if(parts[0]===\"ID\") msg.payload [parts[0]] = parseInt(parts[1], 16);\n else msg.payload[parts[0]] = parts[1];\n }\n}\n\n\n/* or\nmsg.payload = msg.payload.split(/=|;/);\nmsg.payload = {\n [msg.payload[5]]: parseInt(msg.payload[6],16)/10,\n [msg.payload[7]]: parseInt(msg.payload[8])\n}\n*/\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":250,"y":820,"wires":[["28a29eb7.ccf372","20de9a3f.02141e","762a773f.c7cb38"]]},{"id":"28a29eb7.ccf372","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":490,"y":820,"wires":[]},{"id":"20de9a3f.02141e","type":"ui_gauge","z":"b779de97.b1b46","name":"","group":"8b5cde76.edd58","order":14,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"units","format":"{{payload.TEMP}}","min":0,"max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":450,"y":880,"wires":[]},{"id":"762a773f.c7cb38","type":"ui_gauge","z":"b779de97.b1b46","name":"","group":"8b5cde76.edd58","order":14,"width":0,"height":0,"gtype":"gage","title":"Humidity","label":"units","format":"{{payload.HUM}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":450,"y":920,"wires":[]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"12","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
If this is failing post the section of your flow that you are having difficulty with.
That is because it msg.payload.TEMP not msg.TEMP. But no need to do that if you just want to feed it into a gauge.