mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 08:47:10 +00:00
Add application_credentials platform for netatmo (#71884)
This commit is contained in:
parent
99f68ab858
commit
ddecf76f6f
@ -11,6 +11,10 @@ import pyatmo
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components import cloud
|
||||
from homeassistant.components.application_credentials import (
|
||||
ClientCredential,
|
||||
async_import_client_credential,
|
||||
)
|
||||
from homeassistant.components.webhook import (
|
||||
async_generate_url as webhook_generate_url,
|
||||
async_register as webhook_register,
|
||||
@ -35,7 +39,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
from homeassistant.helpers.event import async_call_later
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from . import api, config_flow
|
||||
from . import api
|
||||
from .const import (
|
||||
AUTH,
|
||||
CONF_CLOUDHOOK_URL,
|
||||
@ -48,8 +52,6 @@ from .const import (
|
||||
DATA_SCHEDULES,
|
||||
DOMAIN,
|
||||
NETATMO_SCOPES,
|
||||
OAUTH2_AUTHORIZE,
|
||||
OAUTH2_TOKEN,
|
||||
PLATFORMS,
|
||||
WEBHOOK_DEACTIVATION,
|
||||
WEBHOOK_PUSH_TYPE,
|
||||
@ -60,14 +62,17 @@ from .webhook import async_handle_webhook
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_CLIENT_ID): cv.string,
|
||||
vol.Required(CONF_CLIENT_SECRET): cv.string,
|
||||
}
|
||||
)
|
||||
},
|
||||
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,
|
||||
)
|
||||
|
||||
@ -88,17 +93,21 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
if DOMAIN not in config:
|
||||
return True
|
||||
|
||||
config_flow.NetatmoFlowHandler.async_register_implementation(
|
||||
await async_import_client_credential(
|
||||
hass,
|
||||
config_entry_oauth2_flow.LocalOAuth2Implementation(
|
||||
hass,
|
||||
DOMAIN,
|
||||
DOMAIN,
|
||||
ClientCredential(
|
||||
config[DOMAIN][CONF_CLIENT_ID],
|
||||
config[DOMAIN][CONF_CLIENT_SECRET],
|
||||
OAUTH2_AUTHORIZE,
|
||||
OAUTH2_TOKEN,
|
||||
),
|
||||
)
|
||||
_LOGGER.warning(
|
||||
"Configuration of Netatmo integration in YAML is deprecated and "
|
||||
"will be removed in a future release; Your existing configuration "
|
||||
"(including OAuth Application Credentials) have been imported into "
|
||||
"the UI automatically and can be safely removed from your "
|
||||
"configuration.yaml file"
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
14
homeassistant/components/netatmo/application_credentials.py
Normal file
14
homeassistant/components/netatmo/application_credentials.py
Normal file
@ -0,0 +1,14 @@
|
||||
"""Application credentials platform for Netatmo."""
|
||||
|
||||
from homeassistant.components.application_credentials import AuthorizationServer
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .const import OAUTH2_AUTHORIZE, OAUTH2_TOKEN
|
||||
|
||||
|
||||
async def async_get_authorization_server(hass: HomeAssistant) -> AuthorizationServer:
|
||||
"""Return authorization server."""
|
||||
return AuthorizationServer(
|
||||
authorize_url=OAUTH2_AUTHORIZE,
|
||||
token_url=OAUTH2_TOKEN,
|
||||
)
|
@ -4,7 +4,7 @@
|
||||
"documentation": "https://www.home-assistant.io/integrations/netatmo",
|
||||
"requirements": ["pyatmo==6.2.4"],
|
||||
"after_dependencies": ["cloud", "media_source"],
|
||||
"dependencies": ["auth", "webhook"],
|
||||
"dependencies": ["application_credentials", "webhook"],
|
||||
"codeowners": ["@cgtobi"],
|
||||
"config_flow": true,
|
||||
"homekit": {
|
||||
|
@ -8,6 +8,7 @@ To update, run python3 -m script.hassfest
|
||||
APPLICATION_CREDENTIALS = [
|
||||
"geocaching",
|
||||
"google",
|
||||
"netatmo",
|
||||
"spotify",
|
||||
"xbox"
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user