Remove unnecessary try-else (2) (#86159)
This commit is contained in:
parent
1cc8feabb7
commit
bc115634d1
8 changed files with 39 additions and 41 deletions
|
@ -191,11 +191,11 @@ class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
self.data[CONF_ID] = status.get("chipId", status["mac"].replace(":", ""))
|
||||
except (CannotConnect, KeyError) as err:
|
||||
raise CannotConnect from err
|
||||
else:
|
||||
self.data[CONF_MODEL] = status.get("model", KONN_MODEL)
|
||||
self.data[CONF_ACCESS_TOKEN] = "".join(
|
||||
random.choices(f"{string.ascii_uppercase}{string.digits}", k=20)
|
||||
)
|
||||
|
||||
self.data[CONF_MODEL] = status.get("model", KONN_MODEL)
|
||||
self.data[CONF_ACCESS_TOKEN] = "".join(
|
||||
random.choices(f"{string.ascii_uppercase}{string.digits}", k=20)
|
||||
)
|
||||
|
||||
async def async_step_import(self, device_config):
|
||||
"""Import a configuration.yaml config.
|
||||
|
@ -282,19 +282,17 @@ class KonnectedFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
status = await get_status(self.hass, netloc[0], int(netloc[1]))
|
||||
except CannotConnect:
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
else:
|
||||
self.data[CONF_HOST] = netloc[0]
|
||||
self.data[CONF_PORT] = int(netloc[1])
|
||||
self.data[CONF_ID] = status.get(
|
||||
"chipId", status["mac"].replace(":", "")
|
||||
)
|
||||
self.data[CONF_MODEL] = status.get("model", KONN_MODEL)
|
||||
|
||||
KonnectedFlowHandler.discovered_hosts[self.data[CONF_ID]] = {
|
||||
CONF_HOST: self.data[CONF_HOST],
|
||||
CONF_PORT: self.data[CONF_PORT],
|
||||
}
|
||||
return await self.async_step_confirm()
|
||||
self.data[CONF_HOST] = netloc[0]
|
||||
self.data[CONF_PORT] = int(netloc[1])
|
||||
self.data[CONF_ID] = status.get("chipId", status["mac"].replace(":", ""))
|
||||
self.data[CONF_MODEL] = status.get("model", KONN_MODEL)
|
||||
|
||||
KonnectedFlowHandler.discovered_hosts[self.data[CONF_ID]] = {
|
||||
CONF_HOST: self.data[CONF_HOST],
|
||||
CONF_PORT: self.data[CONF_PORT],
|
||||
}
|
||||
return await self.async_step_confirm()
|
||||
|
||||
return self.async_abort(reason="unknown")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue