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: emonCMS: Getting started emonPi/Base ā€” OpenEnergyMonitor 0.0.1 documentation

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 emoncms.org? 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 emoncms.org.

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

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 emoncms.org 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 emoncms.org? (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 emoncms.org, 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 emoncms.org. 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 emoncms.org.

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.

2 Likes