Utilise Energy Monitoring in HA on Existing Multipurpose ESP32

Hi,
I have an ESP32 currently monitoring my Electricity Meters (via pulse) x 4, water meter x 1 and various weather sensors. My Electricity data (for 2 meters) is currently uploaded to PVOutput for remote monitoring and the other data to Thingspeak (access via widget on phone). All my data is stored to a SQL database in 5 minute intervals also for periodical analysis.

I would like to add in my Electricity data to the built in Energy feature of HA however I have two queries
1. Can I add in ESPHome functionality into an ESP32 with unique custom code that is doing lots of other things (which I don’t want stored solely in HA). If so any pointers where I can find similar examples (doesn’t need to be energy obviously).
2. Can I expose data on the ESP32 another way which would make those values appear as sensors which HomeAssistant can access and therefore could complete the energy monitoring in HA as well.

Any pointers would be appreciated. Everything I have searched seems to just direct to ESPHome which if I can’t incorporate that into the existing code I have isn’t really a option and also don’t want to have to splice sensor wiring and run a extra ESP just for this functionality). Thanks.

  1. No
  2. Mqtt?

Thanks Tom,

Didn’t even think of MQTT. Think that shall be the perfect solution as it also will require minimal changes to my existing ESP Code.

Thanks again for your prompt and helpful reply

Mmm… You can do pretty much anything with ESPHome’s custom components, really

https://esphome.io/custom/custom_component.html

They are talking about adding ESPHome to an ESP device already running custom code.

1 Like

Thinking I will stay with the original plan even though what Chris is suggesting looks like would work it is going to be more involved and I wouldn’t get any of the extra benefits from doing it this way so feel no real reason to go this instead. Also feel MQTT is more versatile for the future and other plans that may be outside HA. Thanks for providing another alternative

Only if you removed your custom firmware.

In looking at it I took it as I could just add the library and incorporate the functions as needed but assumed many of the benefits to ESPHome would just not function because it was hard coded. Thanks for the clarification. Thankful I had decided on your original idea. Many Thanks.

Yeah it works the other way around, you can add custom components to ESPHome.

I re-read the OP thrice and just couldn’t fathom how you guessed :joy:

This bit:

1 Like

Hehe. I read it as “Can I add in ESPHome functionality with unique custom code that is doing lots of other things, into an ESP32”, basically :wink: