Skip to content

Commit

Permalink
Do not update IP or hostname from disabled DHCP entry #265
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaae committed Jan 20, 2023
1 parent a7c00d8 commit ce9ce90
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion custom_components/mikrotik_router/mikrotik_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -2179,7 +2179,11 @@ async def async_process_host(self):
self.data["host"][uid]["available"] = False

# Update IP and interface (DHCP/returned host)
if uid in self.data["dhcp"] and "." in self.data["dhcp"][uid]["address"]:
if (
uid in self.data["dhcp"]
and self.data["dhcp"][uid]["enabled"]
and "." in self.data["dhcp"][uid]["address"]
):
if (
self.data["dhcp"][uid]["address"]
!= self.data["host"][uid]["address"]
Expand Down Expand Up @@ -2217,6 +2221,7 @@ async def async_process_host(self):
].split("#", 1)[0]
elif (
uid in self.data["dhcp"]
and self.data["dhcp"][uid]["enabled"]
and self.data["dhcp"][uid]["comment"].split("#", 1)[0]
!= ""
):
Expand All @@ -2234,6 +2239,7 @@ async def async_process_host(self):
if (
self.data["host"][uid]["host-name"] == "unknown"
and uid in self.data["dhcp"]
and self.data["dhcp"][uid]["enabled"]
and self.data["dhcp"][uid]["comment"].split("#", 1)[0] != ""
):
self.data["host"][uid]["host-name"] = self.data["dhcp"][uid][
Expand All @@ -2243,6 +2249,7 @@ async def async_process_host(self):
elif (
self.data["host"][uid]["host-name"] == "unknown"
and uid in self.data["dhcp"]
and self.data["dhcp"][uid]["enabled"]
and self.data["dhcp"][uid]["host-name"] != "unknown"
):
self.data["host"][uid]["host-name"] = self.data["dhcp"][uid][
Expand Down

0 comments on commit ce9ce90

Please sign in to comment.