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
def name(self) -> str:
"""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
def unique_id(self) -> str:
@ -157,7 +157,7 @@ class MikrotikControllerPortDeviceTracker(ScannerEntity):
info = {
"connections": {(CONNECTION_NETWORK_MAC, self.mikrotik_controller.data['interface'][self._uid]['port-mac-address'])},
"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'],
}
return info

View file

@ -108,7 +108,6 @@ class MikrotikControllerSensor(Entity):
def __init__(self, mikrotik_controller, name, kind, uid=''):
"""Initialize."""
self.mikrotik_controller = mikrotik_controller
self.data = mikrotik_controller.data
self._name = name
self.kind = kind
self.uid = uid
@ -172,9 +171,9 @@ class MikrotikControllerSensor(Entity):
def device_info(self):
"""Return a port description for device registry."""
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'],
"model": SENSOR_TYPES[self.kind]['group'],
"model": self.mikrotik_controller.data['resource']['board-name'],
"name": SENSOR_TYPES[self.kind]['group'],
}
return info