Publish Feed value to MQTT

I’d like to take the value of a Feed and publish it to MQTT. The Feed is my house energy in kWh.

I thought this was possible but I am not able to figure it out. (It is one of those cases where I feel like I am missing the obvious!) Can someone point me in the right direction? Thank you!

Hi Jon

I did this from inputs.

I (borrowed) an input that is always zero.

I added the feed and then did published to mqtt.



1 Like

And if you haven’t got an always-zero input, you can “Reset to Zero” any input that’s otherwise finished processing and has been logged.

1 Like

It can be done in Emoncms but my preference would be to use nodeRED, it will give you much more flexibility. NodeRED is pre-installed and running on the emonPi. Just browse to http://emonpi:1880

See guide:

1 Like


I took the safe route and did both:

It worked great! Thank you @ian and @Robert.Wall!!

I tied to do something similar in a Virtual Feed but it did not work. It only grabbed one value and then stopped updating.


I am working in node-red for this effort so that is preferred for me also! But this is the only way it worked and it just seemed awkward. Is there another way via Node-Red??

That looks fine to me. Where is the data coming from? Can you obtain it locally from nodeRED?

The data is coming from the emonPi. It is the data calculated with the two CTs

That is where my original post came from. I could not figure out how to get it into node-red.

Ah you can get that data from MQTT just use an MQTT input node to subscribe to: emon/emonpi/power1pluspower2.

I don’t need power1pluspower2.

I’m looking for the kWh from the Power to kWh process.

Ah sorry, I misunderstood. I get it now.

So the two options available are: use the Emoncms publish to MQTT input process or nodeRED using the flow you already have .

Should the Virtual Feed work when doing a Publish to MQTT?

A Virtual Feed will only process one value and then it stopped updating.

No. Use the input processlist for that.
Virtual feeds are processed in realtime in every call to the feed API (eg. a graphic on a dashboard), and for the given time range on the API (eg, seeking on a graph).
The other case is when you get the last value from a virtual feed on a processlist to do some calculations.

slightly off topic but still in line with the topic…
I intend to use node-ed to subscribe to a external mqtt broker, and then to publish to the OEM mqtt broker.
feed would be like pv yield Node 258 and pv yield node 260 as the 2 outputs from 2 chase controllers. would what be the preferred topic structure? emon/emonpi/pvyield258 and emon/emonpi/pvyield260
2nd part of this question though, would this then show up as feeds, which I can graph ?
3rd part of question, (hehehe) I currently have x feeds, how do I get their mqtt names to be able to subscribe to my emonpi mqtt broker to pull into my Home Assistant / Node Red to push to InfluxDB and display via Grafana.
Still deciding where I’m going to create a single dashboard to show all my data. (thinking of using / keeping the OEM data in OEM, and keeping my Inverter data in the inverter MQTT broker and then consolidate all the different streams, which includes some sonoff power current temp etc feeds all onto the platform)