From 22735e5a7fb81380f2e81887ae9cc0db0d6f6f7c Mon Sep 17 00:00:00 2001 From: Phil Bruckner Date: Tue, 26 Dec 2023 07:47:54 -0600 Subject: [PATCH] Fix for frozen entity_description in 2024.1 (#105) --- custom_components/sun2/sensor.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/custom_components/sun2/sensor.py b/custom_components/sun2/sensor.py index ba31a45..c413db3 100644 --- a/custom_components/sun2/sensor.py +++ b/custom_components/sun2/sensor.py @@ -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))