Battery SOC out of Home Assistant into Emonpi/cms?

At the moment, this will be just battery_soc, but could be any numeric value from home_assistant in the future so that I can graph everything in one place/

I have emonpi (with mqtt) and also emoncms.
I have local home assistant and a separate local mqtt broker and node-red installation.

What is the easiest way to get some values out of home assistant into emoncms?
Is there any way to create a virtual entity/feed that can be populated with an API call?
Maybe this could be local call from emonpi to home assistant, then forward the input onto emoncms

I have been playing with MQTT and do have my local broker pulling the value that I want from home assistant on a trigger automation. Based on a HA post that @borpin was involved in! :slight_smile:
But it’s the then getting it into emoncms bit that i’m struggling with. I’m no expert with node-red or mqtt AT ALL.

Do I create new feeds/inputs on emonpi? Then poke node-red into emon/something/something?
Or make an API call into emoncms?

Hope some of that makes sense?
Any help or pointers would be appreciated.

Cheers, Mick

Mild progress. I’ve got Node-Red publishing to the emonpi via MQTT (/emon/remote/battery_0100)

I see this in my emonpi feed list, but I don’t see this passing through to emoncms.

Do I have to do something with my emonpi emonhub config file? add a new node entry?
A bit scared of breaking something in there.

If the data is travelling via your LAN, I think I’m right in saying it completely bypasses emonHub, and goes straight into emonCMS.

And that’s puzzling me - that screenshot looks like the Inputs page of emonCMS, so the data must be getting into emonCMS.

Do you mean the list on the Feeds page or on the Inputs page?

If that really is the Inputs page (“Inputs” is in big letters at the top), then your next step is to add some processing to it using the spanner icon and save the data to a Feed. Only then will it appear on the Feeds page. (A “Feed” is the storage mechanism - all the processing on the Inputs page is transient, if it is not logged to a Feed, the data evaporates.)

You might find this useful: 2. Log Locally - Guide | OpenEnergyMonitor

I suggest installing the Node-RED Addon to HA (assuming you are running Supervisor). This then gives you a whole load of nodes that interact with HA and reduce the need for automations for publishing stuff to MQTT.

Then, 2 ways,

  1. Use the emoncms Node-RED node
  2. Publish the values to the MQTT topic your local emoncms subscribes to (my preferred method).

Either will automatically create the Input which you then process to create the Feed.

By ‘emoncms’ do you mean Both are EmonCMS just one is local and one is in ‘the cloud’.

An MQTT Broker doesn’t ‘pull’ anything. You Publish values to a Topic on the Broker which then makes them available to other resources that have ‘Subscribed’ to those topics.

If the topic your local emoncms subscribes to is emon/ (the default) then publish the value from NR to a topic such as emon/Battery_SOC and (as you see) an Input is then created. You then need to create a Process to create the Feed (just like you do for any other Input).

I think then there is a settng somewhere to mirror that info to

You could alternatively use the emoncms NR node and publish the data directly to

Thanks @borpin , yep i’m getting to this point.
(HA to local MQTT, being picked up by my local NR and pushed to my local emoncms MQTT). Probably over complicated, but it’s working and i’m happy to keep the NR/MQTT instances separate from HA install.

The bit I’m missing is that I can’t see the input created below (from my local emonpi/emoncms) being replicated on my account.

You mentioned ‘a setting’. Can anyone advise where that could be?

I see no reference to battery_0100 or remote in the Emonhub log (on local emonpi/emoncms)

Do I have to put the input on my local emonpi/emoncms into a feed for the input to then pass over to cloud (where i’d have to do a cloud ‘log to feed’?)

Thanks for any help.

The only route that I know of is if the input is coming via emonHub. EmonHub is capable of forwarding the data to, but if it’s arriving via your LAN and bypassing emonHub, then your source needs to send duplicate sets of data to both the local emonCMS and to Then it appears on the Inputs page of both emonCMS’s, and you arrange the same processing thereafter in both. That’s if I understand it correctly.

Node-RED Addon gives you a whole load more nodes that interact with HA directly. I run the Addon and another instance so it is horses for courses.

I think you have to create the Feed and then sync it? @TrystanLea is probably the person - I have never really used

The other way is to use the Node-RED Emoncms node and send it directly.

Hi Robert, thanks for that.

Yes, it makes sense that it you bypass the local emonhub and just stick the values directly into the input via MQTT, then how will emonhub know to pass the data onto remote emoncms?

So I modified the Node Red flow to make an API POST to emoncms and poke the battery % directly into a remote emoncms input. From there, I made a emoncms feed using that input.

So i’ve now got what I wanted, my battery % recording in emoncms, so I can graph it.

Thanks to you and @borpin for the pointers and direction. Much appreciated.

As I wrote - it cannot. emonHub knows nothing about it:

As I understand it, emonHub only handles data arriving via the handlers that it has - the serial interfacers, which are either the TTY port from the emonPI’s Atmel ATMega 328P (power & radio from outlying nodes) or the other Serial inputs like RS485 via the USB serial ports.

1 Like

Actually no, emonhub has lots of interfacers including a TCP one, but that is advanced usage that I really don’t understand :slight_smile:

Probably the best way :slight_smile:

1 Like

Hmm… It looks like one more to go on the bottom of the wish list then - fully document emonHub.