mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-08 00:14:31 +02:00
cleanup
This commit is contained in:
parent
9c5a270b4f
commit
e1e9f61e08
2 changed files with 28 additions and 32 deletions
|
@ -2090,10 +2090,9 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
|
||||||
self.ds["host"][uid]["bypassed"] = self.ds["hostspot_host"][uid][
|
self.ds["host"][uid]["bypassed"] = self.ds["hostspot_host"][uid][
|
||||||
"bypassed"
|
"bypassed"
|
||||||
]
|
]
|
||||||
else:
|
elif "authorized" in self.ds["host"][uid]:
|
||||||
if "authorized" in self.ds["host"][uid]:
|
del self.ds["host"][uid]["authorized"]
|
||||||
del self.ds["host"][uid]["authorized"]
|
del self.ds["host"][uid]["bypassed"]
|
||||||
del self.ds["host"][uid]["bypassed"]
|
|
||||||
|
|
||||||
# CAPS-MAN availability
|
# CAPS-MAN availability
|
||||||
if vals["source"] == "capsman" and uid not in capsman_detected:
|
if vals["source"] == "capsman" and uid not in capsman_detected:
|
||||||
|
@ -2152,29 +2151,28 @@ class MikrotikCoordinator(DataUpdateCoordinator[None]):
|
||||||
].split(".")[0]
|
].split(".")[0]
|
||||||
break
|
break
|
||||||
|
|
||||||
# Resolve hostname from DHCP comment
|
if self.ds["host"][uid]["host-name"] == "unknown":
|
||||||
if (
|
# Resolve hostname from DHCP comment
|
||||||
self.ds["host"][uid]["host-name"] == "unknown"
|
if (
|
||||||
and uid in self.ds["dhcp"]
|
uid in self.ds["dhcp"]
|
||||||
and self.ds["dhcp"][uid]["enabled"]
|
and self.ds["dhcp"][uid]["enabled"]
|
||||||
and self.ds["dhcp"][uid]["comment"].split("#", 1)[0] != ""
|
and self.ds["dhcp"][uid]["comment"].split("#", 1)[0] != ""
|
||||||
):
|
):
|
||||||
self.ds["host"][uid]["host-name"] = self.ds["dhcp"][uid][
|
self.ds["host"][uid]["host-name"] = self.ds["dhcp"][uid][
|
||||||
"comment"
|
"comment"
|
||||||
].split("#", 1)[0]
|
].split("#", 1)[0]
|
||||||
# Resolve hostname from DHCP hostname
|
# Resolve hostname from DHCP hostname
|
||||||
elif (
|
elif (
|
||||||
self.ds["host"][uid]["host-name"] == "unknown"
|
uid in self.ds["dhcp"]
|
||||||
and uid in self.ds["dhcp"]
|
and self.ds["dhcp"][uid]["enabled"]
|
||||||
and self.ds["dhcp"][uid]["enabled"]
|
and self.ds["dhcp"][uid]["host-name"] != "unknown"
|
||||||
and self.ds["dhcp"][uid]["host-name"] != "unknown"
|
):
|
||||||
):
|
self.ds["host"][uid]["host-name"] = self.ds["dhcp"][uid][
|
||||||
self.ds["host"][uid]["host-name"] = self.ds["dhcp"][uid][
|
"host-name"
|
||||||
"host-name"
|
]
|
||||||
]
|
# Fallback to mac address for hostname
|
||||||
# Fallback to mac address for hostname
|
else:
|
||||||
elif self.ds["host"][uid]["host-name"] == "unknown":
|
self.ds["host"][uid]["host-name"] = uid
|
||||||
self.ds["host"][uid]["host-name"] = uid
|
|
||||||
|
|
||||||
# Resolve manufacturer
|
# Resolve manufacturer
|
||||||
if vals["manufacturer"] == "detect" and vals["mac-address"] != "unknown":
|
if vals["manufacturer"] == "detect" and vals["mac-address"] != "unknown":
|
||||||
|
|
|
@ -245,7 +245,7 @@ class MikrotikEntity(CoordinatorEntity[_MikrotikCoordinatorT], Entity):
|
||||||
dev_connection_value = self._data[dev_connection_value]
|
dev_connection_value = self._data[dev_connection_value]
|
||||||
|
|
||||||
if self.entity_description.ha_group == "System":
|
if self.entity_description.ha_group == "System":
|
||||||
info = DeviceInfo(
|
return DeviceInfo(
|
||||||
connections={(dev_connection, f"{dev_connection_value}")},
|
connections={(dev_connection, f"{dev_connection_value}")},
|
||||||
identifiers={(dev_connection, f"{dev_connection_value}")},
|
identifiers={(dev_connection, f"{dev_connection_value}")},
|
||||||
name=f"{self._inst} {dev_group}",
|
name=f"{self._inst} {dev_group}",
|
||||||
|
@ -265,7 +265,7 @@ class MikrotikEntity(CoordinatorEntity[_MikrotikCoordinatorT], Entity):
|
||||||
"manufacturer"
|
"manufacturer"
|
||||||
]
|
]
|
||||||
|
|
||||||
info = DeviceInfo(
|
return DeviceInfo(
|
||||||
connections={(dev_connection, f"{dev_connection_value}")},
|
connections={(dev_connection, f"{dev_connection_value}")},
|
||||||
default_name=f"{dev_group}",
|
default_name=f"{dev_group}",
|
||||||
default_manufacturer=f"{dev_manufacturer}",
|
default_manufacturer=f"{dev_manufacturer}",
|
||||||
|
@ -275,7 +275,7 @@ class MikrotikEntity(CoordinatorEntity[_MikrotikCoordinatorT], Entity):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
info = DeviceInfo(
|
return DeviceInfo(
|
||||||
connections={(dev_connection, f"{dev_connection_value}")},
|
connections={(dev_connection, f"{dev_connection_value}")},
|
||||||
default_name=f"{self._inst} {dev_group}",
|
default_name=f"{self._inst} {dev_group}",
|
||||||
default_model=f"{self.coordinator.data['resource']['board-name']}",
|
default_model=f"{self.coordinator.data['resource']['board-name']}",
|
||||||
|
@ -286,8 +286,6 @@ class MikrotikEntity(CoordinatorEntity[_MikrotikCoordinatorT], Entity):
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
return info
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> Mapping[str, Any]:
|
def extra_state_attributes(self) -> Mapping[str, Any]:
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue