Skip to content

Commit

Permalink
Fix for frozen entity_description in 2024.1 (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
pnbruckner authored Dec 26, 2023
1 parent a623446 commit 22735e5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions custom_components/sun2/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,19 @@ def __init__(
) -> None:
"""Initialize sensor."""
key = entity_description.key
if name is None:
name = key.replace("_", " ").title()
if isinstance(extra, Sun2EntityParams):
entity_description.entity_registry_enabled_default = key in _ENABLED_SENSORS
if name:
self._attr_name = name
self._attr_entity_registry_enabled_default = key in _ENABLED_SENSORS
else:
if name is None:
name = key.replace("_", " ").title()
# Note that entity_platform will add namespace prefix to object ID.
self.entity_id = f"{SENSOR_DOMAIN}.{slugify(name)}"
if extra:
name = f"{extra} {name}"
extra = None
entity_description.name = name
self._attr_name = name
self.entity_description = entity_description
super().__init__(loc_params, cast(Sun2EntityParams | None, extra))

Expand Down

0 comments on commit 22735e5

Please sign in to comment.