1 """The Oncue integration."""
3 from __future__
import annotations
5 from datetime
import timedelta
8 from aiooncue
import LoginFailedException, Oncue, OncueDevice
16 from .const
import CONNECTION_EXCEPTIONS, DOMAIN
17 from .types
import OncueConfigEntry
19 PLATFORMS: list[str] = [Platform.BINARY_SENSOR, Platform.SENSOR]
21 _LOGGER = logging.getLogger(__name__)
25 """Set up Oncue from a config entry."""
28 client = Oncue(data[CONF_USERNAME], data[CONF_PASSWORD], websession)
30 await client.async_login()
31 except CONNECTION_EXCEPTIONS
as ex:
32 raise ConfigEntryNotReady
from ex
33 except LoginFailedException
as ex:
34 raise ConfigEntryAuthFailed
from ex
36 async
def _async_update() -> dict[str, OncueDevice]:
37 """Fetch data from Oncue."""
39 return await client.async_fetch_all()
40 except LoginFailedException
as ex:
41 raise ConfigEntryAuthFailed
from ex
43 coordinator = DataUpdateCoordinator[dict[str, OncueDevice]](
47 name=f
"Oncue {entry.data[CONF_USERNAME]}",
49 update_method=_async_update,
52 await coordinator.async_config_entry_first_refresh()
54 entry.runtime_data = coordinator
55 await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
60 """Unload a config entry."""
61 return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
bool async_unload_entry(HomeAssistant hass, OncueConfigEntry entry)
bool async_setup_entry(HomeAssistant hass, OncueConfigEntry entry)
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)