I upgraded my gas meter with a reed contact recently and get correct reading for the impulses. The meter readings are reported to HA through mqtt and are calculated in a template sensor to volume in [m³] . This works all fine so far.
- sensor:
# Berechnet den Zählerstand der Gasuhr in m³
- name: Zählerstand Gasuhr
unique_id: "ZaehlerstandGasuhr"
unit_of_measurement: 'm³'
device_class: "gas"
state_class: "total_increasing"
state: >-
{{ (float(states('sensor.gasuhr_counter_c1')))/100}}```
I created same input number helpers for the gas-condition-number and for the gas-heat-value. The gas-heat-value has got the unit [kWh/m³] . the gas-condition-number is free of units.
Then I created a template sensor to calculate the gas usage in kWh.
- sensor:
Berechnet den Gasverbrauch in kWh
- name: Gasverbrauch
unique_id: "Gasverbrauch"
unit_of_measurement: 'kWh'
device_class: "gas"
state_class: "total_increasing"
state: >-
{{ ((float(states('sensor.zahlerstand_gasuhr')))(float(states('input_number.gas_zustandszahl')))(float(states('input_number.brennwert_gas')))) | round(2) }}
- name: Gasverbrauch
Here the unit of measurement is [kWh]. But when I put this number into my energy dashbord, I get an error message regarding an unexpectes unit.
The entity used has not an expected unit. It should be (....,mWh,Wh,kWh,MWh,...) but it is kWh. ???
I am confused here. I can not see my mistake.
It would be geatly appreciated if anybody could help me.
Kindest regards,
Poppa