mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Remove deprecated Senz YAML configuration (#75419)
This commit is contained in:
parent
e65018fb85
commit
24b3b5fc46
@ -6,14 +6,9 @@ import logging
|
|||||||
|
|
||||||
from aiosenz import SENZAPI, Thermostat
|
from aiosenz import SENZAPI, Thermostat
|
||||||
from httpx import RequestError
|
from httpx import RequestError
|
||||||
import voluptuous as vol
|
|
||||||
|
|
||||||
from homeassistant.components.application_credentials import (
|
|
||||||
ClientCredential,
|
|
||||||
async_import_client_credential,
|
|
||||||
)
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, Platform
|
from homeassistant.const import Platform
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ConfigEntryNotReady
|
from homeassistant.exceptions import ConfigEntryNotReady
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
@ -21,7 +16,6 @@ from homeassistant.helpers import (
|
|||||||
config_validation as cv,
|
config_validation as cv,
|
||||||
httpx_client,
|
httpx_client,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.typing import ConfigType
|
|
||||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||||
|
|
||||||
from .api import SENZConfigEntryAuth
|
from .api import SENZConfigEntryAuth
|
||||||
@ -31,52 +25,13 @@ UPDATE_INTERVAL = timedelta(seconds=30)
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False)
|
||||||
vol.All(
|
|
||||||
cv.deprecated(DOMAIN),
|
|
||||||
{
|
|
||||||
DOMAIN: vol.Schema(
|
|
||||||
{
|
|
||||||
vol.Required(CONF_CLIENT_ID): cv.string,
|
|
||||||
vol.Required(CONF_CLIENT_SECRET): cv.string,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
},
|
|
||||||
),
|
|
||||||
extra=vol.ALLOW_EXTRA,
|
|
||||||
)
|
|
||||||
|
|
||||||
PLATFORMS = [Platform.CLIMATE]
|
PLATFORMS = [Platform.CLIMATE]
|
||||||
|
|
||||||
SENZDataUpdateCoordinator = DataUpdateCoordinator[dict[str, Thermostat]]
|
SENZDataUpdateCoordinator = DataUpdateCoordinator[dict[str, Thermostat]]
|
||||||
|
|
||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|
||||||
"""Set up the SENZ OAuth2 configuration."""
|
|
||||||
hass.data[DOMAIN] = {}
|
|
||||||
|
|
||||||
if DOMAIN not in config:
|
|
||||||
return True
|
|
||||||
|
|
||||||
await async_import_client_credential(
|
|
||||||
hass,
|
|
||||||
DOMAIN,
|
|
||||||
ClientCredential(
|
|
||||||
config[DOMAIN][CONF_CLIENT_ID],
|
|
||||||
config[DOMAIN][CONF_CLIENT_SECRET],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
_LOGGER.warning(
|
|
||||||
"Configuration of SENZ integration in YAML is deprecated "
|
|
||||||
"and will be removed in a future release; Your existing OAuth "
|
|
||||||
"Application Credentials have been imported into the UI "
|
|
||||||
"automatically and can be safely removed from your "
|
|
||||||
"configuration.yaml file"
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||||
"""Set up SENZ from a config entry."""
|
"""Set up SENZ from a config entry."""
|
||||||
implementation = (
|
implementation = (
|
||||||
@ -111,7 +66,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
|
|
||||||
await coordinator.async_config_entry_first_refresh()
|
await coordinator.async_config_entry_first_refresh()
|
||||||
|
|
||||||
hass.data[DOMAIN][entry.entry_id] = coordinator
|
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = coordinator
|
||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
|
|
||||||
|
@ -3,10 +3,15 @@ from unittest.mock import patch
|
|||||||
|
|
||||||
from aiosenz import AUTHORIZATION_ENDPOINT, TOKEN_ENDPOINT
|
from aiosenz import AUTHORIZATION_ENDPOINT, TOKEN_ENDPOINT
|
||||||
|
|
||||||
from homeassistant import config_entries, setup
|
from homeassistant import config_entries
|
||||||
|
from homeassistant.components.application_credentials import (
|
||||||
|
ClientCredential,
|
||||||
|
async_import_client_credential,
|
||||||
|
)
|
||||||
from homeassistant.components.senz.const import DOMAIN
|
from homeassistant.components.senz.const import DOMAIN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import config_entry_oauth2_flow
|
from homeassistant.helpers import config_entry_oauth2_flow
|
||||||
|
from homeassistant.setup import async_setup_component
|
||||||
|
|
||||||
CLIENT_ID = "1234"
|
CLIENT_ID = "1234"
|
||||||
CLIENT_SECRET = "5678"
|
CLIENT_SECRET = "5678"
|
||||||
@ -19,12 +24,11 @@ async def test_full_flow(
|
|||||||
current_request_with_host,
|
current_request_with_host,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Check full flow."""
|
"""Check full flow."""
|
||||||
assert await setup.async_setup_component(
|
await async_setup_component(hass, DOMAIN, {})
|
||||||
hass,
|
await hass.async_block_till_done()
|
||||||
"senz",
|
|
||||||
{
|
await async_import_client_credential(
|
||||||
"senz": {"client_id": CLIENT_ID, "client_secret": CLIENT_SECRET},
|
hass, DOMAIN, ClientCredential(CLIENT_ID, CLIENT_SECRET), "cred"
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user