Calculating Energy Cost using ESPhome

I’m interested in finding a way to calculate my natural gas energy cost using ESPhome. I’m hoping someone smarter than me can help me determine if this can be done.

My new home will have a 3-zone radiant floor heat system. A single natural gas boiler will feed all the zones. I’m hoping to use a series of sensors and ESPhome to get a rough estimate of the energy cost of heating each zone.

What I know

  • I pay about $0.52 per therm (100,000 BTUs)
  • It takes 8.33 BTUs to heat 1 gallon of water 1 degree (Fahrenheit)

If I know the water flow in gallons of each zone, the temperature of the water supplied to the zone, and the temperature of the water returning from the zone then I should be able to get a rough calculation of my BTU usage and therefore energy cost, right? What I can’t find out how to do is to capture the water temp differences only when the pump is running and the water is flowing. I essentially need to tell ESPhome or home assistant to capture the temperature data only while the water is flowing, average it, then multiply the average temperature difference by the total gallons of water that flowed then by 8.33 to get my BTU usage.

Does anyone know how to do this? Or know of a simpler way?

Measure the gas going in and multiply by the price?

I’ve considered that, but gas meters that work with HA are a few hundred bucks. Plus, that would only give me the cost for the 3 combined zones. I’d prefer to measure them separately. 1 zone is my basement that will be kept at 70. Another is my garage and the 3rd is a basement storage area. I’d like to know what I’m spending on the garage and storage area so I can decide how warm I want to maintain it

Your proposed method is able to be done in HA I am sure. As long as you can record when the pump is going and the volume of water to each branch.