changed host device_tracker from dhcp to host data point

This commit is contained in:
tomaae 2020-04-08 09:44:00 +02:00
parent a9c0be0b2c
commit e4e128ab4b

View file

@ -37,11 +37,10 @@ DEVICE_ATTRIBUTES_IFACE = [
] ]
DEVICE_ATTRIBUTES_HOST = [ DEVICE_ATTRIBUTES_HOST = [
"host-name", "hostname",
"address", "address",
"mac-address", "mac-address",
"interface", "interface",
"status",
"last-seen", "last-seen",
] ]
@ -91,7 +90,7 @@ def update_items(inst, mikrotik_controller, async_add_entities, tracked):
# Add switches # Add switches
for sid, sid_uid, sid_func in zip( for sid, sid_uid, sid_func in zip(
["interface", "dhcp"], ["interface", "host"],
["default-name", "mac-address"], ["default-name", "mac-address"],
[ [
MikrotikControllerPortDeviceTracker, MikrotikControllerPortDeviceTracker,
@ -218,7 +217,7 @@ class MikrotikControllerHostDeviceTracker(ScannerEntity):
"""Set up tracked port.""" """Set up tracked port."""
self._inst = inst self._inst = inst
self._ctrl = mikrotik_controller self._ctrl = mikrotik_controller
self._data = mikrotik_controller.data["dhcp"][uid] self._data = mikrotik_controller.data["host"][uid]
self._attrs = { self._attrs = {
ATTR_ATTRIBUTION: ATTRIBUTION, ATTR_ATTRIBUTION: ATTRIBUTION,
@ -234,7 +233,7 @@ class MikrotikControllerHostDeviceTracker(ScannerEntity):
_LOGGER.debug( _LOGGER.debug(
"New host tracker %s (%s - %s)", "New host tracker %s (%s - %s)",
self._inst, self._inst,
self._data["host-name"], self._data["hostname"],
self._data["mac-address"], self._data["mac-address"],
) )
@ -254,7 +253,7 @@ class MikrotikControllerHostDeviceTracker(ScannerEntity):
@property @property
def name(self): def name(self):
"""Return the name of the host.""" """Return the name of the host."""
return f"{self._inst} {self._data['host-name']}" return f"{self._data['hostname']}"
@property @property
def unique_id(self): def unique_id(self):