Skip to content

Commit 9733b89

Browse files
committed
Cleanup old token code
* custom_components/daikin_residential_altherma/__init__.py: * custom_components/daikin_residential_altherma/config_flow.py: * custom_components/daikin_residential_altherma/const.py: * custom_components/daikin_residential_altherma/daikin_api.py: * custom_components/daikin_residential_altherma/diagnostics.py: * custom_components/daikin_residential_altherma/manifest.json:
1 parent 26f6828 commit 9733b89

File tree

6 files changed

+23
-416
lines changed

6 files changed

+23
-416
lines changed

custom_components/daikin_residential_altherma/__init__.py

+10-17
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
import datetime
44
import logging
55
import voluptuous as vol
6+
from aiohttp import ClientError
67

78
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
8-
from homeassistant.const import CONF_EMAIL, CONF_PASSWORD, SERVICE_RELOAD
9+
from homeassistant.const import SERVICE_RELOAD
910
from homeassistant.helpers.typing import HomeAssistantType
1011
from homeassistant.helpers import config_entry_oauth2_flow
12+
from homeassistant.exceptions import ConfigEntryNotReady
1113

12-
from .const import DOMAIN, DAIKIN_API, DAIKIN_DEVICES, CONF_TOKENSET
14+
from .const import DOMAIN, DAIKIN_API, DAIKIN_DEVICES
1315

1416
from .daikin_api import DaikinApi
1517

1618
_LOGGER = logging.getLogger(__name__)
1719

18-
ENTRY_IS_SETUP = "daikin_entry_is_setup"
19-
2020
MIN_TIME_BETWEEN_UPDATES = datetime.timedelta(seconds=15)
2121
SCAN_INTERVAL = datetime.timedelta(seconds=30)
2222

@@ -30,17 +30,6 @@
3030

3131
COMPONENT_TYPES = ["climate", "sensor", "water_heater", "switch", "select"]
3232

33-
CONFIG_SCHEMA = vol.Schema(
34-
vol.All(
35-
{
36-
DOMAIN: vol.Schema(
37-
{vol.Required(CONF_EMAIL): str, vol.Required(CONF_PASSWORD): str}
38-
)
39-
}
40-
),
41-
extra=vol.ALLOW_EXTRA,
42-
)
43-
4433
async def async_setup(hass, config):
4534
"""Setup the Daikin Residential component."""
4635

@@ -50,8 +39,6 @@ async def _handle_reload(service):
5039
try:
5140
daikin_api = hass.data[DOMAIN][DAIKIN_API]
5241
data = daikin_api._config_entry.data.copy()
53-
await daikin_api.retrieveAccessToken(data[CONF_EMAIL], data[CONF_PASSWORD])
54-
data[CONF_TOKENSET] = daikin_api.tokenSet
5542
hass.config_entries.async_update_entry(
5643
entry=daikin_api._config_entry, data=data
5744
)
@@ -85,6 +72,12 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
8572
)
8673

8774
daikin_api = DaikinApi(hass, entry, implementation)
75+
76+
try:
77+
await daikin_api.async_get_access_token()
78+
except ClientError as err:
79+
raise ConfigEntryNotReady from err
80+
8881
await daikin_api.getCloudDeviceDetails()
8982

9083
devices = await daikin_api.getCloudDevices()

custom_components/daikin_residential_altherma/config_flow.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
from typing import Any
66

77
from homeassistant import config_entries
8-
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_TOKEN
98
from homeassistant.helpers import config_entry_oauth2_flow
109
from homeassistant.data_entry_flow import FlowResult
1110

1211
from .daikin_api import DaikinApi
1312
from .const import DOMAIN
1413

15-
CONF_USER_ID = "user_id"
1614
_LOGGER = logging.getLogger(__name__)
1715

1816
class FlowHandler(
@@ -31,6 +29,8 @@ def extra_authorize_data(self) -> dict[str, str]:
3129
"""Extra data that needs to be appended to the authorize url."""
3230
return {
3331
"scope": "openid onecta:basic.integration",
32+
"client_id": "emU20GdJDiiUxI_HnFGz69dD",
33+
"client_secret": "TNL1ePwnOkf6o2gKiI8InS8nVwTz2G__VYkv6WznzJGUnwLHLTmKYp-7RZc6FA3yS6D0Wgj_snvqsU5H_LPHQA",
3434
}
3535

3636
async def async_oauth_create_entry(self, data: dict) -> FlowResult:

custom_components/daikin_residential_altherma/const.py

-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from homeassistant.const import (
44
CONF_DEVICE_CLASS,
5-
CONF_TOKEN,
65
CONF_ICON,
76
CONF_NAME,
87
CONF_TYPE,
@@ -25,8 +24,6 @@
2524

2625
DOMAIN = "daikin_residential_altherma"
2726

28-
CONF_TOKENSET = CONF_TOKEN + "set"
29-
3027
DAIKIN_DATA = "daikin_data"
3128
DAIKIN_API = "daikin_api"
3229
DAIKIN_DEVICES = "daikin_devices"

0 commit comments

Comments
 (0)