Improve ipp unique id parsing (#35959)

This commit is contained in:
Chris Talkington authored and GitHub committed 2020-05-23 20:02:49 +02:00
1 parent 6e3bba07da
commit be854b7363
2 files changed
+23 -5

No files matched your search

+5 -5
View File
@@ -85,12 +85,12 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN):
unique_id = user_input[CONF_UUID] = info[CONF_UUID]
if unique_id is None and info[CONF_SERIAL] is not None:
if not unique_id and info[CONF_SERIAL]:
_LOGGER.debug(
"Printer UUID is missing from IPP response. Falling back to IPP serial number"
)
unique_id = info[CONF_SERIAL]
elif unique_id is None:
elif not unique_id:
_LOGGER.debug("Unable to determine unique id from IPP response")
await self.async_set_unique_id(unique_id)
@@ -138,17 +138,17 @@ class IPPFlowHandler(ConfigFlow, domain=DOMAIN):
return self.async_abort(reason="ipp_error")
unique_id = self.discovery_info[CONF_UUID]
if unique_id is None and info[CONF_UUID] is not None:
if not unique_id and info[CONF_UUID]:
_LOGGER.debug(
"Printer UUID is missing from discovery info. Falling back to IPP UUID"
)
unique_id = self.discovery_info[CONF_UUID] = info[CONF_UUID]
elif unique_id is None and info[CONF_SERIAL] is not None:
elif not unique_id and info[CONF_SERIAL]:
_LOGGER.debug(
"Printer UUID is missing from discovery info and IPP response. Falling back to IPP serial number"
)
unique_id = info[CONF_SERIAL]
elif unique_id is None:
elif not unique_id:
_LOGGER.debug(
"Unable to determine unique id from discovery info and IPP response"
)