Fixed device tracker names

This commit is contained in:
Tomaae 2023-09-12 12:00:42 +02:00
parent d3a2432eb7
commit 6079affcfa
No known key found for this signature in database
GPG key ID: 2F97770867DAA4E6
2 changed files with 12 additions and 5 deletions

View file

@ -22,6 +22,7 @@ from homeassistant.util.dt import utcnow
from homeassistant.components.device_tracker.const import SourceType from homeassistant.components.device_tracker.const import SourceType
from .device_tracker_types import SENSOR_TYPES, SENSOR_SERVICES from .device_tracker_types import SENSOR_TYPES, SENSOR_SERVICES
from .coordinator import MikrotikCoordinator
from .entity import _skip_sensor, MikrotikEntity from .entity import _skip_sensor, MikrotikEntity
from .helper import format_attribute from .helper import format_attribute
from .const import ( from .const import (
@ -118,6 +119,16 @@ async def async_setup_entry(
class MikrotikDeviceTracker(MikrotikEntity, ScannerEntity): class MikrotikDeviceTracker(MikrotikEntity, ScannerEntity):
"""Representation of a device tracker.""" """Representation of a device tracker."""
def __init__(
self,
coordinator: MikrotikCoordinator,
entity_description,
uid: str | None = None,
):
"""Initialize entity"""
super().__init__(coordinator, entity_description, uid)
self._attr_name = None
@property @property
def ip_address(self) -> str: def ip_address(self) -> str:
"""Return the primary ip address of the device.""" """Return the primary ip address of the device."""
@ -169,11 +180,6 @@ class MikrotikHostDeviceTracker(MikrotikDeviceTracker):
) )
return timedelta(seconds=track_network_hosts_timeout) return timedelta(seconds=track_network_hosts_timeout)
@property
def name(self) -> Any:
"""Return the name."""
return None
@property @property
def is_connected(self) -> bool: def is_connected(self) -> bool:
"""Return true if the host is connected to the network.""" """Return true if the host is connected to the network."""

View file

@ -33,6 +33,7 @@ class MikrotikDeviceTrackerEntityDescription(SwitchEntityDescription):
data_path: str | None = None data_path: str | None = None
data_attribute: str = "available" data_attribute: str = "available"
data_name: str | None = None data_name: str | None = None
data_name_comment: bool = False
data_uid: str | None = None data_uid: str | None = None
data_reference: str | None = None data_reference: str | None = None
data_attributes_list: List = field(default_factory=lambda: []) data_attributes_list: List = field(default_factory=lambda: [])