Home Assistant Unofficial Reference 2024.12.1
helpers.py
Go to the documentation of this file.
1 """Blebox helpers."""
2 
3 from __future__ import annotations
4 
5 import aiohttp
6 
7 from homeassistant.core import HomeAssistant
9  async_create_clientsession,
10  async_get_clientsession,
11 )
12 
13 
15  hass: HomeAssistant, password: str | None, username: str | None
16 ) -> aiohttp.ClientSession:
17  """Return proper session object."""
18  if username and password:
19  auth = aiohttp.BasicAuth(login=username, password=password)
20  return async_create_clientsession(hass, auth=auth)
21 
22  return async_get_clientsession(hass)
aiohttp.ClientSession get_maybe_authenticated_session(HomeAssistant hass, str|None password, str|None username)
Definition: helpers.py:16
aiohttp.ClientSession async_create_clientsession()
Definition: coordinator.py:51
aiohttp.ClientSession async_get_clientsession(HomeAssistant hass, bool verify_ssl=True, socket.AddressFamily family=socket.AF_UNSPEC, ssl_util.SSLCipherList ssl_cipher=ssl_util.SSLCipherList.PYTHON_DEFAULT)