diff --git a/custom_components/mikrotik_router/device_tracker.py b/custom_components/mikrotik_router/device_tracker.py index 7bc7ddb..f60bc72 100644 --- a/custom_components/mikrotik_router/device_tracker.py +++ b/custom_components/mikrotik_router/device_tracker.py @@ -34,6 +34,14 @@ DEVICE_ATTRIBUTES = [ "default-name", ] +def format_attribute(attr): + res = attr.replace("-", " ") + res = res.capitalize() + res = res.replace(" ip ", " IP ") + res = res.replace(" mac ", " MAC ") + res = res.replace(" mtu", " MTU") + return res + # --------------------------- # async_setup_entry @@ -168,6 +176,6 @@ class MikrotikControllerPortDeviceTracker(ScannerEntity): for variable in DEVICE_ATTRIBUTES: if variable in self._data: - attributes[variable] = self._data[variable] + attributes[format_attribute(variable)] = self._data[variable] return attributes diff --git a/custom_components/mikrotik_router/switch.py b/custom_components/mikrotik_router/switch.py index 20b7fc3..6bb10ac 100644 --- a/custom_components/mikrotik_router/switch.py +++ b/custom_components/mikrotik_router/switch.py @@ -55,6 +55,14 @@ DEVICE_ATTRIBUTES_SCRIPT = [ "run-count", ] +def format_attribute(attr): + res = attr.replace("-", " ") + res = res.capitalize() + res = res.replace(" ip ", " IP ") + res = res.replace(" mac ", " MAC ") + res = res.replace(" mtu", " MTU") + return res + # --------------------------- # async_setup_entry @@ -200,7 +208,7 @@ class MikrotikControllerPortSwitch(MikrotikControllerSwitch): for variable in DEVICE_ATTRIBUTES_IFACE: if variable in self._data: - attributes[variable] = self._data[variable] + attributes[format_attribute(variable)] = self._data[variable] return attributes @@ -290,7 +298,7 @@ class MikrotikControllerNATSwitch(MikrotikControllerSwitch): for variable in DEVICE_ATTRIBUTES_NAT: if variable in self._data: - attributes[variable] = self._data[variable] + attributes[format_attribute(variable)] = self._data[variable] return attributes @@ -375,7 +383,7 @@ class MikrotikControllerScriptSwitch(MikrotikControllerSwitch): for variable in DEVICE_ATTRIBUTES_SCRIPT: if variable in self._data: - attributes[variable] = self._data[variable] + attributes[format_attribute(variable)] = self._data[variable] return attributes