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!
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.
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.)
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,
Use the emoncms Node-RED node
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ā?)
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.
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.