Fixed entity names

This commit is contained in:
Tomaae 2023-09-12 11:49:27 +02:00
parent 2349584551
commit d3a2432eb7
No known key found for this signature in database
GPG key ID: 2F97770867DAA4E6

View file

@ -174,6 +174,8 @@ class MikrotikEntity(CoordinatorEntity[_MikrotikCoordinatorT], Entity):
if self._uid: if self._uid:
self._data = coordinator.data[self.entity_description.data_path][self._uid] self._data = coordinator.data[self.entity_description.data_path][self._uid]
self._attr_name = self.custom_name
@callback @callback
def _handle_coordinator_update(self) -> None: def _handle_coordinator_update(self) -> None:
self._data = self.coordinator.data[self.entity_description.data_path] self._data = self.coordinator.data[self.entity_description.data_path]
@ -184,7 +186,7 @@ class MikrotikEntity(CoordinatorEntity[_MikrotikCoordinatorT], Entity):
super()._handle_coordinator_update() super()._handle_coordinator_update()
@property @property
def name(self) -> str: def custom_name(self) -> str:
"""Return the name for this entity""" """Return the name for this entity"""
if not self._uid: if not self._uid:
if self.entity_description.data_name_comment and self._data["comment"]: if self.entity_description.data_name_comment and self._data["comment"]: