Voltage/Current readings from Sonoff POW R2 with Tasmota to Dashboard

Hi All,

I am EXTREMELY new to MQTT, Node Red and this world. But I want to learn and I thought this would be the best place for advise?

I have a MQTT Broker and Node Red set up on a pi and that is running perfectly. I have already created a few timers for items around the house (pool pump and borehole pump). These are running perfectly.

I found the Dashboard yesterday and want to create a gauge and donut for Voltage and Current respectively - and then play around more, but I need to start somewhere.

I have searched high and low but don't know how to "decode" the

stat/borehole/STATUS8

message and "convert" or extract the Voltage and Current from this message?

10:25:19 MQT: stat/borehole/STATUS8 = {"StatusSNS":{"Time":"2019-10-06T10:25:19","ENERGY":{"TotalStartTime":"2019-10-03T14:05:46","Total":5.731,"Yesterday":2.616,"Today":2.453,"Power":0.0,"ApparentPower":0.0,"ReactivePower":0.0,"Factor":0.00,"Voltage":236,"Current":0.00}}}

I have seen an example here with putting the MQTT INPUT --> FUNCTION NODE --> DASHBOARD GAUGE and adding this code

var msg1 = {};
var msg2 = {};

msg1.payload = msg.payload.Voltage;
msg1.topic = 'Voltage';
msg2.payload = msg.payload.Current;
msg2.topic = 'Current';

return [msg1, msg2];

to the FUNCTION NODE.

When I use a debug node to see the message, the only thing that shows is "Voltage" and "Current" in the 2 debug messages.

I understand that the values need to be read from

stat/borehole/STATUS8

From what I understand from searching the web, I think I need to use

$.StatusSNS.ENERGY.Voltage

and

$.StatusSNS.ENERGY.Current

to point to the value, but something just isn't tying up for me.

Im really struggling.. Any help will be greatly appreciated.
Im sure I have left some info out that is needed for you all to help :grimacing:

Thanks in advance everyone..

Feed this into a Json node connected to a debug node showing the complete message and you will find the paths to your required values in the debug panel.

payload.StatusSNS.ENERGY.Voltage
payload.StatusSNS.ENERGY.Current

Working through this page will give you a better understanding:

https://nodered.org/docs/user-guide/messages

Feed this into a Json node

or just change the mqtt node to output json instead.

You can extract this in various ways, using a change node "looks" cleaner

Example.

[{"id":"527edb.9164c124","type":"inject","z":"5182c67b.dd2b4","name":"","topic":"","payload":"{\"StatusSNS\":{\"Time\":\"2019-10-06T10:25:19\",\"ENERGY\":{\"TotalStartTime\":\"2019-10-03T14:05:46\",\"Total\":5.731,\"Yesterday\":2.616,\"Today\":2.453,\"Power\":0.0,\"ApparentPower\":0.0,\"ReactivePower\":0.0,\"Factor\":0.00,\"Voltage\":236,\"Current\":0.00}}}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":194,"y":192,"wires":[["1eabd804.eb0e2","620c88c1.d7e998"]]},{"id":"1eabd804.eb0e2","type":"change","z":"5182c67b.dd2b4","name":"Voltage","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.StatusSNS.ENERGY.Voltage","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":372,"y":168,"wires":[["78ecdf40.5ae2a8"]]},{"id":"78ecdf40.5ae2a8","type":"debug","z":"5182c67b.dd2b4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":598,"y":192,"wires":[]},{"id":"620c88c1.d7e998","type":"change","z":"5182c67b.dd2b4","name":"Current","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.StatusSNS.ENERGY.Current","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":372,"y":216,"wires":[["78ecdf40.5ae2a8"]]}]
2 Likes

Ah yes, I forgot that option :slight_smile:

@bakman2, that totally worked... Thank you so much...!

You had me puzzled with that long string of code... I was trying to decipher it for a while... Like I said, Im extremely new to this..

But then I looked at it more intently and thought it must be a flow in text format...

And you can, I'm sure, understand the next step..!

Thanks again, really appreciate your help... Love the power of the forums.. Such knowledge and willingness to help others.. :+1::+1::+1: