mirror of
https://github.com/home-assistant/core.git
synced 2026-07-01 03:36:05 +01:00
d766aae436
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: frenck <195327+frenck@users.noreply.github.com>
21 lines
572 B
Python
21 lines
572 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:
|
|
auth = aiohttp.BasicAuth(login=username, password=password)
|
|
return async_create_clientsession(hass, auth=auth)
|
|
|
|
return async_get_clientsession(hass)
|