Adding units of measurement in 2021.12

Hello,

im reading out my smart meter with tasmota sending its data to HASS over mqtt.
The values are shown in homeassistant as normal but the units of measurement are missing.
Without these units, i cant use the energy tab.

grafik

If you are configuring the sensors using YAML just add the unit_of_measurement there.

If the sensors are discovered, and you can’t specify this in Tasmota, then use customize to add a unit_of_measurement.

I tried this in my configuration.yaml but that didnt change anything:

customize:
    sensor.tasmota_zaehler_leistung:
       unit_of_measurement: "W"
    sensor.tasmota_zaehler_einspeisung:
        unit_of_measurement: "kWh"
    sensor.tasmota_zaehler_verbrauch:
           unit_of_measurement: "kWh"

Your indentation is all over the place. And customize: goes under homeassistant: look at the examples.

Thank you.
Just to be right, the device classes are right for each sensor?

homeassistant:
    customize:
        sensor.tasmota_zaehler_leistung:
            unit_of_measurement: "W"
            device_class: power
            state_class: measurement
        sensor.tasmota_zaehler_einspeisung:
            unit_of_measurement: "kWh"
            device_class: energy
            state_class: total
        sensor.tasmota_zaehler_verbrauch:
            unit_of_measurement: "kWh"
            device_class: energy
            state_class: total

Not quite:

homeassistant:
  customize:
    sensor.tasmota_zaehler_leistung:
      unit_of_measurement: "W"
      device_class: power
      state_class: measurement
    sensor.tasmota_zaehler_einspeisung:
      unit_of_measurement: "kWh"
      device_class: energy
      state_class: total_increasing
    sensor.tasmota_zaehler_verbrauch:
      unit_of_measurement: "kWh"
      device_class: energy
      state_class: total_increasing

But if i understand total_increasing right,
if the old value is 1000 it gets to 0 and then after that again to 1000 the shown value is 2000 right?
Because if the reader of the smart meter loses connection to the meter the values get 0.

If i use total, i dont have this problem right?

I used total_increasing so you could use them in the energy dashboard. If that is not needed then sure, use total. It would be better to fix your sensor to report unavailable rather than 0, as energy should be a monotonically increasing number.

Hello, I’m trying to do the same thing. I added the code to configuration.yaml but it does not work.
Moreover, when I add those lines, homeassistant does not load all integrations and even freezes or crashes. The sensor is a tasmota mqtt configured via GUI.
Any ideas?

homeassistant:
  customize:
    sensor.tasmota_total_in
      unit_of_measurement: "kWh"
      device_class: energy
      state_class: total_increasing

homeassistant:
  customize:
    sensor.tasmota_total_in:
      unit_of_measurement: "kWh"
      device_class: energy
      state_class: total_increasing

you ve forgotten the „ : “ after the Sensor

1 Like