Add dhcp discovery properties to mikrotik (#45205)
This commit is contained in:
parent
1454349813
commit
11cbf1152d
3 changed files with 26 additions and 0 deletions
|
@ -93,6 +93,21 @@ class MikrotikHubTracker(ScannerEntity):
|
|||
"""Return the name of the client."""
|
||||
return self.device.name
|
||||
|
||||
@property
|
||||
def hostname(self) -> str:
|
||||
"""Return the hostname of the client."""
|
||||
return self.device.name
|
||||
|
||||
@property
|
||||
def mac_address(self) -> str:
|
||||
"""Return the mac address of the client."""
|
||||
return self.device.mac
|
||||
|
||||
@property
|
||||
def ip_address(self) -> str:
|
||||
"""Return the mac address of the client."""
|
||||
return self.device.ip_address
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str:
|
||||
"""Return a unique identifier for this device."""
|
||||
|
|
|
@ -54,6 +54,11 @@ class Device:
|
|||
"""Return device name."""
|
||||
return self._params.get("host-name", self.mac)
|
||||
|
||||
@property
|
||||
def ip_address(self):
|
||||
"""Return device primary ip address."""
|
||||
return self._params.get("address")
|
||||
|
||||
@property
|
||||
def mac(self):
|
||||
"""Return device mac."""
|
||||
|
|
|
@ -48,6 +48,9 @@ async def test_device_trackers(hass, legacy_patchable_time):
|
|||
device_1 = hass.states.get("device_tracker.device_1")
|
||||
assert device_1 is not None
|
||||
assert device_1.state == "home"
|
||||
assert device_1.attributes["ip"] == "0.0.0.1"
|
||||
assert device_1.attributes["mac"] == "00:00:00:00:00:01"
|
||||
assert device_1.attributes["host_name"] == "Device_1"
|
||||
device_2 = hass.states.get("device_tracker.device_2")
|
||||
assert device_2 is None
|
||||
|
||||
|
@ -61,6 +64,9 @@ async def test_device_trackers(hass, legacy_patchable_time):
|
|||
device_2 = hass.states.get("device_tracker.device_2")
|
||||
assert device_2 is not None
|
||||
assert device_2.state == "home"
|
||||
assert device_2.attributes["ip"] == "0.0.0.2"
|
||||
assert device_2.attributes["mac"] == "00:00:00:00:00:02"
|
||||
assert device_2.attributes["host_name"] == "Device_2"
|
||||
|
||||
# test state remains home if last_seen consider_home_interval
|
||||
del WIRELESS_DATA[1] # device 2 is removed from wireless list
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue