You can use change node to get the value for each gauge
(for humidity the to field must be payload.humidity)
Or if you want, you can edit the function to create 4 messages where payload alread carries single dedicate value.
You can use change node to get the value for each gauge
(for humidity the to field must be payload.humidity)
Or if you want, you can edit the function to create 4 messages where payload alread carries single dedicate value.
The flow code
[{"id":"dbb798e0.0cd498","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"fb03f3c3.d80078","type":"json","z":"dbb798e0.0cd498","name":"","property":"payload","action":"","pretty":false,"x":482,"y":533,"wires":[["8005f275.19abb8","8903a311.1304a"]]},{"id":"c1ec2ba8.a2e63","type":"debug","z":"dbb798e0.0cd498","name":"","active":true,"tosidebar":true,"console":true,"tostatus":true,"complete":"true","targetType":"full","x":770,"y":400,"wires":[]},{"id":"476f9720.d6b8a8","type":"mqtt in","z":"dbb798e0.0cd498","name":"","topic":"tele/Condizionatore/SENSOR","qos":"1","datatype":"auto","broker":"6c357407.2e2684","x":280,"y":380,"wires":[["fb03f3c3.d80078"]]},{"id":"91db737.0ed221","type":"ui_gauge","z":"dbb798e0.0cd498","name":"Room temp","group":"ceee212e.e6fb28","order":5,"width":"6","height":"4","gtype":"gage","title":"Ufficio","label":"","format":"{{value}}°C","min":0,"max":"50","colors":["#00ff00","#fdd242","#ff0202"],"seg1":"","seg2":"","x":1150,"y":580,"wires":[]},{"id":"8005f275.19abb8","type":"debug","z":"dbb798e0.0cd498","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":400,"wires":[]},{"id":"8903a311.1304a","type":"function","z":"dbb798e0.0cd498","name":"parse multiple AM2310","func":"var out_1 = null // this will be message for first output\nvar out_2 = null// this will be message for second output\n\n// notice that if message stays null, it will not be sended out from here\n\nfor (const property in msg.payload) {\n // you can always debug incoming payload for what properties it has.\n //just remove \"//\" from beginning of the next line\n //node.warn(property+\":\"+JSON.stringify(msg.payload[property]));\n if(property == \"AM2301-13\"){\n // incoming payload contains AM2301-13. lets create outgoing message out_1\n out_1 = {topic:property}// you can change the topic to indicate sensor location\n // let's create payload containing humidity and temperature of that sensor\n out_1.payload = {temperature:msg.payload[property].Temperature,humidity:msg.payload[property].Humidity}\n \n }\n //let's do same things if AM2301-14 found in payload\n if(property == \"AM2301-14\"){\n out_2 = {topic:property}\n out_2.payload = {temperature:msg.payload[property].Temperature,humidity:msg.payload[property].Humidity}\n \n }\n}\n\n// now there will be 2 outputs. \nreturn [out_1,out_2];","outputs":2,"noerr":0,"x":660,"y":600,"wires":[["c1ec2ba8.a2e63","e4904f0f.4abab","27b1077.adb2378"],["91d149ce.54dd98","32a52780.bc5588"]]},{"id":"d730c59.11b89b8","type":"ui_gauge","z":"dbb798e0.0cd498","name":"Room Umidità ","group":"ceee212e.e6fb28","order":5,"width":"6","height":"4","gtype":"gage","title":"Umidità ","label":"","format":"{{value}}%","min":0,"max":"100","colors":["#00ff00","#fdd242","#ff0202"],"seg1":"","seg2":"","x":1140,"y":540,"wires":[]},{"id":"e4904f0f.4abab","type":"change","z":"dbb798e0.0cd498","name":"Umidità ","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.humidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":540,"wires":[["d730c59.11b89b8"]]},{"id":"91d149ce.54dd98","type":"change","z":"dbb798e0.0cd498","name":"Umidità ","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.humidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":620,"wires":[["154c8650.6853fa"]]},{"id":"27b1077.adb2378","type":"change","z":"dbb798e0.0cd498","name":"Temperatura","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":580,"wires":[["91db737.0ed221"]]},{"id":"32a52780.bc5588","type":"change","z":"dbb798e0.0cd498","name":"Temperatura","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":660,"wires":[["67913272.6bae4c"]]},{"id":"67913272.6bae4c","type":"ui_gauge","z":"dbb798e0.0cd498","name":"Room temp","group":"ceee212e.e6fb28","order":5,"width":"6","height":"4","gtype":"gage","title":"Soggiorno","label":"","format":"{{value}}°C","min":0,"max":"50","colors":["#00ff00","#fdd242","#ff0202"],"seg1":"","seg2":"","x":1150,"y":660,"wires":[]},{"id":"154c8650.6853fa","type":"ui_gauge","z":"dbb798e0.0cd498","name":"Room Umidità ","group":"ceee212e.e6fb28","order":5,"width":"6","height":"4","gtype":"gage","title":"Umidità ","label":"","format":"{{value}}%","min":0,"max":"100","colors":["#00ff00","#fdd242","#ff0202"],"seg1":"","seg2":"","x":1140,"y":620,"wires":[]},{"id":"6c357407.2e2684","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"ceee212e.e6fb28","type":"ui_group","z":"","name":"Condizionatori","tab":"30daa7b8.3ce76","disp":true,"width":"6","collapse":false},{"id":"30daa7b8.3ce76","type":"ui_tab","z":"","name":"Bedroom1","icon":"dashboard"}]
The real issue what was wrong with your flow:
MQTT formatting
then sent to JSON node where from output configured
But the data type what is needed is javascript object. And if you explore the MQTT node, you can configure the output a parsed JSON object and this way the JSON node is not needed at all.
Data will be properly formatted and the hypen can be solved by
msg.payload["property-with-hypen"].value
It just didn't make sense for me so I needed to digg deeper.
But anyway, the problem is solved.
i have a similar problem with SHTC3-0x70 sensor from tasmota, i can't figure out how to write this in node red because node red doesn't read the characters, can anyone help?
Show us exactly what you have tried that doesn't work.
Here attached is my flow, where i can read temperature from DS18B20 and where it's not possibile to read the values from SHTC3 eventhough they're connected and both working on the same ESP8266 in Tasmota.
[{"id":"7f734a08.a6c2a4","type":"debug","z":"dbb798e0.0cd498","name":"Temperatura","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":260,"wires":}]
What are you seeing in node-red? Feed the data into a debug node and show us what it shows.
i have this in debug
For ds18b20
05/01/2021, 15:43:51node: Temperature
msg.payload : number
19.3
For SHTC3
05/01/2021, 15:43:51node: Temperatura
msg.payload : undefined
undefined
I meant what do you see coming out of the MQTT node? You need to show us that and how you are attempting to extract the data. However before replying please read the docs page Working with Messages which shows how you can get the path to a value from the debug pane to use in a function or Change node.
Also your flow is not importable, when pasting a flow here you can use the </>
button at the top of the forum entry window, that stops the forum from messing with it. However, since you only exported a debug node that would not have helped much anyway.
Here's what i have from the mqtt console
16:23:42 MQT: tele/sonoff/SENSOR = {"Time":"2021-01-05T16:23:42","DS18B20":{"Temperature":18.6},"SHTC3-0x70":{"Temperature":18.7,"Humidity":79.5},"MCP230XX":{"D0":0,"D1":0,"D2":0,"D3":0,"D4":0,"D5":0,"D6":0,"D7":0,"D8":0,"D9":0,"D10":0,"D11":0,"D12":0,"D13":0,"D14":0,"D15":0},"TempUnit":"C"}
[{"id":"dbb798e0.0cd498","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"a5041287.ede75","type":"inject","z":"dbb798e0.0cd498","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"30","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":430,"y":220,"wires":[["1f0f917d.12d88f"]]},{"id":"de647ff4.b6d6b","type":"debug","z":"dbb798e0.0cd498","name":"Temperature","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":180,"wires":[]},{"id":"7f734a08.a6c2a4","type":"debug","z":"dbb798e0.0cd498","name":"Temperatura","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":910,"y":260,"wires":[]},{"id":"1f0f917d.12d88f","type":"Tasmota Sensor","z":"dbb798e0.0cd498","broker":"5acedfdd.575cd","device":"sonoff","name":"","outputs":3,"uidisabler":false,"fullTopic":"","cmndPrefix":"cmnd","statPrefix":"stat","telePrefix":"tele","rules":["DS18B20.Temperature","","['SHTC3-0x70'].Temperature"],"x":690,"y":220,"wires":[["de647ff4.b6d6b"],[],["7f734a08.a6c2a4"]]},{"id":"5acedfdd.575cd","type":"mqtt-broker","name":"Tasmota","broker":"192.168.1.96","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
You are using the contrib node not trying to read the data with standard nodes. That is another story. It is reasonable to rise the issue in node's github page or try to contact with the node's author.
How can i do a work around only with node red without using any contrib nodes? Can i have an example?
Post 23 in this same thread has pretty valid example.
You should be able to use an MQTT In node and get the data that way. That is the way I would do it rather than use a contrib node.