[Solved] Unit_of_measurement for integration sensor not showing

Hello everyone.
I created a “platform: template” sensor that reads power in W from a custom made power board:

sensor:
  - platform: template
    sensors:

      casa_eletricidade_potencia_solar:
        friendly_name_template: Produção solar
        unique_id: 3
        icon_template: mdi:white-balance-sunny
        value_template: >-
          {% if (states('sensor.active_power_1')|int) < 40 %}
            {{0}}
          {% else %}
            {{ (states('sensor.active_power_1')|int) }}
          {% endif %}
        unit_of_measurement: "W"

Then, I created a “platform: integration” sensor that integrates that power to calculate energy in kWh.

  - platform: integration
    name: casa_eletricidade_energia_solar
    source: sensor.casa_eletricidade_potencia_solar
    unit_prefix: k
    round: 10
    method: left

My problem is that there is no unit for this energy sensor, despite others sensors, created exactly in the same way, do have unit.

HA

As the image shows, the problem also happens for other sensors.

What am I doing wrong?

Thank you very much in advance. :slight_smile:

Hi there, we should be able to add the parameter unit like below.

  - platform: integration
    name: casa_eletricidade_energia_solar
    source: sensor.casa_eletricidade_potencia_solar
    unit_prefix: k
    round: 10
    method: left
    unit: kWh

Please try it

Hi Sheminasalam,
Thank you for the reply. Home Assistant is strange. I did nothing and the unit appears. I suppose HA needed time for something. Nevertheless, I will keep your suggestion if this situation occurs in the future again.
Best regards!

1 Like