Tasmota gasmeter reader picked up in HA but immediately unavailable

Hi,

I’ve bought a Tasmota device to import our gas meter readings into HA, and I’m having troubles setting it up.

It gets autodiscovered in HA, but its sensor and all other attributes show up as unavailable immediately:

The contents of my configuration.yaml file:


homeassistant:
  packages: !include_dir_named packages 
  customize: !include customize.yaml
  
# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

template:
  - sensor:
    - name: "Gasmeter m3"
      unique_id: gaszaehler_m3
      state: "{{ states ('sensor.tasmota_counter_c1') | float * 0.01 }}"
      unit_of_measurement: "m³"
      icon: "mdi:gas-station"
      device_class: gas
      state_class: total_increasing
  - sensor:
    - name: "Gasmeter kWh"
      unique_id: gaszaehler_kwh
      state: "{{ (states ('sensor.gaszaehler_m3') | float(0) * 0.9533 * 10.3) | round(0) }}"
      unit_of_measurement: "kWh"
      icon: "mdi:gas-station"
      device_class: energy
      state_class: total_increasing

And the contents of my customize.yaml file:

# electricity sensors
sensor.tasmota_power_curr:
  device_class: power
  unit_of_measurement: 'W'
  state_class: measurement
  
sensor.tasmota_total_in:
  device_class: energy
  unit_of_measurement: 'kWh'
  state_class: total_increasing


# gas sensor
sensor.tasmota_counter_c1:
  device_class: gas
  unit_of_measurement: 'm3'
  state_class: total_increasing

Can anyone help? Thanks in advance!

The Tasmota device itself does read the gas meter correctly:

Found out I did not have the proper MQTT configuration in the Tasmota device. After I changed it to the following, I’m now receiving data in HA.

However, the counter sensor in HA does not show the right value. The displayed value should be divided by 100:

image

It displays as “171 m3” where it should be “1.71 m3”.

The template helper solves that for usage on the Energy dashboard, but it looks weird in the Tasmota integration.
Is there a way to fix that?

Never mind, I found it.

Since this is only a counter, I should’nt define it as a m3 gas sensor. Thus the issue was resolved when I removed the following from my customize.yaml:


# gas sensor
sensor.tasmota_counter_c1:
  device_class: gas
  unit_of_measurement: 'm3'
  state_class: total_increasing