Set has_entity_name in freedompro (#94603)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Erik Montnemery 2023-06-14 21:42:51 +02:00 committed by GitHub
parent c48afebbfc
commit fa9c31d3db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 31 additions and 16 deletions

View file

@ -54,12 +54,14 @@ async def async_setup_entry(
class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SensorEntity):
"""Representation of an Freedompro sensor."""
_attr_has_entity_name = True
_attr_name = None
def __init__(
self, device: dict[str, Any], coordinator: FreedomproDataUpdateCoordinator
) -> None:
"""Initialize the Freedompro sensor."""
super().__init__(coordinator)
self._attr_name = device["name"]
self._attr_unique_id = device["uid"]
self._type = device["type"]
self._attr_device_info = DeviceInfo(
@ -68,7 +70,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SensorEntity):
},
manufacturer="Freedompro",
model=device["type"],
name=self.name,
name=device["name"],
)
self._attr_device_class = DEVICE_CLASS_MAP[device["type"]]
self._attr_state_class = STATE_CLASS_MAP[device["type"]]