Don't find my sensor on HA

Hello,

Actually, i am using a shelly to measure my electricity consumption. But, i want to show the power with the power factor.

So, i created this sensor, but i can’t find it on my interface.
I tried the dev tools and the result is ok.

template:
  - sensor:
    - name: "EDF Instantanée Réelle"
      unique_id: edf_power_real
      unit_of_measurement: 'W'
      state_class: measurement
      device_class: energy
      state:  >
        {% set edf_power = states('sensor.edf_power') | float %}
        {% set edf_pf = states('sensor.edf_power_factor') | float %}
        {% set edf_power_real = (edf_power * ( 100 / (100 - ( 1 + edf_pf ) * 100 )) )  | round(0, default=0) %}
        {% if edf_power_real > 0 %}
          {{ edf_power_real }}
        {% else %}
          0
        {% endif %}

I restart many time HA but i can’t find it in the entities menu.

Can you help me?

do you have an entry in your logs?

Does it have an entity in dev-tools/states?

1 Like

I have nothing.

Do you have

more then once in configuration.yaml ?

I take a look and i found nothing.

Then, i try anything. Until now, i am just using the quick reload configuration.
Now, i try the complete restart and i get this log:

Entity sensor.edf_instantanee_reelle (<class ‘homeassistant.components.template.sensor.SensorTemplate’>) is using native unit of measurement ‘W’ which is not a valid unit for the device class (‘energy’) it is using; expected one of [‘GJ’, ‘MWh’, ‘kWh’, ‘Wh’, ‘MJ’]; Please update your configuration if your entity is manually configured, otherwise create a bug report at Issues · home-assistant/core · GitHub

I deleted the line:
device_class: energy

And now, i can see my sensor on the interface.

1 Like

A step further, your device is actually of the class “power”, not “energy”. May not ultimately matter for your use-case, but change the device class to power.

Ok, i will modify this; Thx