added support for overriding zone name in device_tracker

This commit is contained in:
ddanssaert 2021-12-16 22:45:29 +01:00
parent 6129e18cc3
commit 873d18e60a
4 changed files with 32 additions and 1 deletions

View file

@ -9,6 +9,7 @@ from homeassistant.components.device_tracker.const import SOURCE_TYPE_ROUTER
from homeassistant.const import (
CONF_NAME,
ATTR_ATTRIBUTION,
STATE_NOT_HOME,
)
from homeassistant.core import callback
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
@ -300,6 +301,13 @@ class MikrotikControllerHostDeviceTracker(MikrotikControllerDeviceTracker):
return "mdi:lan-connect"
return "mdi:lan-disconnect"
@property
def state(self) -> str:
"""Return the state of the device."""
if self.is_connected:
return self._ctrl.option_zone
return STATE_NOT_HOME
@property
def extra_state_attributes(self) -> Dict[str, Any]:
"""Return the state attributes."""