From f0f88d56bdbb5b82d8ec60bbeb9cfded0c802142 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Mon, 29 Nov 2021 18:53:42 -1000 Subject: [PATCH] Avoid probing configured ipp devices at discovery (#60551) - Each time these were seen by zeroconf, these devices were probed even if they were already configured. This is expensive and we want to avoid this when possible --- homeassistant/components/ipp/config_flow.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/ipp/config_flow.py b/homeassistant/components/ipp/config_flow.py index 543592cd4f0..432094eee8e 100644 --- a/homeassistant/components/ipp/config_flow.py +++ b/homeassistant/components/ipp/config_flow.py @@ -104,23 +104,28 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN): self, discovery_info: zeroconf.ZeroconfServiceInfo ) -> FlowResult: """Handle zeroconf discovery.""" - port = discovery_info[zeroconf.ATTR_PORT] - zctype = discovery_info[zeroconf.ATTR_TYPE] - name = discovery_info[zeroconf.ATTR_NAME].replace(f".{zctype}", "") + host = discovery_info.host + + # Avoid probing devices that already have an entry + self._async_abort_entries_match({CONF_HOST: host}) + + port = discovery_info.port + zctype = discovery_info.type + name = discovery_info.name.replace(f".{zctype}", "") tls = zctype == "_ipps._tcp.local." - base_path = discovery_info[zeroconf.ATTR_PROPERTIES].get("rp", "ipp/print") + base_path = discovery_info.properties.get("rp", "ipp/print") self.context.update({"title_placeholders": {"name": name}}) self.discovery_info.update( { - CONF_HOST: discovery_info[zeroconf.ATTR_HOST], + CONF_HOST: host, CONF_PORT: port, CONF_SSL: tls, CONF_VERIFY_SSL: False, CONF_BASE_PATH: f"/{base_path}", CONF_NAME: name, - CONF_UUID: discovery_info[zeroconf.ATTR_PROPERTIES].get("UUID"), + CONF_UUID: discovery_info.properties.get("UUID"), } )