- name: 'Total Gas Used kWh'
state: "{{ state_attr('sensor.geo_energy_usage_total','totalConsumptionList') | selectattr('commodityType', 'equalto', 'GAS_ENERGY') | map(attribute='totalConsumption') | first/1000*11.36267 | round(2) if is_state('sensor.geo_energy_usage_total','guid') else 'unknown' }}"
unit_of_measurement: "kWh"
device_class: energy
state_class: total
Note that this is quite specific to the sensor I was using which was sensor.geo_energy_usage_total
and had the data stored in an array attribute. However you get the m3 value you need to use /1000*11.36267 | round(2)
to convert it to kWh and round it to 2 decimal places.
I’m now using the Geo Energy integration which does all this internally.