added description variable to prioritize entry comment over name

This commit is contained in:
Tomaae 2022-02-04 20:33:54 +01:00
parent 89d2dc9513
commit 18f2e56691
2 changed files with 6 additions and 0 deletions

View file

@ -279,6 +279,11 @@ class MikrotikControllerSwitch(SwitchEntity, RestoreEntity):
@property @property
def name(self) -> str: def name(self) -> str:
"""Return the name.""" """Return the name."""
if self.entity_description.data_name_comment and self._data["comment"]:
return (
f"{self._inst} {self.entity_description.name} {self._data['comment']}"
)
return f"{self._inst} {self.entity_description.name} {self._data[self.entity_description.data_name]}" return f"{self._inst} {self.entity_description.name} {self._data[self.entity_description.data_name]}"
@property @property

View file

@ -152,6 +152,7 @@ class MikrotikSwitchEntityDescription(SwitchEntityDescription):
data_switch_path: str = "" data_switch_path: str = ""
data_switch_parameter: str = "disabled" data_switch_parameter: str = "disabled"
data_name: str = "" data_name: str = ""
data_name_comment: bool = False
data_uid: str = "" data_uid: str = ""
data_reference: str = "" data_reference: str = ""
data_attributes_list: List = field(default_factory=lambda: []) data_attributes_list: List = field(default_factory=lambda: [])