mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +00:00
Fix somfy optimistic mode when missing in conf (#32995)
* Fix optimistic mode when missing in conf #32971 * Ease code using a default value * Client id and secret are now inclusive
This commit is contained in:
parent
23045af4a7
commit
5a2aabea9c
@ -27,7 +27,7 @@ DOMAIN = "somfy"
|
|||||||
|
|
||||||
CONF_CLIENT_ID = "client_id"
|
CONF_CLIENT_ID = "client_id"
|
||||||
CONF_CLIENT_SECRET = "client_secret"
|
CONF_CLIENT_SECRET = "client_secret"
|
||||||
CONF_OPTIMISTIC = "optimisitic"
|
CONF_OPTIMISTIC = "optimistic"
|
||||||
|
|
||||||
SOMFY_AUTH_CALLBACK_PATH = "/auth/somfy/callback"
|
SOMFY_AUTH_CALLBACK_PATH = "/auth/somfy/callback"
|
||||||
SOMFY_AUTH_START = "/auth/somfy"
|
SOMFY_AUTH_START = "/auth/somfy"
|
||||||
@ -36,8 +36,8 @@ CONFIG_SCHEMA = vol.Schema(
|
|||||||
{
|
{
|
||||||
DOMAIN: vol.Schema(
|
DOMAIN: vol.Schema(
|
||||||
{
|
{
|
||||||
vol.Required(CONF_CLIENT_ID): cv.string,
|
vol.Inclusive(CONF_CLIENT_ID, "oauth"): cv.string,
|
||||||
vol.Required(CONF_CLIENT_SECRET): cv.string,
|
vol.Inclusive(CONF_CLIENT_SECRET, "oauth"): cv.string,
|
||||||
vol.Optional(CONF_OPTIMISTIC, default=False): cv.boolean,
|
vol.Optional(CONF_OPTIMISTIC, default=False): cv.boolean,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -51,23 +51,21 @@ SOMFY_COMPONENTS = ["cover", "switch"]
|
|||||||
async def async_setup(hass, config):
|
async def async_setup(hass, config):
|
||||||
"""Set up the Somfy component."""
|
"""Set up the Somfy component."""
|
||||||
hass.data[DOMAIN] = {}
|
hass.data[DOMAIN] = {}
|
||||||
|
domain_config = config.get(DOMAIN, {})
|
||||||
|
hass.data[DOMAIN][CONF_OPTIMISTIC] = domain_config.get(CONF_OPTIMISTIC, False)
|
||||||
|
|
||||||
if DOMAIN not in config:
|
if CONF_CLIENT_ID in domain_config:
|
||||||
return True
|
config_flow.SomfyFlowHandler.async_register_implementation(
|
||||||
|
|
||||||
hass.data[DOMAIN][CONF_OPTIMISTIC] = config[DOMAIN][CONF_OPTIMISTIC]
|
|
||||||
|
|
||||||
config_flow.SomfyFlowHandler.async_register_implementation(
|
|
||||||
hass,
|
|
||||||
config_entry_oauth2_flow.LocalOAuth2Implementation(
|
|
||||||
hass,
|
hass,
|
||||||
DOMAIN,
|
config_entry_oauth2_flow.LocalOAuth2Implementation(
|
||||||
config[DOMAIN][CONF_CLIENT_ID],
|
hass,
|
||||||
config[DOMAIN][CONF_CLIENT_SECRET],
|
DOMAIN,
|
||||||
"https://accounts.somfy.com/oauth/oauth/v2/auth",
|
config[DOMAIN][CONF_CLIENT_ID],
|
||||||
"https://accounts.somfy.com/oauth/oauth/v2/token",
|
config[DOMAIN][CONF_CLIENT_SECRET],
|
||||||
),
|
"https://accounts.somfy.com/oauth/oauth/v2/auth",
|
||||||
)
|
"https://accounts.somfy.com/oauth/oauth/v2/token",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user