mirror of
https://github.com/Andre0512/hon.git
synced 2024-11-27 17:00:55 +01:00
Set refresh token and mobile id
This commit is contained in:
parent
71d3d42efe
commit
8694882c45
@ -8,7 +8,7 @@ from homeassistant.helpers import config_validation as cv, aiohttp_client
|
|||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
from pyhon import Hon
|
from pyhon import Hon
|
||||||
|
|
||||||
from .const import DOMAIN, PLATFORMS
|
from .const import DOMAIN, PLATFORMS, MOBILE_ID, CONF_REFRESH_TOKEN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -30,9 +30,11 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
|
|||||||
if (config_dir := hass.config.config_dir) is None:
|
if (config_dir := hass.config.config_dir) is None:
|
||||||
raise ValueError("Missing Config Dir")
|
raise ValueError("Missing Config Dir")
|
||||||
hon = await Hon(
|
hon = await Hon(
|
||||||
entry.data["email"],
|
entry.data[CONF_EMAIL],
|
||||||
entry.data["password"],
|
entry.data[CONF_PASSWORD],
|
||||||
|
mobile_id=MOBILE_ID,
|
||||||
session=session,
|
session=session,
|
||||||
|
refresh_token=entry.data[CONF_REFRESH_TOKEN],
|
||||||
test_data_path=Path(config_dir),
|
test_data_path=Path(config_dir),
|
||||||
).create()
|
).create()
|
||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
@ -47,6 +49,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
|
|||||||
|
|
||||||
|
|
||||||
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
|
async def async_unload_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool:
|
||||||
|
entry.data[CONF_REFRESH_TOKEN] = hass.data[DOMAIN][entry.unique_id].api.auth.refresh_token
|
||||||
unload = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
unload = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||||
if unload:
|
if unload:
|
||||||
if not hass.data[DOMAIN]:
|
if not hass.data[DOMAIN]:
|
||||||
|
@ -8,6 +8,8 @@ from homeassistant.components.climate import (
|
|||||||
|
|
||||||
DOMAIN: str = "hon"
|
DOMAIN: str = "hon"
|
||||||
UPDATE_INTERVAL: int = 60
|
UPDATE_INTERVAL: int = 60
|
||||||
|
MOBILE_ID: str = "homassistant"
|
||||||
|
CONF_REFRESH_TOKEN = "refresh_token"
|
||||||
|
|
||||||
PLATFORMS: list[str] = [
|
PLATFORMS: list[str] = [
|
||||||
"sensor",
|
"sensor",
|
||||||
|
Loading…
Reference in New Issue
Block a user