show mikrotik model name on integration screen

append device name in front of entities
This commit is contained in:
tomaae 2019-12-03 18:28:22 +01:00
parent f95e87ed32
commit 3289c57b7a
2 changed files with 4 additions and 5 deletions

View file

@ -126,7 +126,7 @@ class MikrotikControllerPortDeviceTracker(ScannerEntity):
@property @property
def name(self) -> str: def name(self) -> str:
"""Return the name of the port.""" """Return the name of the port."""
return self.mikrotik_controller.data['interface'][self._uid]['default-name'] return f"{self._name} {self.mikrotik_controller.data['interface'][self._uid]['default-name']}"
@property @property
def unique_id(self) -> str: def unique_id(self) -> str:
@ -157,7 +157,7 @@ class MikrotikControllerPortDeviceTracker(ScannerEntity):
info = { info = {
"connections": {(CONNECTION_NETWORK_MAC, self.mikrotik_controller.data['interface'][self._uid]['port-mac-address'])}, "connections": {(CONNECTION_NETWORK_MAC, self.mikrotik_controller.data['interface'][self._uid]['port-mac-address'])},
"manufacturer": self.mikrotik_controller.data['resource']['platform'], "manufacturer": self.mikrotik_controller.data['resource']['platform'],
"model": "Port", "model": self.mikrotik_controller.data['resource']['board-name'],
"name": self.mikrotik_controller.data['interface'][self._uid]['default-name'], "name": self.mikrotik_controller.data['interface'][self._uid]['default-name'],
} }
return info return info

View file

@ -108,7 +108,6 @@ class MikrotikControllerSensor(Entity):
def __init__(self, mikrotik_controller, name, kind, uid=''): def __init__(self, mikrotik_controller, name, kind, uid=''):
"""Initialize.""" """Initialize."""
self.mikrotik_controller = mikrotik_controller self.mikrotik_controller = mikrotik_controller
self.data = mikrotik_controller.data
self._name = name self._name = name
self.kind = kind self.kind = kind
self.uid = uid self.uid = uid
@ -172,9 +171,9 @@ class MikrotikControllerSensor(Entity):
def device_info(self): def device_info(self):
"""Return a port description for device registry.""" """Return a port description for device registry."""
info = { info = {
"identifiers": {(DOMAIN, "serial-number", self.data['routerboard']['serial-number'])}, "identifiers": {(DOMAIN, "serial-number", self.mikrotik_controller.data['routerboard']['serial-number'], "switch", "PORT")},
"manufacturer": self.mikrotik_controller.data['resource']['platform'], "manufacturer": self.mikrotik_controller.data['resource']['platform'],
"model": SENSOR_TYPES[self.kind]['group'], "model": self.mikrotik_controller.data['resource']['board-name'],
"name": SENSOR_TYPES[self.kind]['group'], "name": SENSOR_TYPES[self.kind]['group'],
} }
return info return info