mirror of
https://github.com/home-assistant/core.git
synced 2026-09-07 22:20:07 +01:00
23 lines
602 B
Python
23 lines
602 B
Python
"""Blebox helpers."""
|
|
|
|
import aiohttp
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
from homeassistant.helpers.aiohttp_client import (
|
|
async_create_clientsession,
|
|
async_get_clientsession,
|
|
)
|
|
|
|
|
|
def get_maybe_authenticated_session(
|
|
hass: HomeAssistant, password: str | None, username: str | None
|
|
) -> aiohttp.ClientSession:
|
|
"""Return proper session object."""
|
|
if username and password:
|
|
return async_create_clientsession(
|
|
hass,
|
|
headers={"Authorization": aiohttp.encode_basic_auth(username, password)},
|
|
)
|
|
|
|
return async_get_clientsession(hass)
|