Energy Dashboard - Mitigate Huge Gas Reading Errors

Hello,

In my energy dashboard I have for the past 4 months been getting Gas spikes of typically 50,000 to 200,000 kWh every day screwing up my dashboard and stats. (this has escalated from the odd reading once in a blue moon).

I have tried to work out how to mitigate this but I am stumped.

My gas reading is via a MQTT feed;

  - state_topic: "SMART/HILD/[REDACTED]"
    name: "Home Gas"
    unit_of_measurement: "kWh"
    value_template: "{{ value_json['gasMtr']['0702']['00']['00']|int(base=16) * value_json['gasMtr']['0702']['03']['01']|int(base=16) / value_json['gasMtr']['0702']['03']['02']|int(base=16) }}"
    icon: "mdi:flash"
    device_class: energy
    state_class: 'total_increasing'

This then feeds into a Utility Meter Integration which is used by the dashboard.

MQTT sensor feed.

Utility Meter Reading

Energy Dashboard

I believe I need to add to the MQTT sensor that an unavailable state doesn’t render a 0 rating, but given some of the readings have only dropped from 50,000 to 20,000 I am not sure if this is correct?

I did have:

    availability: >
          {{ states('sensor.Home_Gas') not in ['unknown', 'unavailable', 'None'] }}

On the MQTT sensor but this wasn’t working.

Any help appreciated.