Add microBees integration (#99573)
* Create a new homeassistan integration for microBees * black --fast homeassistant tests * Switch platform * rename folder * rename folder * Update owners * aiohttp removed in favor of hass * Update config_flow.py * Update __init__.py * Update const.py * Update manifest.json * Update string.json * Update servicesMicrobees.py * Update switch.py * Update __init__.py * Update it.json * Create a new homeassistan integration for microBees * black --fast homeassistant tests * Switch platform * rename folder * rename folder * Update owners * aiohttp removed in favor of hass * Update config_flow.py * Update __init__.py * Update const.py * Update manifest.json * Update string.json * Update servicesMicrobees.py * Update switch.py * Update __init__.py * Update it.json * fixes review * fixes review * fixes review * pyproject.toml * Update package_constraints.txt * fixes review * bug fixes * bug fixes * delete microbees connector * add other productID in switch * added coordinator and enanchments * added coordinator and enanchments * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * fixes from suggestions * add test * add test * add test * add test * requested commit * requested commit * requested commit * requested commit * reverting .strict-typing and added microbees to .coveragerc * remove log * remove log * remove log * remove log * add test for microbeesExeption and Exeption * add test for microbeesExeption and Exeption * add test for microbeesException and Exception * add test for microbeesException and Exception * add test for microbeesException and Exception --------- Co-authored-by: FedDam <noceracity@gmail.com> Co-authored-by: Federico D'Amico <48856240+FedDam@users.noreply.github.com>
This commit is contained in:
parent
b349a466ba
commit
3a4c6fc7f3
23 changed files with 1012 additions and 0 deletions
28
homeassistant/components/microbees/api.py
Normal file
28
homeassistant/components/microbees/api.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
"""API for microBees bound to Home Assistant OAuth."""
|
||||
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
|
||||
class ConfigEntryAuth:
|
||||
"""Provide microBees authentication tied to an OAuth2 based config entry."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
hass: HomeAssistant,
|
||||
oauth2_session: config_entry_oauth2_flow.OAuth2Session,
|
||||
) -> None:
|
||||
"""Initialize microBees Auth."""
|
||||
self.oauth_session = oauth2_session
|
||||
self.hass = hass
|
||||
|
||||
@property
|
||||
def access_token(self) -> str:
|
||||
"""Return the access token."""
|
||||
return self.oauth_session.token[CONF_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