Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for frozen entity_description in 2024.1 #105

Merged
merged 1 commit into from
Dec 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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