Added status, rate, duplex and negotiation status to ethernet ports #146

This commit is contained in:
tomaae 2021-12-15 23:07:11 +01:00
parent 052c1f1e7d
commit b04a0a5b26
3 changed files with 105 additions and 41 deletions

View file

@ -60,6 +60,25 @@ DEVICE_ATTRIBUTES_IFACE = [
"actual-mtu",
"type",
"name",
]
DEVICE_ATTRIBUTES_IFACE_ETHER = [
"running",
"enabled",
"comment",
"client-ip-address",
"client-mac-address",
"port-mac-address",
"last-link-down-time",
"last-link-up-time",
"link-downs",
"actual-mtu",
"type",
"name",
"status",
"auto-negotiation",
"rate",
"full-duplex",
"default-name",
"poe-out",
]
@ -476,12 +495,19 @@ class MikrotikControllerPortBinarySensor(MikrotikControllerBinarySensor):
def extra_state_attributes(self) -> Dict[str, Any]:
"""Return the state attributes."""
attributes = self._attrs
for variable in DEVICE_ATTRIBUTES_IFACE:
if variable in self._data:
attributes[format_attribute(variable)] = self._data[variable]
if "sfp-shutdown-temperature" in self._data:
for variable in DEVICE_ATTRIBUTES_IFACE_SFP:
if self._data["type"] == "ether":
for variable in DEVICE_ATTRIBUTES_IFACE_ETHER:
if variable in self._data:
attributes[format_attribute(variable)] = self._data[variable]
if "sfp-shutdown-temperature" in self._data:
for variable in DEVICE_ATTRIBUTES_IFACE_SFP:
if variable in self._data:
attributes[format_attribute(variable)] = self._data[variable]
else:
for variable in self._sid_data["sid_attr"]:
if variable in self._data:
attributes[format_attribute(variable)] = self._data[variable]