This commit is contained in:
Tomaae 2023-08-10 02:21:16 +02:00
parent 9c5a270b4f
commit e1e9f61e08
No known key found for this signature in database
GPG key ID: 2F97770867DAA4E6
2 changed files with 28 additions and 32 deletions

View file

@ -2090,10 +2090,9 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
self.ds["host"][uid]["bypassed"] = self.ds["hostspot_host"][uid][
"bypassed"
]
else:
if "authorized" in self.ds["host"][uid]:
del self.ds["host"][uid]["authorized"]
del self.ds["host"][uid]["bypassed"]
elif "authorized" in self.ds["host"][uid]:
del self.ds["host"][uid]["authorized"]
del self.ds["host"][uid]["bypassed"]
# CAPS-MAN availability
if vals["source"] == "capsman" and uid not in capsman_detected:
@ -2152,29 +2151,28 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
].split(".")[0]
break
# Resolve hostname from DHCP comment
if (
self.ds["host"][uid]["host-name"] == "unknown"
and uid in self.ds["dhcp"]
and self.ds["dhcp"][uid]["enabled"]
and self.ds["dhcp"][uid]["comment"].split("#", 1)[0] != ""
):
self.ds["host"][uid]["host-name"] = self.ds["dhcp"][uid][
"comment"
].split("#", 1)[0]
# Resolve hostname from DHCP hostname
elif (
self.ds["host"][uid]["host-name"] == "unknown"
and uid in self.ds["dhcp"]
and self.ds["dhcp"][uid]["enabled"]
and self.ds["dhcp"][uid]["host-name"] != "unknown"
):
self.ds["host"][uid]["host-name"] = self.ds["dhcp"][uid][
"host-name"
]
# Fallback to mac address for hostname
elif self.ds["host"][uid]["host-name"] == "unknown":
self.ds["host"][uid]["host-name"] = uid
if self.ds["host"][uid]["host-name"] == "unknown":
# Resolve hostname from DHCP comment
if (
uid in self.ds["dhcp"]
and self.ds["dhcp"][uid]["enabled"]
and self.ds["dhcp"][uid]["comment"].split("#", 1)[0] != ""
):
self.ds["host"][uid]["host-name"] = self.ds["dhcp"][uid][
"comment"
].split("#", 1)[0]
# Resolve hostname from DHCP hostname
elif (
uid in self.ds["dhcp"]
and self.ds["dhcp"][uid]["enabled"]
and self.ds["dhcp"][uid]["host-name"] != "unknown"
):
self.ds["host"][uid]["host-name"] = self.ds["dhcp"][uid][
"host-name"
]
# Fallback to mac address for hostname
else:
self.ds["host"][uid]["host-name"] = uid
# Resolve manufacturer
if vals["manufacturer"] == "detect" and vals["mac-address"] != "unknown":

View file

@ -245,7 +245,7 @@ class MikrotikEntity(CoordinatorEntity[_MikrotikCoordinatorT], Entity):
dev_connection_value = self._data[dev_connection_value]
if self.entity_description.ha_group == "System":
info = DeviceInfo(
return DeviceInfo(
connections={(dev_connection, f"{dev_connection_value}")},
identifiers={(dev_connection, f"{dev_connection_value}")},
name=f"{self._inst} {dev_group}",
@ -265,7 +265,7 @@ class MikrotikEntity(CoordinatorEntity[_MikrotikCoordinatorT], Entity):
"manufacturer"
]
info = DeviceInfo(
return DeviceInfo(
connections={(dev_connection, f"{dev_connection_value}")},
default_name=f"{dev_group}",
default_manufacturer=f"{dev_manufacturer}",
@ -275,7 +275,7 @@ class MikrotikEntity(CoordinatorEntity[_MikrotikCoordinatorT], Entity):
),
)
else:
info = DeviceInfo(
return DeviceInfo(
connections={(dev_connection, f"{dev_connection_value}")},
default_name=f"{self._inst} {dev_group}",
default_model=f"{self.coordinator.data['resource']['board-name']}",
@ -286,8 +286,6 @@ class MikrotikEntity(CoordinatorEntity[_MikrotikCoordinatorT], Entity):
),
)
return info
@property
def extra_state_attributes(self) -> Mapping[str, Any]:
"""Return the state attributes."""