I have an electricity meter that delivers the current electricity consumption and the total number of kWh via MQTT.
In Tasmota I see the units “kWh” and “W”.
Only the value is transmitted via MQTT, but not the unit.
In Home Assistant, the unit is usually recognized by the sensor (also works with my current measuring sockets).
BUT not with the electricity meter.
How can I teach Home Assistant that this is Watt “W” and kWh for the sensor???
Use customize.yaml
or a full sensor:
mqtt:
sensor:
- name: "EB1 Import"
unique_id: EB1_TotEneImp
state_topic: "tele/edpbox1/SENSOR"
value_template: >-
{% set x = value_json.EB1.TEI|float(0) %}
{% if x > 0 %}
{{ x }}
{% endif %}
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
As a example for the mentioned
Add the following to customize.yaml it completes the already existing sensor from the given example:
homeassistant:
customize:
sensor.power_leistung_akt:
unit_of_measurement: "W"
device_class: power
state_class: measurement
sensor.power_verbrauch:
unit_of_measurement: "kWh"
device_class: energy
state_class: total_increasing
1 Like