mirror of
https://github.com/home-assistant/core.git
synced 2025-05-17 04:19:16 +00:00

* First checkin for myUplink * Refactored coordinator and sensor state classe * Updated .coveragerc * Update test_config_flow * Fix test_config_flow for myuplink * Only set state class for temperature sensor * PR comment updates * Type strong dict * use asyncio.timeouts * PR updates (part 1) * Updated to myuplink 0.0.9 * Add strict typing * Fix typing * Inherit CoordinatorEntity * Clean up coordinator and sensors * Use common base entity * Improve device point sensor * Exclude entity from coverage * Set device point entity name if there's no entity description * Update homeassistant/components/myuplink/sensor.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/myuplink/entity.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Update homeassistant/components/myuplink/entity.py Co-authored-by: Martin Hjelmare <marhje52@gmail.com> * Remvoed firmware + connstate sensors * Always add device point parameter name * Removed MyUplinkDeviceSensor * Removed unused class * key="celsius", --------- Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
32 lines
994 B
Python
32 lines
994 B
Python
"""API for myUplink bound to Home Assistant OAuth."""
|
|
from __future__ import annotations
|
|
|
|
from typing import cast
|
|
|
|
from aiohttp import ClientSession
|
|
from myuplink.auth_abstract import AbstractAuth
|
|
|
|
from homeassistant.helpers import config_entry_oauth2_flow
|
|
|
|
from .const import API_ENDPOINT
|
|
|
|
|
|
class AsyncConfigEntryAuth(AbstractAuth): # type: ignore[misc]
|
|
"""Provide myUplink authentication tied to an OAuth2 based config entry."""
|
|
|
|
def __init__(
|
|
self,
|
|
websession: ClientSession,
|
|
oauth_session: config_entry_oauth2_flow.OAuth2Session,
|
|
) -> None:
|
|
"""Initialize myUplink auth."""
|
|
super().__init__(websession, API_ENDPOINT)
|
|
self._oauth_session = oauth_session
|
|
|
|
async def async_get_access_token(self) -> str:
|
|
"""Return a valid access token."""
|
|
if not self._oauth_session.valid_token:
|
|
await self._oauth_session.async_ensure_token_valid()
|
|
|
|
return cast(str, self._oauth_session.token["access_token"])
|