1 """Support for Axis devices."""
10 from .const
import PLATFORMS
11 from .errors
import AuthenticationRequired, CannotConnect
12 from .hub
import AxisHub, get_axis_api
14 _LOGGER = logging.getLogger(__name__)
16 type AxisConfigEntry = ConfigEntry[AxisHub]
20 """Set up the Axis integration."""
23 except CannotConnect
as err:
24 raise ConfigEntryNotReady
from err
25 except AuthenticationRequired
as err:
26 raise ConfigEntryAuthFailed
from err
28 hub = config_entry.runtime_data = AxisHub(hass, config_entry, api)
29 await hub.async_update_device_registry()
30 await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
33 config_entry.add_update_listener(hub.async_new_address_callback)
34 config_entry.async_on_unload(hub.teardown)
35 config_entry.async_on_unload(
36 hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, hub.shutdown)
43 """Unload Axis device config entry."""
44 return await hass.config_entries.async_unload_platforms(config_entry, PLATFORMS)
48 """Migrate old entry."""
49 _LOGGER.debug(
"Migrating from version %s", config_entry.version)
51 if config_entry.version != 3:
53 hass.config_entries.async_update_entry(config_entry, version=3)
55 _LOGGER.debug(
"Migration to version %s successful", config_entry.version)
axis.AxisDevice get_axis_api(HomeAssistant hass, MappingProxyType[str, Any] config)
bool async_unload_entry(HomeAssistant hass, ConfigEntry config_entry)
bool async_migrate_entry(HomeAssistant hass, ConfigEntry config_entry)
bool async_setup_entry(HomeAssistant hass, AxisConfigEntry config_entry)