Energy monitoring problem - help please

I am following this guide to add gas monitoring capability to my HASS installation and have a problem that is driving me crazy as I can’t figure out what I’m doing wrong so any help would be appreciated.

My configuration entries are:

configuration.yaml:

sensor:
# For the gas usage sensor
  - platform: template
    sensors:
      gas_meter:
        friendly_name: Gas Meter
        unit_of_measurement: "m³"
        icon_template: "mdi:fire"
        device_class: gas
        value_template: "{{ states ('counter.gas_counter') | float(0) * 0.01}}"

The automation.yaml:

- alias: Gas Counting
# see https://community.home-assistant.io/t/gas-meter-from-xiaomi-aqara-door-sensor-zigbee/348032
#  description: ''
  mode: single
  trigger:
    - platform: state
      entity_id: binary_sensor.gas_sensor_aqara
      from: 'off'
      to: 'on'
#  condition: []
  action:
    - service: counter.increment
      target:
        entity_id: counter.gas_counter

Customize.yaml:

sensor.gas_meter:
#  device_class: energy
  state_class: measurement
  last_reset: '2021-08-20T06:43:36.740703+00:00'

The energy setting for gas is:

The Gas Meter counter is incrementing:
image

And the problem is that the m3 is not showing but cost is being attributed:

What am I doing wrong, please?

Thanks.

Richard

You need to add this to your sensor:

 state_class: total_increasing

The legacy template sensor platform does not support this. So either use Customize or use the template integration.

Thank you so much, @tom_l - adding that to customize.yaml sorted it.

Hi
Just a question on this regarding the cost per m3.

I am trying to work out how to convert the pence per kwh hour to m3.
My bill only shows the m3 units used and the pp kwh.
It doesn’t show pp m3.
Thanks

Your energy company should be able to provide you with the specifics for your meter. This is mine: image

Oh, forgot to say that the calorific value changes with the seasons (temperature related).

Thanks. Yes I see that :+1:t2: