From ce9ce906f5089b23244380bea105ac10cfe8f147 Mon Sep 17 00:00:00 2001 From: Tomaae <23486452+tomaae@users.noreply.github.com> Date: Fri, 20 Jan 2023 09:35:59 +0100 Subject: [PATCH] Do not update IP or hostname from disabled DHCP entry #265 --- custom_components/mikrotik_router/mikrotik_controller.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/custom_components/mikrotik_router/mikrotik_controller.py b/custom_components/mikrotik_router/mikrotik_controller.py index 9c94b51..41bc38b 100644 --- a/custom_components/mikrotik_router/mikrotik_controller.py +++ b/custom_components/mikrotik_router/mikrotik_controller.py @@ -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"] @@ -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] != "" ): @@ -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][ @@ -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][