fixed dictionary changed size during iteration for async_ping_tracked_hosts

This commit is contained in:
tomaae 2020-04-11 17:44:45 +02:00
parent a1a407ca3c
commit d189ad8c66

View file

@ -284,7 +284,7 @@ class MikrotikControllerData:
except: except:
return return
for uid, vals in self.data["host"].items(): for uid in list(self.data["host"]):
if not self.host_tracking_initialized: if not self.host_tracking_initialized:
# Add missing default values # Add missing default values
for key, default in zip( for key, default in zip(
@ -303,14 +303,16 @@ class MikrotikControllerData:
# Check host availability # Check host availability
if ( if (
vals["source"] not in ["capsman", "wireless"] self.data["host"][uid]["source"] not in ["capsman", "wireless"]
and vals["address"] != "unknown" and self.data["host"][uid]["address"] != "unknown"
and vals["interface"] != "unknown" and self.data["host"][uid]["interface"] != "unknown"
): ):
self.data["host"][uid][ self.data["host"][uid][
"available" "available"
] = await self.hass.async_add_executor_job( ] = await self.hass.async_add_executor_job(
self.api_ping.arp_ping, vals["address"], vals["interface"] self.api_ping.arp_ping,
self.data["host"][uid]["address"],
self.data["host"][uid]["interface"]
) )
# Update last seen # Update last seen