Introduce reauthentication flow to Axis integration (#45307)

This commit is contained in:
Robert Svensson 2021-01-21 12:56:04 +01:00 committed by GitHub
parent 25adc6dd4f
commit b601e7e497
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 30 deletions

View file

@ -13,6 +13,7 @@ from axis.streammanager import SIGNAL_PLAYING, STATE_STOPPED
from homeassistant.components import mqtt
from homeassistant.components.mqtt import DOMAIN as MQTT_DOMAIN
from homeassistant.components.mqtt.models import Message
from homeassistant.config_entries import SOURCE_REAUTH
from homeassistant.const import (
CONF_HOST,
CONF_NAME,
@ -213,9 +214,13 @@ class AxisNetworkDevice:
except CannotConnect as err:
raise ConfigEntryNotReady from err
except Exception as err: # pylint: disable=broad-except
LOGGER.error(
"Unknown error connecting with Axis device (%s): %s", self.host, err
except AuthenticationRequired:
self.hass.async_create_task(
self.hass.config_entries.flow.async_init(
AXIS_DOMAIN,
context={"source": SOURCE_REAUTH},
data=self.config_entry.data,
)
)
return False