Problems parsing MQTT data to dashboard

Hi, I am new to Node-Red.
I have a working Mosquitto server.
ESP32 publishes two sensor data that are shown at Node_Red debug flow:

Debug output was activated as follow:
Plain from Mosquitto MQTT:

Converted to Javascript:
{temperatura: object}
{humidade: object}

Javascript then split:
{value: 27}
{value: 67}

***New user can only post two pictures so I transcribed the last two:

Still I do not get data that would be suitable for submission to the dashboard.
My goal is to have two gauges, one for temperatura and one for humidade.

Assistance welcome.
Thanks
Paulo

mqtt -> json node (or set the mqtt node to send a json message instead), remove the split node.

output will be something like

{temperatura:{value:27.00}}
{humidade:{value:59.00}}

connect the 2 gauge nodes to the json/mqtt node and in the value fields use:

{{msg.payload.temperatura.value}}
{{msg.payload.humdade.value}}

Don't forget to take a look at the cookbook

Dear backman2, thanks for your availability to assist.
Only the json node:

Not getting the expected result...
What I am doing wrong?
Thanks

That is the expected result, even easier to just set the mqtt node output to "a parsed JSON object", then you can remove the json node.

OK, did that, from MQTT (straight to debug as a "parsed JSON object")
Get the same result as the previous picture.
Now, you mean I can submit that to the dashboard as it is?

Remember I have 2 gauges, don't I have to use a split somewhere?
Thanks

As I indicated above, you can use the values directly in the gauge node.

Also read the documentation how to work with json/messages

I am in the process of trying the gauge now...
I have been reading some of these docs, your indication will sure help as well but as it was not working I decided to get some help on making it work. Once it works it also makes it more easy to see what went wrong.

Just a last one.
Gauge is still in progress but you mean gauge will understand I actually have two variables to plot?
Separately?
Thanks

Yes: 2 gauges, 2 different values, 1 mqtt node.
The documentation explains the JSON message part, that is what is coming from the MQTT node.

The gauge node parses this message, thus if there is temperatura in there it will display it else it won't, same applies to the humidity.

OK, I have been to this doc already.
My difficulty is to understand how to, for instance, Mosquitto sends temperatura data and humidade data at different moments.
How do I know the data I am dealing with now is temperatura? How do I test it?
Because if I want to do something else with this value I must know what is the data about.

Supose I want to publish back to Mosquito a, say, LED "on" when temperature is above, say, 30 degrees? You see, that is where I am still struggling.

Well, not only there...
I linket MQTT node straight to Gauge and what I am getting is this:

Thanks
Paulo

try setting the gauge like this

Hi, thanks dceejay, it worked for temperatura...
How do I get a separate gauge for humidade?

I mean, perhaps link another gauge at the same source and make it as you said just with humidade?

Great, I did that and it worked. Thanks

Thanks again...

HI again...
It is working perfectly with a gauge with value= {{msg.payload.temperatura.value}} and a separate gauge with value={{msg.payload.humidade.value}} but the debug screen shows an error:
"Type error: cannot read property 'value' of undefined" for both temperatura and humidade gauges.

My current flow is as below:

MQTT node:
Server: Mosquitto
Topic: /devices/esp32devboard/#
Output: auto-detect (string or buffer)
Name: AllTopics

JSON
Action: always convert to javascript object
property: payload

Gauge
Group: myGroup
Label: Temperatura
value format: {{msg.payload.temperatura.value}}

Gauge humidade is changed accordingly.

Thanks
Paulo

edit I am incorrect, i will post a test flow.

Apologies, i made quick assumptions, the undefined error comes from the gauge node that doesn't accept other data than the one defined.

With this flow it should work, instead of using a "split", it contains 2 switch nodes that only passes data when either temperature or humidity exists. Replace the inject nodes with the mqtt node

[{"id":"5e695d79.c5a7f4","type":"ui_gauge","z":"50a9d0fb.ca78d","name":"","group":"9aa3571e.b6013","order":2,"width":0,"height":0,"gtype":"gage","title":"temperatura","label":"c","format":"{{msg.payload.temperatura.value}}","min":"-20","max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":686,"y":672,"wires":[]},{"id":"7030a7e6.81464","type":"ui_gauge","z":"50a9d0fb.ca78d","name":"","group":"9aa3571e.b6013","order":2,"width":0,"height":0,"gtype":"gage","title":"humidity","label":"%","format":"{{msg.payload.humidade.value}}","min":0,"max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":676,"y":728,"wires":[]},{"id":"b8e3427b.68e8d","type":"inject","z":"50a9d0fb.ca78d","name":"{\"temperatura\":{\"value\":24}}","topic":"","payload":"{\"temperatura\":{\"value\":24}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":232,"y":672,"wires":[["dbb7cea4.d730d8","8ead371d.55a9d"]]},{"id":"514b08ba.318018","type":"inject","z":"50a9d0fb.ca78d","name":"{\"humidade\":{\"value\":52}}","topic":"","payload":"{\"humidade\":{\"value\":52}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":222,"y":728,"wires":[["8ead371d.55a9d","dbb7cea4.d730d8"]]},{"id":"8ead371d.55a9d","type":"switch","z":"50a9d0fb.ca78d","name":"humidity","property":"payload.humidade","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":480,"y":728,"wires":[["7030a7e6.81464"]]},{"id":"dbb7cea4.d730d8","type":"switch","z":"50a9d0fb.ca78d","name":"temperatura","property":"payload.temperatura","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":490,"y":672,"wires":[["5e695d79.c5a7f4"]]},{"id":"9aa3571e.b6013","type":"ui_group","z":"","name":"Default","tab":"76ec6942.7f7ab","disp":true,"width":"17","collapse":false},{"id":"76ec6942.7f7ab","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

@dceejay I am running NR beta, the has key option works nicely for this example :slight_smile: thanks for the implementation!

Hi, this one worked perfect.
Thank you all for your contributions and effort.
Regards
Paulo

This "has key" would be perfect.
Any information on when it will be available?
Thanks
Paulo