1 """Axis network device abstraction."""
3 from asyncio
import timeout
4 from types
import MappingProxyType
8 from axis.models.configuration
import Configuration
20 from ..const
import LOGGER
21 from ..errors
import AuthenticationRequired, CannotConnect
26 config: MappingProxyType[str, Any],
28 """Create a Axis device API."""
31 api = axis.AxisDevice(
35 port=config[CONF_PORT],
36 username=config[CONF_USERNAME],
37 password=config[CONF_PASSWORD],
38 web_proto=config.get(CONF_PROTOCOL,
"http"),
43 async
with timeout(30):
44 await api.vapix.initialize()
46 except axis.Unauthorized
as err:
48 "Connected to device at %s but not registered", config[CONF_HOST]
50 raise AuthenticationRequired
from err
52 except (TimeoutError, axis.RequestError)
as err:
53 LOGGER.error(
"Error connecting to the Axis device at %s", config[CONF_HOST])
54 raise CannotConnect
from err
56 except axis.AxisException
as err:
57 LOGGER.exception(
"Unknown Axis communication error occurred")
58 raise AuthenticationRequired
from err
axis.AxisDevice get_axis_api(HomeAssistant hass, MappingProxyType[str, Any] config)
httpx.AsyncClient get_async_client(HomeAssistant hass, bool verify_ssl=True)