Add YoLink product integration (#69167)
* add yolink integration with door sensor * Add test flow and update .coveragerc * Yolink integration Bug fix * resovle test flow * issues resolve * issues resolve * issues resolve * resolve issues * issues resolve * issues resolve * change .coveragerc and test_flow * Update yolink api version * add test for config entry * change config flow and add test cases * remove config entry data * Add token check for re-auth test flow * fix test flow issues * Add application credentials * Add alias for application_credentials * support application credentials and cloud account linking * fix suggest change
This commit is contained in:
parent
513e276bba
commit
e0154d6fb1
19 changed files with 740 additions and 1 deletions
30
homeassistant/components/yolink/api.py
Normal file
30
homeassistant/components/yolink/api.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
"""API for yolink bound to Home Assistant OAuth."""
|
||||
from aiohttp import ClientSession
|
||||
from yolink.auth_mgr import YoLinkAuthMgr
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
|
||||
class ConfigEntryAuth(YoLinkAuthMgr):
|
||||
"""Provide yolink authentication tied to an OAuth2 based config entry."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
websession: ClientSession,
|
||||
oauth2Session: config_entry_oauth2_flow.OAuth2Session,
|
||||
) -> None:
|
||||
"""Initialize yolink Auth."""
|
||||
self.hass = hass
|
||||
self.oauth_session = oauth2Session
|
||||
super().__init__(websession)
|
||||
|
||||
def access_token(self) -> str:
|
||||
"""Return the access token."""
|
||||
return self.oauth_session.token["access_token"]
|
||||
|
||||
async def check_and_refresh_token(self) -> str:
|
||||
"""Check the token."""
|
||||
await self.oauth_session.async_ensure_token_valid()
|
||||
return self.access_token()
|
Loading…
Add table
Add a link
Reference in a new issue