Home Assistant Unofficial Reference 2024.12.1
util.py
Go to the documentation of this file.
1 """Define notion utilities."""
2 
3 from aionotion import (
4  async_get_client_with_credentials as cwc,
5  async_get_client_with_refresh_token as cwrt,
6 )
7 from aionotion.client import Client
8 
9 from homeassistant.core import HomeAssistant
10 from homeassistant.helpers import aiohttp_client
11 from homeassistant.helpers.instance_id import async_get
12 
13 
15  hass: HomeAssistant, email: str, password: str
16 ) -> Client:
17  """Get a Notion client with credentials."""
18  session = aiohttp_client.async_get_clientsession(hass)
19  instance_id = await async_get(hass)
20  return await cwc(email, password, session=session, session_name=instance_id)
21 
22 
24  hass: HomeAssistant, user_uuid: str, refresh_token: str
25 ) -> Client:
26  """Get a Notion client with credentials."""
27  session = aiohttp_client.async_get_clientsession(hass)
28  instance_id = await async_get(hass)
29  return await cwrt(
30  user_uuid, refresh_token, session=session, session_name=instance_id
31  )
Client async_get_client_with_credentials(HomeAssistant hass, str email, str password)
Definition: util.py:16
Client async_get_client_with_refresh_token(HomeAssistant hass, str user_uuid, str refresh_token)
Definition: util.py:25
AreaRegistry async_get(HomeAssistant hass)