Changed device_class in ESPHome not reflected in HA

I have asked ESPHome developers to add the device class ‘apparent_power’ so that unit of measurement VA is correctly recognized in HA. https://github.com/esphome/issues/issues/3405
Fix has been done and therefore I have modified my yaml file for the ESPHome component and changed the device class from power to apparent_power. In the log file the correct device class is sent to HA

But now if I look to this entity with developper tools I see:

So it seems that the device_class has not been updated to its new value ?
And if I look at statistics I am still getting this error


I have also looked at the database and the entity does not show up in statistic_meta!

I have tried to reload the ESPHome integration, I have restarted HA but nothing works to change the device_class!

Any idea what I should do to fix this problem ?

Even more strange!

I have 4 sensors that return apparent power. 3 of them got updated but one not ???

and in statistics 3 with no issue and one stuck with error

Maybe I can remove the ESPHome device and integrate it again but I will loose all my entities customizations

It would need state_class: measurement for that.

Try removing the device, restart and add it again.

Yes this will probably work but the device has 35 entities and all of them are customized so I will need to reenter all the information. Not fun :frowning:
What strange is why it worked for 3 of them?

I tested on another instance of HA reading data from the same ESPHome devices and in this instance everything got updated correctly!

I will probably do what you says. It is maybe because some data are stuck in the DB ???

Thanks for advice.
I fixed the problem as follow (this may help others?):

In ESPHome I removed the problematic sensor recompiled. After that the removed sensor was declared as not available in HA but I could not remove it. So I restarted HA and this time I was able to remove it.
Then I put back the sensor in ESPHome recompiled … and voilà the device was now displayed with the correct device_class

Also in case you missed it, you need this for Long Term Statistics:

You need to reload the integration esphome for that device.

Go to integration and use reload ( in the 3 dots next to configure)