Gas utility meter not showing correct values, energy integration

I am trying to use the energy integration to show how much gas my furnace is using as well as the cost.
I am using a scraper to get the current price in $/therm, and then a template sensor to convert that to $/m³.
I then have another template sensor that calculates gas usage based on the total runtime of my furnace and its capacity. This sensor’s units are m³. I had to add customization in order for the Energy integration to recognize it as a gas consumption source.

homeassistant:
  customize:
    sensor.gas_usage_cubic_meters:
      state_class: total_increasing
      meter_period: daily
      icon: hass:counter

sensor:
  - platform: template
    sensors:
      gas_price_cubic_meters:
        friendly_name: "Gas Price (m^3)"
        value_template: >-
          {% set p = states('sensor.current_gas_cost') | float %}
          {{p / 2.83168}}
        unit_of_measurement: "$/m³"
      gas_usage_cubic_meters:
        friendly_name: "Gas Usage (m^3)"
        device_class: gas
        value_template: >-
          {% set t = states('sensor.furnace_on_time') | float %}
          {{t * 2.038788}}
        unit_of_measurement: "m³"

When looking at the actual values of these sensors, they appear to be correct. My issues are with the Energy tab. I configured the energy integration to show these values, however it doesn’t seem to be treating the gas sources as a total_increasing value. In fact, the energy tab is displaying numbers that don’t make any sense.


You can see that I have only used 16.04 m³ of gas, but the integration shows it at over 600 m³. Even if that were correct, the cost of that 600 m³ should be around $130, not $9.84.

I’m not sure what is going on here, I’ve tried everything from just about every forum post on this topic including using the utility_meter integration (that made things worse) and I’m stuck. Hopefully I can get some insight into this behavior.

I’m honestly offended that the gas consumption graph is giving me the bird.

Well I figured it out. The issue is with how the energy integration handles units.

The integration seems to think that the units for the gas consumption source is m³ (no matter what the actual units are) and then displays that value converted to ft³ on the energy tab. Even so, it uses the value before it does the conversion to do the cost calculation. ¯\_(ツ)_/¯

To get this to work properly, I used the values of the usage and cost in m³, however I had to set the units for the cost to USD/ft³ (even though the actual value was the cost in USD/m³).

I am going to submit a feature request about handling the units under energy management. Hopefully this can help someone else with this issue.