pnbruckner / ha-sun2

Home Assistant Sun2 Sensor
The Unlicense
236 stars 22 forks source link

Fix display of period-of-time sensors w/ HA 2024.2 #110

Closed pnbruckner closed 9 months ago

pnbruckner commented 9 months ago

Starting in HA 2024.2, the frontend no longer displays sensors with a duration device_class as HH:MM:SS if the entity has a suggested_display_precision set, or the user has manually set a display_precision for the entity.

Previously, the period-of-time sensors (daylight/night) had a suggested_display_precision of 3. This change removes that setting.

Unfortunately, there's a bug in the sensor component that doesn't properly remove suggested_display_precision from the entity registry. Therefore, this change also forcibly removes it from the registry if necessary.

Also, add a state_class of measurment to period-of-time sensors (which was not possible for duration sensors in much older HA versions.)

Fixes #109.