diff --git a/custom_components/mikrotik_router/binary_sensor_types.py b/custom_components/mikrotik_router/binary_sensor_types.py index bab704c..d112b97 100644 --- a/custom_components/mikrotik_router/binary_sensor_types.py +++ b/custom_components/mikrotik_router/binary_sensor_types.py @@ -137,7 +137,7 @@ SENSOR_TYPES = { ), "interface": MikrotikBinarySensorEntityDescription( key="interface", - name="", + name="Connection", icon_enabled="mdi:lan-connect", icon_disabled="mdi:lan-pending", device_class=BinarySensorDeviceClass.CONNECTIVITY, @@ -146,7 +146,7 @@ SENSOR_TYPES = { ha_connection_value="data__port-mac-address", data_path="interface", data_attribute="running", - data_name="name", + data_name="default-name", data_uid="default-name", data_reference="default-name", data_attributes_list=DEVICE_ATTRIBUTES_IFACE, diff --git a/custom_components/mikrotik_router/device_tracker.py b/custom_components/mikrotik_router/device_tracker.py index 4920871..cdb49b0 100644 --- a/custom_components/mikrotik_router/device_tracker.py +++ b/custom_components/mikrotik_router/device_tracker.py @@ -99,7 +99,7 @@ class MikrotikHostDeviceTracker(MikrotikDeviceTracker): @property def name(self) -> str: """Return the name.""" - return f"{self._data[self.entity_description.data_name]}" + return "" @property def is_connected(self) -> bool: diff --git a/custom_components/mikrotik_router/model.py b/custom_components/mikrotik_router/model.py index 9d0cae5..533b4de 100644 --- a/custom_components/mikrotik_router/model.py +++ b/custom_components/mikrotik_router/model.py @@ -168,6 +168,8 @@ def model_update_items( class MikrotikEntity: """Define entity""" + _attr_has_entity_name = True + def __init__( self, inst, @@ -194,17 +196,23 @@ class MikrotikEntity: """Return the name for this entity""" if not self._uid: if self.entity_description.data_name_comment and self._data["comment"]: - return f"{self._inst} {self._data['comment']}" + return f"{self._data['comment']}" - return f"{self._inst} {self.entity_description.name}" + return f"{self.entity_description.name}" + + if self.entity_description.data_name_comment and self._data["comment"]: + return f"{self._data['comment']}" if self.entity_description.name: - if self.entity_description.data_name_comment and self._data["comment"]: - return f"{self._inst} {self.entity_description.name} {self._data['comment']}" + if ( + self._data[self.entity_description.data_reference] + == self._data[self.entity_description.data_name] + ): + return f"{self.entity_description.name}" - return f"{self._inst} {self._data[self.entity_description.data_name]} {self.entity_description.name}" + return f"{self._data[self.entity_description.data_name]} {self.entity_description.name}" - return f"{self._inst} {self._data[self.entity_description.data_name]}" + return f"{self._data[self.entity_description.data_name]}" @property def unique_id(self) -> str: diff --git a/custom_components/mikrotik_router/sensor.py b/custom_components/mikrotik_router/sensor.py index 221a371..d6786c7 100644 --- a/custom_components/mikrotik_router/sensor.py +++ b/custom_components/mikrotik_router/sensor.py @@ -98,7 +98,7 @@ class MikrotikClientTrafficSensor(MikrotikSensor): @property def name(self) -> str: """Return the name.""" - return f"{self._data[self.entity_description.data_name]} {self.entity_description.name}" + return f"{self.entity_description.name}" @property def available(self) -> bool: diff --git a/custom_components/mikrotik_router/sensor_types.py b/custom_components/mikrotik_router/sensor_types.py index f4dad8f..fd0e782 100644 --- a/custom_components/mikrotik_router/sensor_types.py +++ b/custom_components/mikrotik_router/sensor_types.py @@ -271,7 +271,7 @@ SENSOR_TYPES = { ), "system_clients-wired": MikrotikSensorEntityDescription( key="system_clients-wired", - name="Wired Clients", + name="Wired clients", icon="mdi:lan", native_unit_of_measurement=None, device_class=None, @@ -286,7 +286,7 @@ SENSOR_TYPES = { ), "system_clients-wireless": MikrotikSensorEntityDescription( key="system_clients-wireless", - name="Wireless Clients", + name="Wireless clients", icon="mdi:wifi", native_unit_of_measurement=None, device_class=None, @@ -301,7 +301,7 @@ SENSOR_TYPES = { ), "system_captive-authorized": MikrotikSensorEntityDescription( key="system_captive-authorized", - name="Captive Portal Clients", + name="Captive portal clients", icon="mdi:key-wireless", native_unit_of_measurement=None, device_class=None, @@ -316,7 +316,7 @@ SENSOR_TYPES = { ), "system_gps-latitude": MikrotikSensorEntityDescription( key="system_gps-latitude", - name="latitude", + name="Latitude", icon="mdi:latitude", native_unit_of_measurement=None, device_class=None, @@ -332,7 +332,7 @@ SENSOR_TYPES = { ), "system_gps-longitude": MikrotikSensorEntityDescription( key="system_gps-longitude", - name="longitude", + name="Longitude", icon="mdi:longitude", native_unit_of_measurement=None, device_class=None, @@ -359,7 +359,7 @@ SENSOR_TYPES = { ha_connection_value="data__port-mac-address", data_path="interface", data_attribute="tx", - data_name="name", + data_name="default-name", data_uid="", data_reference="default-name", data_attributes_list=DEVICE_ATTRIBUTES_IFACE, @@ -378,7 +378,7 @@ SENSOR_TYPES = { ha_connection_value="data__port-mac-address", data_path="interface", data_attribute="rx", - data_name="name", + data_name="default-name", data_uid="", data_reference="default-name", data_attributes_list=DEVICE_ATTRIBUTES_IFACE, @@ -397,7 +397,7 @@ SENSOR_TYPES = { ha_connection_value="data__port-mac-address", data_path="interface", data_attribute="tx-current", - data_name="name", + data_name="default-name", data_uid="", data_reference="default-name", data_attributes_list=DEVICE_ATTRIBUTES_IFACE, @@ -416,7 +416,7 @@ SENSOR_TYPES = { ha_connection_value="data__port-mac-address", data_path="interface", data_attribute="rx-current", - data_name="name", + data_name="default-name", data_uid="", data_reference="default-name", data_attributes_list=DEVICE_ATTRIBUTES_IFACE, diff --git a/custom_components/mikrotik_router/switch.py b/custom_components/mikrotik_router/switch.py index 52498cd..a9c72be 100644 --- a/custom_components/mikrotik_router/switch.py +++ b/custom_components/mikrotik_router/switch.py @@ -168,14 +168,6 @@ class MikrotikPortSwitch(MikrotikSwitch): class MikrotikNATSwitch(MikrotikSwitch): """Representation of a NAT switch.""" - @property - def name(self) -> str: - """Return the name.""" - if self._data["comment"]: - return f"{self._inst} NAT {self._data['comment']}" - - return f"{self._inst} NAT {self._data['name']}" - async def async_turn_on(self) -> None: """Turn on the switch.""" path = self.entity_description.data_switch_path diff --git a/custom_components/mikrotik_router/switch_types.py b/custom_components/mikrotik_router/switch_types.py index cca531d..75575a9 100644 --- a/custom_components/mikrotik_router/switch_types.py +++ b/custom_components/mikrotik_router/switch_types.py @@ -160,7 +160,7 @@ class MikrotikSwitchEntityDescription(SwitchEntityDescription): SENSOR_TYPES = { "interface": MikrotikSwitchEntityDescription( key="interface", - name="port", + name="Port", icon_enabled="mdi:lan-connect", icon_disabled="mdi:lan-pending", entity_category=None, @@ -169,7 +169,7 @@ SENSOR_TYPES = { ha_connection_value="data__port-mac-address", data_path="interface", data_switch_path="/interface", - data_name="name", + data_name="default-name", data_uid="name", data_reference="default-name", data_attributes_list=DEVICE_ATTRIBUTES_IFACE, @@ -177,7 +177,7 @@ SENSOR_TYPES = { ), "nat": MikrotikSwitchEntityDescription( key="nat", - name="NAT", + name="", icon_enabled="mdi:network-outline", icon_disabled="mdi:network-off-outline", entity_category=None, @@ -195,7 +195,7 @@ SENSOR_TYPES = { ), "mangle": MikrotikSwitchEntityDescription( key="mangle", - name="Mangle", + name="", icon_enabled="mdi:bookmark-outline", icon_disabled="mdi:bookmark-off-outline", entity_category=None, @@ -213,7 +213,7 @@ SENSOR_TYPES = { ), "filter": MikrotikSwitchEntityDescription( key="filter", - name="Filter", + name="", icon_enabled="mdi:filter-variant", icon_disabled="mdi:filter-variant-remove", entity_category=None, @@ -247,7 +247,7 @@ SENSOR_TYPES = { ), "queue": MikrotikSwitchEntityDescription( key="queue", - name="Queue", + name="", icon_enabled="mdi:leaf", icon_disabled="mdi:leaf-off", entity_category=None, @@ -264,7 +264,7 @@ SENSOR_TYPES = { ), "kidcontrol_enable": MikrotikSwitchEntityDescription( key="kidcontrol_enable", - name="kidcontrol", + name="", icon_enabled="mdi:account", icon_disabled="mdi:account-off", entity_category=None, @@ -280,7 +280,7 @@ SENSOR_TYPES = { ), "kidcontrol_pause": MikrotikSwitchEntityDescription( key="kidcontrol_paused", - name="kidcontrol paused", + name="paused", icon_enabled="mdi:account-outline", icon_disabled="mdi:account-off-outline", entity_category=None, diff --git a/custom_components/mikrotik_router/update_types.py b/custom_components/mikrotik_router/update_types.py index ed4d5d5..8ca9514 100644 --- a/custom_components/mikrotik_router/update_types.py +++ b/custom_components/mikrotik_router/update_types.py @@ -36,9 +36,9 @@ SENSOR_TYPES = { ), "system_rbfwupdate": MikrotikUpdateEntityDescription( key="system_rbfwupdate", - name="RouterBoard firmware update", + name="RouterBOARD firmware update", ha_group="System", - title="Mikrotik RouterBoard", + title="Mikrotik RouterBOARD", data_path="routerboard", data_attribute="current-firmware", data_name="",