Use CONF_CLIENT_ID & CONF_CLIENT_SECRET from homeassistant.const (#36233)
* Use CONF_CLIENT_ID & CONF_CLIENT_SECRET from homeassistant.const * Fix pylint * Use in tests * Search for "client_id" * Fix tests * Fix test * Fix test
This commit is contained in:
parent
b6407f77da
commit
1855c91988
66 changed files with 386 additions and 352 deletions
|
@ -3,15 +3,13 @@ import logging
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, CONF_NAME
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import config_validation as cv, entityfilter
|
||||
|
||||
from . import flash_briefings, intent, smart_home_http
|
||||
from .const import (
|
||||
CONF_AUDIO,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_DESCRIPTION,
|
||||
CONF_DISPLAY_CATEGORIES,
|
||||
CONF_DISPLAY_URL,
|
||||
|
|
|
@ -7,7 +7,7 @@ import logging
|
|||
import aiohttp
|
||||
import async_timeout
|
||||
|
||||
from homeassistant.const import HTTP_OK
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, HTTP_OK
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import aiohttp_client
|
||||
from homeassistant.util import dt
|
||||
|
@ -48,8 +48,8 @@ class Auth:
|
|||
lwa_params = {
|
||||
"grant_type": "authorization_code",
|
||||
"code": accept_grant_code,
|
||||
"client_id": self.client_id,
|
||||
"client_secret": self.client_secret,
|
||||
CONF_CLIENT_ID: self.client_id,
|
||||
CONF_CLIENT_SECRET: self.client_secret,
|
||||
}
|
||||
_LOGGER.debug(
|
||||
"Calling LWA to get the access token (first time), with: %s",
|
||||
|
@ -80,8 +80,8 @@ class Auth:
|
|||
lwa_params = {
|
||||
"grant_type": "refresh_token",
|
||||
"refresh_token": self._prefs[STORAGE_REFRESH_TOKEN],
|
||||
"client_id": self.client_id,
|
||||
"client_secret": self.client_secret,
|
||||
CONF_CLIENT_ID: self.client_id,
|
||||
CONF_CLIENT_SECRET: self.client_secret,
|
||||
}
|
||||
|
||||
_LOGGER.debug("Calling LWA to refresh the access token.")
|
||||
|
|
|
@ -18,8 +18,6 @@ CONF_DISPLAY_URL = "display_url"
|
|||
CONF_FILTER = "filter"
|
||||
CONF_ENTITY_CONFIG = "entity_config"
|
||||
CONF_ENDPOINT = "endpoint"
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
CONF_LOCALE = "locale"
|
||||
|
||||
ATTR_UID = "uid"
|
||||
|
|
|
@ -3,17 +3,11 @@ import logging
|
|||
|
||||
from homeassistant import core
|
||||
from homeassistant.components.http.view import HomeAssistantView
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
|
||||
from .auth import Auth
|
||||
from .config import AbstractConfig
|
||||
from .const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_ENDPOINT,
|
||||
CONF_ENTITY_CONFIG,
|
||||
CONF_FILTER,
|
||||
CONF_LOCALE,
|
||||
)
|
||||
from .const import CONF_ENDPOINT, CONF_ENTITY_CONFIG, CONF_FILTER, CONF_LOCALE
|
||||
from .smart_home import async_handle_message
|
||||
from .state_report import async_enable_proactive_mode
|
||||
|
||||
|
|
|
@ -13,7 +13,13 @@ import voluptuous as vol
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.auth.const import GROUP_ID_ADMIN
|
||||
from homeassistant.components import conversation
|
||||
from homeassistant.const import CONF_HOST, CONF_TYPE, EVENT_HOMEASSISTANT_START
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_HOST,
|
||||
CONF_TYPE,
|
||||
EVENT_HOMEASSISTANT_START,
|
||||
)
|
||||
from homeassistant.core import Context, CoreState, HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import (
|
||||
|
@ -29,9 +35,6 @@ from homeassistant.helpers import (
|
|||
from . import config_flow
|
||||
from .const import DOMAIN, TYPE_LOCAL, TYPE_OAUTH2
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
|
||||
STORAGE_VERSION = 1
|
||||
STORAGE_KEY = DOMAIN
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@ import logging
|
|||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
||||
from . import config_flow
|
||||
from .const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, DOMAIN
|
||||
from .const import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -11,14 +11,18 @@ from homeassistant.components.climate.const import (
|
|||
HVAC_MODE_OFF,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
)
|
||||
from homeassistant.const import ATTR_NAME, ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||
from homeassistant.const import (
|
||||
ATTR_NAME,
|
||||
ATTR_TEMPERATURE,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
TEMP_CELSIUS,
|
||||
)
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
from .const import (
|
||||
ATTR_VALUE,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
DOMAIN,
|
||||
SERVICE_COMFORT_FEEDBACK,
|
||||
SERVICE_COMFORT_MODE,
|
||||
|
|
|
@ -5,6 +5,7 @@ import ambiclimate
|
|||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.network import get_url
|
||||
|
@ -12,8 +13,6 @@ from homeassistant.helpers.network import get_url
|
|||
from .const import (
|
||||
AUTH_CALLBACK_NAME,
|
||||
AUTH_CALLBACK_PATH,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
DOMAIN,
|
||||
STORAGE_KEY,
|
||||
STORAGE_VERSION,
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
"""Constants used by the Ambiclimate component."""
|
||||
|
||||
ATTR_VALUE = "value"
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
DOMAIN = "ambiclimate"
|
||||
|
||||
ATTR_VALUE = "value"
|
||||
|
||||
SERVICE_COMFORT_FEEDBACK = "send_comfort_feedback"
|
||||
SERVICE_COMFORT_MODE = "set_comfort_mode"
|
||||
SERVICE_TEMPERATURE_MODE = "set_temperature_mode"
|
||||
|
||||
STORAGE_KEY = "ambiclimate_auth"
|
||||
STORAGE_VERSION = 1
|
||||
|
||||
|
|
|
@ -10,19 +10,17 @@ from homeassistant.components.device_tracker import (
|
|||
PLATFORM_SCHEMA,
|
||||
DeviceScanner,
|
||||
)
|
||||
from homeassistant.const import CONF_API_KEY, CONF_HOST
|
||||
from homeassistant.const import CONF_API_KEY, CONF_CLIENT_ID, CONF_HOST
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=120)
|
||||
|
||||
CLIENT_ID = "client_id"
|
||||
|
||||
GRANT_TYPE = "client_credentials"
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
vol.Required(CLIENT_ID): cv.string,
|
||||
vol.Required(CONF_CLIENT_ID): cv.string,
|
||||
vol.Required(CONF_API_KEY): cv.string,
|
||||
}
|
||||
)
|
||||
|
@ -37,7 +35,7 @@ def get_scanner(hass, config):
|
|||
"server": config[DOMAIN][CONF_HOST],
|
||||
"grant_type": GRANT_TYPE,
|
||||
"secret": config[DOMAIN][CONF_API_KEY],
|
||||
"client": config[DOMAIN][CLIENT_ID],
|
||||
"client": config[DOMAIN][CONF_CLIENT_ID],
|
||||
}
|
||||
cppm = ClearPass(data)
|
||||
if cppm.access_token is None:
|
||||
|
|
|
@ -13,6 +13,8 @@ from homeassistant.components.http import HomeAssistantView
|
|||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import (
|
||||
ATTR_ATTRIBUTION,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_UNIT_SYSTEM,
|
||||
MASS_KILOGRAMS,
|
||||
MASS_MILLIGRAMS,
|
||||
|
@ -32,8 +34,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
ATTR_ACCESS_TOKEN = "access_token"
|
||||
ATTR_REFRESH_TOKEN = "refresh_token"
|
||||
ATTR_CLIENT_ID = "client_id"
|
||||
ATTR_CLIENT_SECRET = "client_secret"
|
||||
ATTR_LAST_SAVED_AT = "last_saved_at"
|
||||
|
||||
CONF_MONITORED_RESOURCES = "monitored_resources"
|
||||
|
@ -47,7 +47,10 @@ FITBIT_DEFAULT_RESOURCES = ["activities/steps"]
|
|||
|
||||
SCAN_INTERVAL = datetime.timedelta(minutes=30)
|
||||
|
||||
DEFAULT_CONFIG = {"client_id": "CLIENT_ID_HERE", "client_secret": "CLIENT_SECRET_HERE"}
|
||||
DEFAULT_CONFIG = {
|
||||
CONF_CLIENT_ID: "CLIENT_ID_HERE",
|
||||
CONF_CLIENT_SECRET: "CLIENT_SECRET_HERE",
|
||||
}
|
||||
|
||||
FITBIT_RESOURCES_LIST = {
|
||||
"activities/activityCalories": ["Activity Calories", "cal", "fire"],
|
||||
|
@ -251,8 +254,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
expires_at = config_file.get(ATTR_LAST_SAVED_AT)
|
||||
if None not in (access_token, refresh_token):
|
||||
authd_client = Fitbit(
|
||||
config_file.get(ATTR_CLIENT_ID),
|
||||
config_file.get(ATTR_CLIENT_SECRET),
|
||||
config_file.get(CONF_CLIENT_ID),
|
||||
config_file.get(CONF_CLIENT_SECRET),
|
||||
access_token=access_token,
|
||||
refresh_token=refresh_token,
|
||||
expires_at=expires_at,
|
||||
|
@ -305,7 +308,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
|
||||
else:
|
||||
oauth = FitbitOauth2Client(
|
||||
config_file.get(ATTR_CLIENT_ID), config_file.get(ATTR_CLIENT_SECRET)
|
||||
config_file.get(CONF_CLIENT_ID), config_file.get(CONF_CLIENT_SECRET)
|
||||
)
|
||||
|
||||
redirect_uri = f"{get_url(hass)}{FITBIT_AUTH_CALLBACK_PATH}"
|
||||
|
@ -388,8 +391,8 @@ class FitbitAuthCallbackView(HomeAssistantView):
|
|||
config_contents = {
|
||||
ATTR_ACCESS_TOKEN: result.get("access_token"),
|
||||
ATTR_REFRESH_TOKEN: result.get("refresh_token"),
|
||||
ATTR_CLIENT_ID: self.oauth.client_id,
|
||||
ATTR_CLIENT_SECRET: self.oauth.client_secret,
|
||||
CONF_CLIENT_ID: self.oauth.client_id,
|
||||
CONF_CLIENT_SECRET: self.oauth.client_secret,
|
||||
ATTR_LAST_SAVED_AT: int(time.time()),
|
||||
}
|
||||
save_json(hass.config.path(FITBIT_CONFIG_FILE), config_contents)
|
||||
|
@ -514,8 +517,8 @@ class FitbitSensor(Entity):
|
|||
config_contents = {
|
||||
ATTR_ACCESS_TOKEN: token.get("access_token"),
|
||||
ATTR_REFRESH_TOKEN: token.get("refresh_token"),
|
||||
ATTR_CLIENT_ID: self.client.client.client_id,
|
||||
ATTR_CLIENT_SECRET: self.client.client.client_secret,
|
||||
CONF_CLIENT_ID: self.client.client.client_id,
|
||||
CONF_CLIENT_SECRET: self.client.client.client_secret,
|
||||
ATTR_LAST_SAVED_AT: int(time.time()),
|
||||
}
|
||||
save_json(self.config_path, config_contents)
|
||||
|
|
|
@ -6,14 +6,17 @@ from ritassist import API
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.device_tracker import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.event import track_utc_time_change
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
CONF_INCLUDE = "include"
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
|
|
|
@ -8,14 +8,17 @@ from requests import Session
|
|||
from requests.exceptions import RequestException
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
|
||||
from .const import (
|
||||
BASE_TOKEN_FILENAME,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
DOMAIN,
|
||||
FLUME_AUTH,
|
||||
FLUME_DEVICES,
|
||||
|
|
|
@ -7,9 +7,14 @@ from requests.exceptions import RequestException
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, core, exceptions
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
|
||||
from .const import BASE_TOKEN_FILENAME, CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from .const import BASE_TOKEN_FILENAME
|
||||
from .const import DOMAIN # pylint:disable=unused-import
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
|
|
@ -5,8 +5,6 @@ PLATFORMS = ["sensor"]
|
|||
|
||||
DEFAULT_NAME = "Flume Sensor"
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
FLUME_TYPE_SENSOR = 2
|
||||
|
||||
FLUME_AUTH = "flume_auth"
|
||||
|
|
|
@ -7,14 +7,18 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.config_entries import SOURCE_IMPORT
|
||||
from homeassistant.const import CONF_NAME, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_NAME,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
from .const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
DEFAULT_NAME,
|
||||
DOMAIN,
|
||||
FLUME_AUTH,
|
||||
|
|
|
@ -15,6 +15,7 @@ import voluptuous as vol
|
|||
from voluptuous.error import Error as VoluptuousError
|
||||
import yaml
|
||||
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.helpers import discovery
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import generate_entity_id
|
||||
|
@ -26,8 +27,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||
DOMAIN = "google"
|
||||
ENTITY_ID_FORMAT = DOMAIN + ".{}"
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
CONF_TRACK_NEW = "track_new_calendar"
|
||||
|
||||
CONF_CAL_ID = "cal_id"
|
||||
|
|
|
@ -4,14 +4,14 @@ import logging
|
|||
from lmnotify import LaMetricManager
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
|
||||
DOMAIN = "lametric"
|
||||
|
||||
LAMETRIC_DEVICES = "LAMETRIC_DEVICES"
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
|
|
|
@ -12,6 +12,8 @@ from homeassistant import config_entries
|
|||
from homeassistant.components.camera import ATTR_FILENAME, CAMERA_SERVICE_SCHEMA
|
||||
from homeassistant.const import (
|
||||
ATTR_MODE,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_SENSORS,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
|
@ -22,8 +24,6 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
|
|||
from . import config_flow
|
||||
from .const import (
|
||||
CONF_API_KEY,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_REDIRECT_URI,
|
||||
DATA_LOGI,
|
||||
DEFAULT_CACHEDB,
|
||||
|
|
|
@ -9,17 +9,15 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.const import CONF_SENSORS, HTTP_BAD_REQUEST
|
||||
from homeassistant.core import callback
|
||||
|
||||
from .const import (
|
||||
CONF_API_KEY,
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_REDIRECT_URI,
|
||||
DEFAULT_CACHEDB,
|
||||
DOMAIN,
|
||||
CONF_SENSORS,
|
||||
HTTP_BAD_REQUEST,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
|
||||
from .const import CONF_API_KEY, CONF_REDIRECT_URI, DEFAULT_CACHEDB, DOMAIN
|
||||
|
||||
_TIMEOUT = 15 # seconds
|
||||
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
"""Constants in Logi Circle component."""
|
||||
from homeassistant.const import UNIT_PERCENTAGE
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
DOMAIN = "logi_circle"
|
||||
DATA_LOGI = DOMAIN
|
||||
|
||||
CONF_API_KEY = "api_key"
|
||||
CONF_REDIRECT_URI = "redirect_uri"
|
||||
|
||||
DEFAULT_CACHEDB = ".logi_cache.pickle"
|
||||
|
||||
DOMAIN = "logi_circle"
|
||||
DATA_LOGI = DOMAIN
|
||||
|
||||
LED_MODE_KEY = "LED"
|
||||
RECORDING_MODE_KEY = "RECORDING_MODE"
|
||||
|
|
|
@ -8,15 +8,13 @@ from lyft_rides.errors import APIError
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import TIME_MINUTES
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, TIME_MINUTES
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.util import Throttle
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
CONF_END_LATITUDE = "end_latitude"
|
||||
CONF_END_LONGITUDE = "end_longitude"
|
||||
CONF_PRODUCT_IDS = "product_ids"
|
||||
|
|
|
@ -6,14 +6,12 @@ from mastodon.Mastodon import MastodonAPIError, MastodonUnauthorizedError
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.notify import PLATFORM_SCHEMA, BaseNotificationService
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_BASE_URL = "base_url"
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
|
||||
DEFAULT_URL = "https://mastodon.social"
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import voluptuous as vol
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.components import websocket_api
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_DEVICE,
|
||||
CONF_NAME,
|
||||
CONF_PASSWORD,
|
||||
|
@ -70,7 +71,6 @@ SERVICE_DUMP = "dump"
|
|||
|
||||
CONF_EMBEDDED = "embedded"
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_DISCOVERY_PREFIX = "discovery_prefix"
|
||||
CONF_KEEPALIVE = "keepalive"
|
||||
CONF_CERTIFICATE = "certificate"
|
||||
|
|
|
@ -10,6 +10,8 @@ import voluptuous as vol
|
|||
from homeassistant import config_entries
|
||||
from homeassistant.const import (
|
||||
CONF_BINARY_SENSORS,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_FILENAME,
|
||||
CONF_MONITORED_CONDITIONS,
|
||||
CONF_SENSORS,
|
||||
|
@ -37,8 +39,6 @@ DATA_NEST_CONFIG = "nest_config"
|
|||
SIGNAL_NEST_UPDATE = "nest_update"
|
||||
|
||||
NEST_CONFIG_FILE = "nest.conf"
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
|
||||
ATTR_ETA = "eta"
|
||||
ATTR_ETA_WINDOW = "eta_window"
|
||||
|
|
|
@ -13,6 +13,7 @@ from homeassistant import config_entries
|
|||
from homeassistant.components.http.view import HomeAssistantView
|
||||
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_HOST,
|
||||
CONF_PORT,
|
||||
CONF_SSL,
|
||||
|
@ -29,7 +30,6 @@ from .const import ( # pylint: disable=unused-import
|
|||
AUTH_CALLBACK_NAME,
|
||||
AUTH_CALLBACK_PATH,
|
||||
AUTOMATIC_SETUP_STRING,
|
||||
CONF_CLIENT_IDENTIFIER,
|
||||
CONF_IGNORE_NEW_SHARED_USERS,
|
||||
CONF_IGNORE_PLEX_WEB_CLIENTS,
|
||||
CONF_MONITORED_USERS,
|
||||
|
@ -227,7 +227,7 @@ class PlexFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
|
||||
entry_config = {CONF_URL: url}
|
||||
if self.client_id:
|
||||
entry_config[CONF_CLIENT_IDENTIFIER] = self.client_id
|
||||
entry_config[CONF_CLIENT_ID] = self.client_id
|
||||
if token:
|
||||
entry_config[CONF_TOKEN] = token
|
||||
if url.startswith("https"):
|
||||
|
|
|
@ -24,7 +24,6 @@ PLEX_UPDATE_MEDIA_PLAYER_SIGNAL = "plex_update_mp_signal.{}"
|
|||
PLEX_UPDATE_PLATFORMS_SIGNAL = "plex_update_platforms_signal.{}"
|
||||
PLEX_UPDATE_SENSOR_SIGNAL = "plex_update_sensor_signal.{}"
|
||||
|
||||
CONF_CLIENT_IDENTIFIER = "client_id"
|
||||
CONF_SERVER = "server"
|
||||
CONF_SERVER_IDENTIFIER = "server_id"
|
||||
CONF_USE_EPISODE_ART = "use_episode_art"
|
||||
|
|
|
@ -17,13 +17,12 @@ from homeassistant.components.media_player.const import (
|
|||
MEDIA_TYPE_PLAYLIST,
|
||||
MEDIA_TYPE_VIDEO,
|
||||
)
|
||||
from homeassistant.const import CONF_TOKEN, CONF_URL, CONF_VERIFY_SSL
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_TOKEN, CONF_URL, CONF_VERIFY_SSL
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.debounce import Debouncer
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
||||
from .const import (
|
||||
CONF_CLIENT_IDENTIFIER,
|
||||
CONF_IGNORE_NEW_SHARED_USERS,
|
||||
CONF_IGNORE_PLEX_WEB_CLIENTS,
|
||||
CONF_MONITORED_USERS,
|
||||
|
@ -81,8 +80,8 @@ class PlexServer:
|
|||
).async_call
|
||||
|
||||
# Header conditionally added as it is not available in config entry v1
|
||||
if CONF_CLIENT_IDENTIFIER in server_config:
|
||||
plexapi.X_PLEX_IDENTIFIER = server_config[CONF_CLIENT_IDENTIFIER]
|
||||
if CONF_CLIENT_ID in server_config:
|
||||
plexapi.X_PLEX_IDENTIFIER = server_config[CONF_CLIENT_ID]
|
||||
plexapi.myplex.BASE_HEADERS = plexapi.reset_base_headers()
|
||||
plexapi.server.BASE_HEADERS = plexapi.reset_base_headers()
|
||||
|
||||
|
|
|
@ -7,7 +7,12 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_TOKEN, CONF_WEBHOOK_ID
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_TOKEN,
|
||||
CONF_WEBHOOK_ID,
|
||||
)
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.dispatcher import (
|
||||
async_dispatcher_connect,
|
||||
|
@ -31,9 +36,6 @@ from .const import (
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
|
||||
DATA_CONFIG_ENTRY_LOCK = "point_config_entry_lock"
|
||||
CONFIG_ENTRY_IS_SETUP = "point_config_entry_is_setup"
|
||||
|
||||
|
@ -82,7 +84,7 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
|||
# Force token update.
|
||||
entry.data[CONF_TOKEN]["expires_in"] = -1
|
||||
session = PointSession(
|
||||
entry.data["refresh_args"]["client_id"],
|
||||
entry.data["refresh_args"][CONF_CLIENT_ID],
|
||||
token=entry.data[CONF_TOKEN],
|
||||
auto_refresh_kwargs=entry.data["refresh_args"],
|
||||
token_saver=token_saver,
|
||||
|
|
|
@ -9,9 +9,10 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.http import HomeAssistantView
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.core import callback
|
||||
|
||||
from .const import CLIENT_ID, CLIENT_SECRET, DOMAIN
|
||||
from .const import DOMAIN
|
||||
|
||||
AUTH_CALLBACK_PATH = "/api/minut"
|
||||
AUTH_CALLBACK_NAME = "api:minut"
|
||||
|
@ -34,8 +35,8 @@ def register_flow_implementation(hass, domain, client_id, client_secret):
|
|||
hass.data[DATA_FLOW_IMPL] = OrderedDict()
|
||||
|
||||
hass.data[DATA_FLOW_IMPL][domain] = {
|
||||
CLIENT_ID: client_id,
|
||||
CLIENT_SECRET: client_secret,
|
||||
CONF_CLIENT_ID: client_id,
|
||||
CONF_CLIENT_SECRET: client_secret,
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,8 +113,8 @@ class PointFlowHandler(config_entries.ConfigFlow):
|
|||
"""Create Minut Point session and get authorization url."""
|
||||
|
||||
flow = self.hass.data[DATA_FLOW_IMPL][self.flow_impl]
|
||||
client_id = flow[CLIENT_ID]
|
||||
client_secret = flow[CLIENT_SECRET]
|
||||
client_id = flow[CONF_CLIENT_ID]
|
||||
client_secret = flow[CONF_CLIENT_SECRET]
|
||||
point_session = PointSession(client_id, client_secret=client_secret)
|
||||
|
||||
self.hass.http.register_view(MinutAuthCallbackView())
|
||||
|
@ -140,8 +141,8 @@ class PointFlowHandler(config_entries.ConfigFlow):
|
|||
"""Create point session and entries."""
|
||||
|
||||
flow = self.hass.data[DATA_FLOW_IMPL][DOMAIN]
|
||||
client_id = flow[CLIENT_ID]
|
||||
client_secret = flow[CLIENT_SECRET]
|
||||
client_id = flow[CONF_CLIENT_ID]
|
||||
client_secret = flow[CONF_CLIENT_SECRET]
|
||||
point_session = PointSession(client_id, client_secret=client_secret)
|
||||
token = await self.hass.async_add_executor_job(
|
||||
point_session.get_access_token, code
|
||||
|
@ -159,8 +160,8 @@ class PointFlowHandler(config_entries.ConfigFlow):
|
|||
data={
|
||||
"token": token,
|
||||
"refresh_args": {
|
||||
"client_id": client_id,
|
||||
"client_secret": client_secret,
|
||||
CONF_CLIENT_ID: client_id,
|
||||
CONF_CLIENT_SECRET: client_secret,
|
||||
},
|
||||
},
|
||||
)
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
from datetime import timedelta
|
||||
|
||||
DOMAIN = "point"
|
||||
CLIENT_ID = "client_id"
|
||||
CLIENT_SECRET = "client_secret"
|
||||
|
||||
|
||||
SCAN_INTERVAL = timedelta(minutes=1)
|
||||
|
||||
|
|
|
@ -6,14 +6,18 @@ import praw
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_MAXIMUM, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_MAXIMUM,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
CONF_SORT_BY = "sort_by"
|
||||
CONF_SUBREDDITS = "subreddits"
|
||||
|
||||
|
|
|
@ -7,7 +7,13 @@ from requests.exceptions import RequestException
|
|||
import smappy
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_HOST,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.discovery import load_platform
|
||||
from homeassistant.util import Throttle
|
||||
|
@ -17,8 +23,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||
DEFAULT_NAME = "Smappee"
|
||||
DEFAULT_HOST_PASSWORD = "admin"
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
CONF_HOST_PASSWORD = "host_password"
|
||||
|
||||
DOMAIN = "smappee"
|
||||
|
|
|
@ -9,7 +9,12 @@ from pysmartapp.event import EVENT_TYPE_DEVICE
|
|||
from pysmartthings import Attribute, Capability, SmartThings
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, HTTP_FORBIDDEN
|
||||
from homeassistant.const import (
|
||||
CONF_ACCESS_TOKEN,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
HTTP_FORBIDDEN,
|
||||
)
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.dispatcher import (
|
||||
|
@ -25,8 +30,6 @@ from .const import (
|
|||
CONF_APP_ID,
|
||||
CONF_INSTALLED_APP_ID,
|
||||
CONF_LOCATION_ID,
|
||||
CONF_OAUTH_CLIENT_ID,
|
||||
CONF_OAUTH_CLIENT_SECRET,
|
||||
CONF_REFRESH_TOKEN,
|
||||
DATA_BROKERS,
|
||||
DATA_MANAGER,
|
||||
|
@ -115,8 +118,8 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry):
|
|||
|
||||
# Get SmartApp token to sync subscriptions
|
||||
token = await api.generate_tokens(
|
||||
entry.data[CONF_OAUTH_CLIENT_ID],
|
||||
entry.data[CONF_OAUTH_CLIENT_SECRET],
|
||||
entry.data[CONF_CLIENT_ID],
|
||||
entry.data[CONF_CLIENT_SECRET],
|
||||
entry.data[CONF_REFRESH_TOKEN],
|
||||
)
|
||||
hass.config_entries.async_update_entry(
|
||||
|
@ -312,8 +315,7 @@ class DeviceBroker:
|
|||
async def regenerate_refresh_token(now):
|
||||
"""Generate a new refresh token and update the config entry."""
|
||||
await self._token.refresh(
|
||||
self._entry.data[CONF_OAUTH_CLIENT_ID],
|
||||
self._entry.data[CONF_OAUTH_CLIENT_SECRET],
|
||||
self._entry.data[CONF_CLIENT_ID], self._entry.data[CONF_CLIENT_SECRET],
|
||||
)
|
||||
self._hass.config_entries.async_update_entry(
|
||||
self._entry,
|
||||
|
|
|
@ -7,7 +7,13 @@ from pysmartthings.installedapp import format_install_url
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, HTTP_FORBIDDEN, HTTP_UNAUTHORIZED
|
||||
from homeassistant.const import (
|
||||
CONF_ACCESS_TOKEN,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
HTTP_FORBIDDEN,
|
||||
HTTP_UNAUTHORIZED,
|
||||
)
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
|
||||
# pylint: disable=unused-import
|
||||
|
@ -17,8 +23,6 @@ from .const import (
|
|||
CONF_APP_ID,
|
||||
CONF_INSTALLED_APP_ID,
|
||||
CONF_LOCATION_ID,
|
||||
CONF_OAUTH_CLIENT_ID,
|
||||
CONF_OAUTH_CLIENT_SECRET,
|
||||
CONF_REFRESH_TOKEN,
|
||||
DOMAIN,
|
||||
VAL_UID_MATCHER,
|
||||
|
@ -112,8 +116,8 @@ class SmartThingsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
None,
|
||||
)
|
||||
if existing:
|
||||
self.oauth_client_id = existing.data[CONF_OAUTH_CLIENT_ID]
|
||||
self.oauth_client_secret = existing.data[CONF_OAUTH_CLIENT_SECRET]
|
||||
self.oauth_client_id = existing.data[CONF_CLIENT_ID]
|
||||
self.oauth_client_secret = existing.data[CONF_CLIENT_SECRET]
|
||||
else:
|
||||
# Get oauth client id/secret by regenerating it
|
||||
app_oauth = AppOAuth(app.app_id)
|
||||
|
@ -227,8 +231,8 @@ class SmartThingsFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
data = {
|
||||
CONF_ACCESS_TOKEN: self.access_token,
|
||||
CONF_REFRESH_TOKEN: self.refresh_token,
|
||||
CONF_OAUTH_CLIENT_ID: self.oauth_client_id,
|
||||
CONF_OAUTH_CLIENT_SECRET: self.oauth_client_secret,
|
||||
CONF_CLIENT_ID: self.oauth_client_id,
|
||||
CONF_CLIENT_SECRET: self.oauth_client_secret,
|
||||
CONF_LOCATION_ID: self.location_id,
|
||||
CONF_APP_ID: self.app_id,
|
||||
CONF_INSTALLED_APP_ID: self.installed_app_id,
|
||||
|
|
|
@ -2,26 +2,31 @@
|
|||
from datetime import timedelta
|
||||
import re
|
||||
|
||||
DOMAIN = "smartthings"
|
||||
|
||||
APP_OAUTH_CLIENT_NAME = "Home Assistant"
|
||||
APP_OAUTH_SCOPES = ["r:devices:*"]
|
||||
APP_NAME_PREFIX = "homeassistant."
|
||||
|
||||
CONF_APP_ID = "app_id"
|
||||
CONF_CLOUDHOOK_URL = "cloudhook_url"
|
||||
CONF_INSTALLED_APP_ID = "installed_app_id"
|
||||
CONF_INSTANCE_ID = "instance_id"
|
||||
CONF_LOCATION_ID = "location_id"
|
||||
CONF_OAUTH_CLIENT_ID = "client_id"
|
||||
CONF_OAUTH_CLIENT_SECRET = "client_secret"
|
||||
CONF_REFRESH_TOKEN = "refresh_token"
|
||||
|
||||
DATA_MANAGER = "manager"
|
||||
DATA_BROKERS = "brokers"
|
||||
DOMAIN = "smartthings"
|
||||
EVENT_BUTTON = "smartthings.button"
|
||||
|
||||
SIGNAL_SMARTTHINGS_UPDATE = "smartthings_update"
|
||||
SIGNAL_SMARTAPP_PREFIX = "smartthings_smartap_"
|
||||
|
||||
SETTINGS_INSTANCE_ID = "hassInstanceId"
|
||||
|
||||
STORAGE_KEY = DOMAIN
|
||||
STORAGE_VERSION = 1
|
||||
|
||||
# Ordered 'specific to least-specific platform' in order for capabilities
|
||||
# to be drawn-down and represented by the most appropriate platform.
|
||||
SUPPORTED_PLATFORMS = [
|
||||
|
@ -35,6 +40,8 @@ SUPPORTED_PLATFORMS = [
|
|||
"sensor",
|
||||
"scene",
|
||||
]
|
||||
|
||||
TOKEN_REFRESH_INTERVAL = timedelta(days=14)
|
||||
|
||||
VAL_UID = "^(?:([0-9a-fA-F]{32})|([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}))$"
|
||||
VAL_UID_MATCHER = re.compile(VAL_UID)
|
||||
|
|
|
@ -9,6 +9,7 @@ import voluptuous as vol
|
|||
|
||||
from homeassistant.components.somfy import config_flow
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.helpers import (
|
||||
config_entry_oauth2_flow,
|
||||
config_validation as cv,
|
||||
|
@ -19,6 +20,7 @@ from homeassistant.helpers.typing import HomeAssistantType
|
|||
from homeassistant.util import Throttle
|
||||
|
||||
from . import api
|
||||
from .const import DOMAIN
|
||||
|
||||
API = "api"
|
||||
|
||||
|
@ -28,10 +30,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
||||
DOMAIN = "somfy"
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
CONF_OPTIMISTIC = "optimistic"
|
||||
|
||||
SOMFY_AUTH_CALLBACK_PATH = "/auth/somfy/callback"
|
||||
|
|
|
@ -6,7 +6,7 @@ import voluptuous as vol
|
|||
from homeassistant.components.media_player import DOMAIN as MEDIA_PLAYER_DOMAIN
|
||||
from homeassistant.components.spotify import config_flow
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_CREDENTIALS
|
||||
from homeassistant.const import ATTR_CREDENTIALS, CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import ConfigEntryNotReady
|
||||
from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv
|
||||
|
@ -16,14 +16,7 @@ from homeassistant.helpers.config_entry_oauth2_flow import (
|
|||
)
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
DATA_SPOTIFY_CLIENT,
|
||||
DATA_SPOTIFY_ME,
|
||||
DATA_SPOTIFY_SESSION,
|
||||
DOMAIN,
|
||||
)
|
||||
from .const import DATA_SPOTIFY_CLIENT, DATA_SPOTIFY_ME, DATA_SPOTIFY_SESSION, DOMAIN
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
DOMAIN = "spotify"
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
|
||||
DATA_SPOTIFY_CLIENT = "spotify_client"
|
||||
DATA_SPOTIFY_ME = "spotify_me"
|
||||
DATA_SPOTIFY_SESSION = "spotify_session"
|
||||
|
|
|
@ -6,7 +6,13 @@ from typing import Any, Dict
|
|||
from toonapilib import Toon
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_SCAN_INTERVAL, CONF_USERNAME
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_PASSWORD,
|
||||
CONF_SCAN_INTERVAL,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
|
||||
|
@ -16,8 +22,6 @@ from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
|||
|
||||
from . import config_flow # noqa: F401
|
||||
from .const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_DISPLAY,
|
||||
CONF_TENANT,
|
||||
DATA_TOON,
|
||||
|
|
|
@ -13,17 +13,15 @@ from toonapilib.toonapilibexceptions import (
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.core import callback
|
||||
|
||||
from .const import (
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_DISPLAY,
|
||||
CONF_TENANT,
|
||||
DATA_TOON_CONFIG,
|
||||
DOMAIN,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.core import callback
|
||||
|
||||
from .const import CONF_DISPLAY, CONF_TENANT, DATA_TOON_CONFIG, DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -94,10 +92,10 @@ class ToonFlowHandler(config_entries.ConfigFlow):
|
|||
displays = toon.display_names
|
||||
|
||||
except InvalidConsumerKey:
|
||||
return self.async_abort(reason="client_id")
|
||||
return self.async_abort(reason=CONF_CLIENT_ID)
|
||||
|
||||
except InvalidConsumerSecret:
|
||||
return self.async_abort(reason="client_secret")
|
||||
return self.async_abort(reason=CONF_CLIENT_SECRET)
|
||||
|
||||
except InvalidCredentials:
|
||||
return await self._show_authenticaticate_form({"base": "credentials"})
|
||||
|
|
|
@ -8,8 +8,6 @@ DATA_TOON_CLIENT = "toon_client"
|
|||
DATA_TOON_CONFIG = "toon_config"
|
||||
DATA_TOON_UPDATED = "toon_updated"
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
CONF_DISPLAY = "display"
|
||||
CONF_TENANT = "tenant"
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from twitch import TwitchClient
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||
from homeassistant.const import CONF_TOKEN
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_TOKEN
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.entity import Entity
|
||||
|
||||
|
@ -23,7 +23,6 @@ ATTR_FOLLOWING = "followers"
|
|||
ATTR_VIEWS = "views"
|
||||
|
||||
CONF_CHANNELS = "channels"
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
|
||||
ICON = "mdi:twitch"
|
||||
|
||||
|
|
|
@ -14,6 +14,8 @@ from homeassistant.components.http import HomeAssistantView
|
|||
from homeassistant.const import (
|
||||
ATTR_BATTERY_LEVEL,
|
||||
ATTR_NAME,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_EMAIL,
|
||||
CONF_PASSWORD,
|
||||
EVENT_HOMEASSISTANT_START,
|
||||
|
@ -38,8 +40,6 @@ DOMAIN = "wink"
|
|||
|
||||
SUBSCRIPTION_HANDLER = None
|
||||
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
CONF_CLIENT_SECRET = "client_secret"
|
||||
CONF_USER_AGENT = "user_agent"
|
||||
CONF_OAUTH = "oauth"
|
||||
CONF_LOCAL_CONTROL = "local_control"
|
||||
|
@ -47,8 +47,6 @@ CONF_MISSING_OAUTH_MSG = "Missing oauth2 credentials."
|
|||
|
||||
ATTR_ACCESS_TOKEN = "access_token"
|
||||
ATTR_REFRESH_TOKEN = "refresh_token"
|
||||
ATTR_CLIENT_ID = "client_id"
|
||||
ATTR_CLIENT_SECRET = "client_secret"
|
||||
ATTR_PAIRING_MODE = "pairing_mode"
|
||||
ATTR_KIDDE_RADIO_CODE = "kidde_radio_code"
|
||||
ATTR_HUB_NAME = "hub_name"
|
||||
|
@ -58,7 +56,10 @@ WINK_AUTH_START = "/auth/wink"
|
|||
WINK_CONFIG_FILE = ".wink.conf"
|
||||
USER_AGENT = f"Manufacturer/Home-Assistant{__version__} python/3 Wink/3"
|
||||
|
||||
DEFAULT_CONFIG = {"client_id": "CLIENT_ID_HERE", "client_secret": "CLIENT_SECRET_HERE"}
|
||||
DEFAULT_CONFIG = {
|
||||
CONF_CLIENT_ID: "CLIENT_ID_HERE",
|
||||
CONF_CLIENT_SECRET: "CLIENT_SECRET_HERE",
|
||||
}
|
||||
|
||||
SERVICE_ADD_NEW_DEVICES = "pull_newly_added_devices_from_wink"
|
||||
SERVICE_REFRESH_STATES = "refresh_state_from_wink"
|
||||
|
@ -219,12 +220,12 @@ def _request_app_setup(hass, config):
|
|||
setup(hass, config)
|
||||
return
|
||||
|
||||
client_id = callback_data.get("client_id").strip()
|
||||
client_secret = callback_data.get("client_secret").strip()
|
||||
client_id = callback_data.get(CONF_CLIENT_ID).strip()
|
||||
client_secret = callback_data.get(CONF_CLIENT_SECRET).strip()
|
||||
if None not in (client_id, client_secret):
|
||||
save_json(
|
||||
_config_path,
|
||||
{ATTR_CLIENT_ID: client_id, ATTR_CLIENT_SECRET: client_secret},
|
||||
{CONF_CLIENT_ID: client_id, CONF_CLIENT_SECRET: client_secret},
|
||||
)
|
||||
setup(hass, config)
|
||||
return
|
||||
|
@ -249,8 +250,8 @@ def _request_app_setup(hass, config):
|
|||
submit_caption="submit",
|
||||
description_image="/static/images/config_wink.png",
|
||||
fields=[
|
||||
{"id": "client_id", "name": "Client ID", "type": "string"},
|
||||
{"id": "client_secret", "name": "Client secret", "type": "string"},
|
||||
{"id": CONF_CLIENT_ID, "name": "Client ID", "type": "string"},
|
||||
{"id": CONF_CLIENT_SECRET, "name": "Client secret", "type": "string"},
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -293,8 +294,8 @@ def setup(hass, config):
|
|||
}
|
||||
|
||||
if config.get(DOMAIN) is not None:
|
||||
client_id = config[DOMAIN].get(ATTR_CLIENT_ID)
|
||||
client_secret = config[DOMAIN].get(ATTR_CLIENT_SECRET)
|
||||
client_id = config[DOMAIN].get(CONF_CLIENT_ID)
|
||||
client_secret = config[DOMAIN].get(CONF_CLIENT_SECRET)
|
||||
email = config[DOMAIN].get(CONF_EMAIL)
|
||||
password = config[DOMAIN].get(CONF_PASSWORD)
|
||||
local_control = config[DOMAIN].get(CONF_LOCAL_CONTROL)
|
||||
|
@ -309,8 +310,8 @@ def setup(hass, config):
|
|||
_LOGGER.info("Using legacy OAuth authentication")
|
||||
if not local_control:
|
||||
pywink.disable_local_control()
|
||||
hass.data[DOMAIN]["oauth"]["client_id"] = client_id
|
||||
hass.data[DOMAIN]["oauth"]["client_secret"] = client_secret
|
||||
hass.data[DOMAIN]["oauth"][CONF_CLIENT_ID] = client_id
|
||||
hass.data[DOMAIN]["oauth"][CONF_CLIENT_SECRET] = client_secret
|
||||
hass.data[DOMAIN]["oauth"]["email"] = email
|
||||
hass.data[DOMAIN]["oauth"]["password"] = password
|
||||
pywink.legacy_set_wink_credentials(email, password, client_id, client_secret)
|
||||
|
@ -341,8 +342,8 @@ def setup(hass, config):
|
|||
# This will be called after authorizing Home-Assistant
|
||||
if None not in (access_token, refresh_token):
|
||||
pywink.set_wink_credentials(
|
||||
config_file.get(ATTR_CLIENT_ID),
|
||||
config_file.get(ATTR_CLIENT_SECRET),
|
||||
config_file.get(CONF_CLIENT_ID),
|
||||
config_file.get(CONF_CLIENT_SECRET),
|
||||
access_token=access_token,
|
||||
refresh_token=refresh_token,
|
||||
)
|
||||
|
@ -353,7 +354,7 @@ def setup(hass, config):
|
|||
redirect_uri = f"{get_url(hass)}{WINK_AUTH_CALLBACK_PATH}"
|
||||
|
||||
wink_auth_start_url = pywink.get_authorization_url(
|
||||
config_file.get(ATTR_CLIENT_ID), redirect_uri
|
||||
config_file.get(CONF_CLIENT_ID), redirect_uri
|
||||
)
|
||||
hass.http.register_redirect(WINK_AUTH_START, wink_auth_start_url)
|
||||
hass.http.register_view(
|
||||
|
@ -698,14 +699,14 @@ class WinkAuthCallbackView(HomeAssistantView):
|
|||
|
||||
if data.get("code") is not None:
|
||||
response = self.request_token(
|
||||
data.get("code"), self.config_file["client_secret"]
|
||||
data.get("code"), self.config_file[CONF_CLIENT_SECRET]
|
||||
)
|
||||
|
||||
config_contents = {
|
||||
ATTR_ACCESS_TOKEN: response["access_token"],
|
||||
ATTR_REFRESH_TOKEN: response["refresh_token"],
|
||||
ATTR_CLIENT_ID: self.config_file["client_id"],
|
||||
ATTR_CLIENT_SECRET: self.config_file["client_secret"],
|
||||
CONF_CLIENT_ID: self.config_file[CONF_CLIENT_ID],
|
||||
CONF_CLIENT_SECRET: self.config_file[CONF_CLIENT_SECRET],
|
||||
}
|
||||
save_json(hass.config.path(WINK_CONFIG_FILE), config_contents)
|
||||
|
||||
|
|
|
@ -7,23 +7,21 @@ import voluptuous as vol
|
|||
from withings_api import WithingsAuth
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.helpers import config_entry_oauth2_flow, config_validation as cv
|
||||
from homeassistant.helpers.typing import ConfigType, HomeAssistantType
|
||||
|
||||
from . import config_flow, const
|
||||
from . import config_flow
|
||||
from .common import _LOGGER, NotAuthenticatedError, get_data_manager
|
||||
|
||||
DOMAIN = const.DOMAIN
|
||||
from .const import CONF_PROFILES, CONFIG, CREDENTIALS, DOMAIN
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
{
|
||||
vol.Required(const.CLIENT_ID): vol.All(cv.string, vol.Length(min=1)),
|
||||
vol.Required(const.CLIENT_SECRET): vol.All(
|
||||
cv.string, vol.Length(min=1)
|
||||
),
|
||||
vol.Required(const.PROFILES): vol.All(
|
||||
vol.Required(CONF_CLIENT_ID): vol.All(cv.string, vol.Length(min=1)),
|
||||
vol.Required(CONF_CLIENT_SECRET): vol.All(cv.string, vol.Length(min=1)),
|
||||
vol.Required(CONF_PROFILES): vol.All(
|
||||
cv.ensure_list,
|
||||
vol.Unique(),
|
||||
vol.Length(min=1),
|
||||
|
@ -42,15 +40,15 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool:
|
|||
if not conf:
|
||||
return True
|
||||
|
||||
hass.data[DOMAIN] = {const.CONFIG: conf}
|
||||
hass.data[DOMAIN] = {CONFIG: conf}
|
||||
|
||||
config_flow.WithingsFlowHandler.async_register_implementation(
|
||||
hass,
|
||||
config_entry_oauth2_flow.LocalOAuth2Implementation(
|
||||
hass,
|
||||
const.DOMAIN,
|
||||
conf[const.CLIENT_ID],
|
||||
conf[const.CLIENT_SECRET],
|
||||
DOMAIN,
|
||||
conf[CONF_CLIENT_ID],
|
||||
conf[CONF_CLIENT_SECRET],
|
||||
f"{WithingsAuth.URL}/oauth2_user/authorize2",
|
||||
f"{WithingsAuth.URL}/oauth2/token",
|
||||
),
|
||||
|
@ -65,12 +63,12 @@ async def async_setup_entry(hass: HomeAssistantType, entry: ConfigEntry) -> bool
|
|||
if "auth_implementation" not in entry.data:
|
||||
_LOGGER.debug("Upgrading existing config entry")
|
||||
data = entry.data
|
||||
creds = data.get(const.CREDENTIALS, {})
|
||||
creds = data.get(CREDENTIALS, {})
|
||||
hass.config_entries.async_update_entry(
|
||||
entry,
|
||||
data={
|
||||
"auth_implementation": const.DOMAIN,
|
||||
"implementation": const.DOMAIN,
|
||||
"auth_implementation": DOMAIN,
|
||||
"implementation": DOMAIN,
|
||||
"profile": data.get("profile"),
|
||||
"token": {
|
||||
"access_token": creds.get("access_token"),
|
||||
|
|
|
@ -51,7 +51,7 @@ class WithingsFlowHandler(config_entry_oauth2_flow.AbstractOAuth2FlowHandler):
|
|||
self._current_data = None
|
||||
return await self.async_step_finish(new_data)
|
||||
|
||||
profiles = self.hass.data[const.DOMAIN][const.CONFIG][const.PROFILES]
|
||||
profiles = self.hass.data[const.DOMAIN][const.CONFIG][const.CONF_PROFILES]
|
||||
return self.async_show_form(
|
||||
step_id="profile",
|
||||
data_schema=vol.Schema({vol.Required(const.PROFILE): vol.In(profiles)}),
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
"""Constants used by the Withings component."""
|
||||
import homeassistant.const as const
|
||||
|
||||
DOMAIN = "withings"
|
||||
|
||||
CONF_PROFILES = "profiles"
|
||||
|
||||
DATA_MANAGER = "data_manager"
|
||||
|
||||
BASE_URL = "base_url"
|
||||
CLIENT_ID = "client_id"
|
||||
CLIENT_SECRET = "client_secret"
|
||||
CODE = "code"
|
||||
CONFIG = "config"
|
||||
CREDENTIALS = "credentials"
|
||||
DOMAIN = "withings"
|
||||
LOG_NAMESPACE = "homeassistant.components.withings"
|
||||
MEASURES = "measures"
|
||||
PROFILE = "profile"
|
||||
PROFILES = "profiles"
|
||||
|
||||
AUTH_CALLBACK_PATH = "/api/withings/authorize"
|
||||
AUTH_CALLBACK_NAME = "withings:authorize"
|
||||
|
|
|
@ -4,13 +4,13 @@ import logging
|
|||
import voluptuous as vol
|
||||
from wunderpy2 import WunderApi
|
||||
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_NAME
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_CLIENT_ID, CONF_NAME
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
DOMAIN = "wunderlist"
|
||||
CONF_CLIENT_ID = "client_id"
|
||||
|
||||
CONF_LIST_NAME = "list_name"
|
||||
CONF_STARRED = "starred"
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
"""Test Alexa auth endpoints."""
|
||||
from homeassistant.components.alexa.auth import Auth
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
|
||||
from . import TEST_TOKEN_URL
|
||||
|
||||
|
@ -53,13 +54,13 @@ async def test_auth_get_access_token_expired(hass, aioclient_mock):
|
|||
|
||||
assert auth_call_json["grant_type"] == "authorization_code"
|
||||
assert auth_call_json["code"] == accept_grant_code
|
||||
assert auth_call_json["client_id"] == client_id
|
||||
assert auth_call_json["client_secret"] == client_secret
|
||||
assert auth_call_json[CONF_CLIENT_ID] == client_id
|
||||
assert auth_call_json[CONF_CLIENT_SECRET] == client_secret
|
||||
|
||||
assert token_call_json["grant_type"] == "refresh_token"
|
||||
assert token_call_json["refresh_token"] == refresh_token
|
||||
assert token_call_json["client_id"] == client_id
|
||||
assert token_call_json["client_secret"] == client_secret
|
||||
assert token_call_json[CONF_CLIENT_ID] == client_id
|
||||
assert token_call_json[CONF_CLIENT_SECRET] == client_secret
|
||||
|
||||
|
||||
async def test_auth_get_access_token_not_expired(hass, aioclient_mock):
|
||||
|
@ -86,5 +87,5 @@ async def test_auth_get_access_token_not_expired(hass, aioclient_mock):
|
|||
|
||||
assert auth_call_json["grant_type"] == "authorization_code"
|
||||
assert auth_call_json["code"] == accept_grant_code
|
||||
assert auth_call_json["client_id"] == client_id
|
||||
assert auth_call_json["client_secret"] == client_secret
|
||||
assert auth_call_json[CONF_CLIENT_ID] == client_id
|
||||
assert auth_call_json[CONF_CLIENT_SECRET] == client_secret
|
||||
|
|
|
@ -4,6 +4,7 @@ import asyncio
|
|||
from homeassistant import config_entries, data_entry_flow, setup
|
||||
from homeassistant.components.almond import config_flow
|
||||
from homeassistant.components.almond.const import DOMAIN
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from tests.async_mock import patch
|
||||
|
@ -17,9 +18,7 @@ async def test_import(hass):
|
|||
"""Test that we can import a config entry."""
|
||||
with patch("pyalmond.WebAlmondAPI.async_list_apps"):
|
||||
assert await setup.async_setup_component(
|
||||
hass,
|
||||
"almond",
|
||||
{"almond": {"type": "local", "host": "http://localhost:3000"}},
|
||||
hass, DOMAIN, {DOMAIN: {"type": "local", "host": "http://localhost:3000"}},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -35,9 +34,7 @@ async def test_import_cannot_connect(hass):
|
|||
"pyalmond.WebAlmondAPI.async_list_apps", side_effect=asyncio.TimeoutError
|
||||
):
|
||||
assert await setup.async_setup_component(
|
||||
hass,
|
||||
"almond",
|
||||
{"almond": {"type": "local", "host": "http://localhost:3000"}},
|
||||
hass, DOMAIN, {DOMAIN: {"type": "local", "host": "http://localhost:3000"}},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
|
@ -94,19 +91,19 @@ async def test_full_flow(hass, aiohttp_client, aioclient_mock):
|
|||
"""Check full flow."""
|
||||
assert await setup.async_setup_component(
|
||||
hass,
|
||||
"almond",
|
||||
DOMAIN,
|
||||
{
|
||||
"almond": {
|
||||
DOMAIN: {
|
||||
"type": "oauth2",
|
||||
"client_id": CLIENT_ID_VALUE,
|
||||
"client_secret": CLIENT_SECRET_VALUE,
|
||||
CONF_CLIENT_ID: CLIENT_ID_VALUE,
|
||||
CONF_CLIENT_SECRET: CLIENT_SECRET_VALUE,
|
||||
},
|
||||
"http": {"base_url": "https://example.com"},
|
||||
},
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"almond", context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
state = config_entry_oauth2_flow._encode_jwt(hass, {"flow_id": result["flow_id"]})
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ import ambiclimate
|
|||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.ambiclimate import config_flow
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util import aiohttp
|
||||
|
||||
|
@ -71,8 +72,8 @@ async def test_full_flow_implementation(hass):
|
|||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["title"] == "Ambiclimate"
|
||||
assert result["data"]["callback_url"] == "https://hass.com/api/ambiclimate"
|
||||
assert result["data"]["client_secret"] == "secret"
|
||||
assert result["data"]["client_id"] == "id"
|
||||
assert result["data"][CONF_CLIENT_SECRET] == "secret"
|
||||
assert result["data"][CONF_CLIENT_ID] == "id"
|
||||
|
||||
with patch("ambiclimate.AmbiclimateOAuth.get_access_token", return_value=None):
|
||||
result = await flow.async_step_code("123ABC")
|
||||
|
|
|
@ -3,6 +3,12 @@ import requests.exceptions
|
|||
|
||||
from homeassistant import config_entries, setup
|
||||
from homeassistant.components.flume.const import DOMAIN
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
|
||||
from tests.async_mock import MagicMock, patch
|
||||
|
||||
|
@ -37,20 +43,20 @@ async def test_form(hass):
|
|||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
"username": "test-username",
|
||||
"password": "test-password",
|
||||
"client_id": "client_id",
|
||||
"client_secret": "client_secret",
|
||||
CONF_USERNAME: "test-username",
|
||||
CONF_PASSWORD: "test-password",
|
||||
CONF_CLIENT_ID: "client_id",
|
||||
CONF_CLIENT_SECRET: "client_secret",
|
||||
},
|
||||
)
|
||||
|
||||
assert result2["type"] == "create_entry"
|
||||
assert result2["title"] == "test-username"
|
||||
assert result2["data"] == {
|
||||
"username": "test-username",
|
||||
"password": "test-password",
|
||||
"client_id": "client_id",
|
||||
"client_secret": "client_secret",
|
||||
CONF_USERNAME: "test-username",
|
||||
CONF_PASSWORD: "test-password",
|
||||
CONF_CLIENT_ID: "client_id",
|
||||
CONF_CLIENT_SECRET: "client_secret",
|
||||
}
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
|
@ -76,20 +82,20 @@ async def test_form_import(hass):
|
|||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data={
|
||||
"username": "test-username",
|
||||
"password": "test-password",
|
||||
"client_id": "client_id",
|
||||
"client_secret": "client_secret",
|
||||
CONF_USERNAME: "test-username",
|
||||
CONF_PASSWORD: "test-password",
|
||||
CONF_CLIENT_ID: "client_id",
|
||||
CONF_CLIENT_SECRET: "client_secret",
|
||||
},
|
||||
)
|
||||
|
||||
assert result["type"] == "create_entry"
|
||||
assert result["title"] == "test-username"
|
||||
assert result["data"] == {
|
||||
"username": "test-username",
|
||||
"password": "test-password",
|
||||
"client_id": "client_id",
|
||||
"client_secret": "client_secret",
|
||||
CONF_USERNAME: "test-username",
|
||||
CONF_PASSWORD: "test-password",
|
||||
CONF_CLIENT_ID: "client_id",
|
||||
CONF_CLIENT_SECRET: "client_secret",
|
||||
}
|
||||
await hass.async_block_till_done()
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
|
@ -111,10 +117,10 @@ async def test_form_invalid_auth(hass):
|
|||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
"username": "test-username",
|
||||
"password": "test-password",
|
||||
"client_id": "client_id",
|
||||
"client_secret": "client_secret",
|
||||
CONF_USERNAME: "test-username",
|
||||
CONF_PASSWORD: "test-password",
|
||||
CONF_CLIENT_ID: "client_id",
|
||||
CONF_CLIENT_SECRET: "client_secret",
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -136,10 +142,10 @@ async def test_form_cannot_connect(hass):
|
|||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
"username": "test-username",
|
||||
"password": "test-password",
|
||||
"client_id": "client_id",
|
||||
"client_secret": "client_secret",
|
||||
CONF_USERNAME: "test-username",
|
||||
CONF_PASSWORD: "test-password",
|
||||
CONF_CLIENT_ID: "client_id",
|
||||
CONF_CLIENT_SECRET: "client_secret",
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import pytest
|
||||
|
||||
import homeassistant.components.google as google
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.async_mock import patch
|
||||
|
@ -24,7 +25,7 @@ def mock_google_setup(hass):
|
|||
|
||||
async def test_setup_component(hass, google_setup):
|
||||
"""Test setup component."""
|
||||
config = {"google": {"client_id": "id", "client_secret": "secret"}}
|
||||
config = {"google": {CONF_CLIENT_ID: "id", CONF_CLIENT_SECRET: "secret"}}
|
||||
|
||||
assert await async_setup_component(hass, "google", config)
|
||||
|
||||
|
@ -51,8 +52,8 @@ async def test_found_calendar(hass, google_setup, mock_next_event, test_calendar
|
|||
"""Test when a calendar is found."""
|
||||
config = {
|
||||
"google": {
|
||||
"client_id": "id",
|
||||
"client_secret": "secret",
|
||||
CONF_CLIENT_ID: "id",
|
||||
CONF_CLIENT_SECRET: "secret",
|
||||
"track_new_calendar": True,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ from homeassistant.components.home_connect.const import (
|
|||
OAUTH2_AUTHORIZE,
|
||||
OAUTH2_TOKEN,
|
||||
)
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
CLIENT_ID = "1234"
|
||||
|
@ -17,7 +18,10 @@ async def test_full_flow(hass, aiohttp_client, aioclient_mock):
|
|||
hass,
|
||||
"home_connect",
|
||||
{
|
||||
"home_connect": {"client_id": CLIENT_ID, "client_secret": CLIENT_SECRET},
|
||||
"home_connect": {
|
||||
CONF_CLIENT_ID: CLIENT_ID,
|
||||
CONF_CLIENT_SECRET: CLIENT_SECRET,
|
||||
},
|
||||
"http": {"base_url": "https://example.com"},
|
||||
},
|
||||
)
|
||||
|
|
|
@ -6,6 +6,7 @@ from homeassistant.components.netatmo.const import (
|
|||
OAUTH2_AUTHORIZE,
|
||||
OAUTH2_TOKEN,
|
||||
)
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from tests.async_mock import patch
|
||||
|
@ -43,7 +44,7 @@ async def test_full_flow(hass, aiohttp_client, aioclient_mock):
|
|||
hass,
|
||||
"netatmo",
|
||||
{
|
||||
"netatmo": {"client_id": CLIENT_ID, "client_secret": CLIENT_SECRET},
|
||||
"netatmo": {CONF_CLIENT_ID: CLIENT_ID, CONF_CLIENT_SECRET: CLIENT_SECRET},
|
||||
"http": {"base_url": "https://example.com"},
|
||||
},
|
||||
)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
from homeassistant.components.media_player import DOMAIN as MP_DOMAIN
|
||||
from homeassistant.components.plex import const
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_HOST,
|
||||
CONF_PORT,
|
||||
CONF_TOKEN,
|
||||
|
@ -35,7 +36,7 @@ MOCK_TOKEN = "secret_token"
|
|||
DEFAULT_DATA = {
|
||||
const.CONF_SERVER: MOCK_SERVERS[0][const.CONF_SERVER],
|
||||
const.PLEX_SERVER_CONFIG: {
|
||||
const.CONF_CLIENT_IDENTIFIER: "00000000-0000-0000-0000-000000000000",
|
||||
CONF_CLIENT_ID: "00000000-0000-0000-0000-000000000000",
|
||||
CONF_TOKEN: MOCK_TOKEN,
|
||||
CONF_URL: f"https://{MOCK_SERVERS[0][CONF_HOST]}:{MOCK_SERVERS[0][CONF_PORT]}",
|
||||
CONF_VERIFY_SSL: True,
|
||||
|
|
|
@ -5,6 +5,7 @@ import pytest
|
|||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.point import DOMAIN, config_flow
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
|
||||
from tests.async_mock import AsyncMock, patch
|
||||
|
||||
|
@ -86,8 +87,8 @@ async def test_full_flow_implementation(
|
|||
result = await flow.async_step_code("123ABC")
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["data"]["refresh_args"] == {
|
||||
"client_id": "id",
|
||||
"client_secret": "secret",
|
||||
CONF_CLIENT_ID: "id",
|
||||
CONF_CLIENT_SECRET: "secret",
|
||||
}
|
||||
assert result["title"] == "john.doe@example.com"
|
||||
assert result["data"]["token"] == {"access_token": "boo"}
|
||||
|
|
|
@ -15,7 +15,13 @@ from homeassistant.components.reddit.sensor import (
|
|||
CONF_SORT_BY,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.const import CONF_MAXIMUM, CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_MAXIMUM,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.setup import setup_component
|
||||
|
||||
from tests.async_mock import patch
|
||||
|
@ -24,8 +30,8 @@ from tests.common import get_test_home_assistant
|
|||
VALID_CONFIG = {
|
||||
"sensor": {
|
||||
"platform": DOMAIN,
|
||||
"client_id": "test_client_id",
|
||||
"client_secret": "test_client_secret",
|
||||
CONF_CLIENT_ID: "test_client_id",
|
||||
CONF_CLIENT_SECRET: "test_client_secret",
|
||||
CONF_USERNAME: "test_username",
|
||||
CONF_PASSWORD: "test_password",
|
||||
"subreddits": ["worldnews", "news"],
|
||||
|
@ -35,8 +41,8 @@ VALID_CONFIG = {
|
|||
VALID_LIMITED_CONFIG = {
|
||||
"sensor": {
|
||||
"platform": DOMAIN,
|
||||
"client_id": "test_client_id",
|
||||
"client_secret": "test_client_secret",
|
||||
CONF_CLIENT_ID: "test_client_id",
|
||||
CONF_CLIENT_SECRET: "test_client_secret",
|
||||
CONF_USERNAME: "test_username",
|
||||
CONF_PASSWORD: "test_password",
|
||||
"subreddits": ["worldnews", "news"],
|
||||
|
@ -48,8 +54,8 @@ VALID_LIMITED_CONFIG = {
|
|||
INVALID_SORT_BY_CONFIG = {
|
||||
"sensor": {
|
||||
"platform": DOMAIN,
|
||||
"client_id": "test_client_id",
|
||||
"client_secret": "test_client_secret",
|
||||
CONF_CLIENT_ID: "test_client_id",
|
||||
CONF_CLIENT_SECRET: "test_client_secret",
|
||||
CONF_USERNAME: "test_username",
|
||||
CONF_PASSWORD: "test_password",
|
||||
"subreddits": ["worldnews", "news"],
|
||||
|
|
|
@ -28,8 +28,6 @@ from homeassistant.components.smartthings.const import (
|
|||
CONF_INSTALLED_APP_ID,
|
||||
CONF_INSTANCE_ID,
|
||||
CONF_LOCATION_ID,
|
||||
CONF_OAUTH_CLIENT_ID,
|
||||
CONF_OAUTH_CLIENT_SECRET,
|
||||
CONF_REFRESH_TOKEN,
|
||||
DATA_BROKERS,
|
||||
DOMAIN,
|
||||
|
@ -39,7 +37,12 @@ from homeassistant.components.smartthings.const import (
|
|||
)
|
||||
from homeassistant.config import async_process_ha_core_config
|
||||
from homeassistant.config_entries import CONN_CLASS_CLOUD_PUSH, SOURCE_USER, ConfigEntry
|
||||
from homeassistant.const import CONF_ACCESS_TOKEN, CONF_WEBHOOK_ID
|
||||
from homeassistant.const import (
|
||||
CONF_ACCESS_TOKEN,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_WEBHOOK_ID,
|
||||
)
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.async_mock import Mock, patch
|
||||
|
@ -217,8 +220,8 @@ def config_entry_fixture(hass, installed_app, location):
|
|||
CONF_APP_ID: installed_app.app_id,
|
||||
CONF_LOCATION_ID: location.location_id,
|
||||
CONF_REFRESH_TOKEN: str(uuid4()),
|
||||
CONF_OAUTH_CLIENT_ID: str(uuid4()),
|
||||
CONF_OAUTH_CLIENT_SECRET: str(uuid4()),
|
||||
CONF_CLIENT_ID: str(uuid4()),
|
||||
CONF_CLIENT_SECRET: str(uuid4()),
|
||||
}
|
||||
return MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
|
|
|
@ -11,13 +11,13 @@ from homeassistant.components.smartthings.const import (
|
|||
CONF_APP_ID,
|
||||
CONF_INSTALLED_APP_ID,
|
||||
CONF_LOCATION_ID,
|
||||
CONF_OAUTH_CLIENT_ID,
|
||||
CONF_OAUTH_CLIENT_SECRET,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config import async_process_ha_core_config
|
||||
from homeassistant.const import (
|
||||
CONF_ACCESS_TOKEN,
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
HTTP_FORBIDDEN,
|
||||
HTTP_NOT_FOUND,
|
||||
HTTP_UNAUTHORIZED,
|
||||
|
@ -97,8 +97,8 @@ async def test_entry_created(hass, app, app_oauth_client, location, smartthings_
|
|||
assert result["data"]["location_id"] == location.location_id
|
||||
assert result["data"]["access_token"] == token
|
||||
assert result["data"]["refresh_token"] == request.refresh_token
|
||||
assert result["data"]["client_secret"] == app_oauth_client.client_secret
|
||||
assert result["data"]["client_id"] == app_oauth_client.client_id
|
||||
assert result["data"][CONF_CLIENT_SECRET] == app_oauth_client.client_secret
|
||||
assert result["data"][CONF_CLIENT_ID] == app_oauth_client.client_id
|
||||
assert result["title"] == location.name
|
||||
entry = next((entry for entry in hass.config_entries.async_entries(DOMAIN)), None,)
|
||||
assert entry.unique_id == smartapp.format_unique_id(
|
||||
|
@ -165,8 +165,8 @@ async def test_entry_created_from_update_event(
|
|||
assert result["data"]["location_id"] == location.location_id
|
||||
assert result["data"]["access_token"] == token
|
||||
assert result["data"]["refresh_token"] == request.refresh_token
|
||||
assert result["data"]["client_secret"] == app_oauth_client.client_secret
|
||||
assert result["data"]["client_id"] == app_oauth_client.client_id
|
||||
assert result["data"][CONF_CLIENT_SECRET] == app_oauth_client.client_secret
|
||||
assert result["data"][CONF_CLIENT_ID] == app_oauth_client.client_id
|
||||
assert result["title"] == location.name
|
||||
entry = next((entry for entry in hass.config_entries.async_entries(DOMAIN)), None,)
|
||||
assert entry.unique_id == smartapp.format_unique_id(
|
||||
|
@ -233,8 +233,8 @@ async def test_entry_created_existing_app_new_oauth_client(
|
|||
assert result["data"]["location_id"] == location.location_id
|
||||
assert result["data"]["access_token"] == token
|
||||
assert result["data"]["refresh_token"] == request.refresh_token
|
||||
assert result["data"]["client_secret"] == app_oauth_client.client_secret
|
||||
assert result["data"]["client_id"] == app_oauth_client.client_id
|
||||
assert result["data"][CONF_CLIENT_SECRET] == app_oauth_client.client_secret
|
||||
assert result["data"][CONF_CLIENT_ID] == app_oauth_client.client_id
|
||||
assert result["title"] == location.name
|
||||
entry = next((entry for entry in hass.config_entries.async_entries(DOMAIN)), None,)
|
||||
assert entry.unique_id == smartapp.format_unique_id(
|
||||
|
@ -262,8 +262,8 @@ async def test_entry_created_existing_app_copies_oauth_client(
|
|||
domain=DOMAIN,
|
||||
data={
|
||||
CONF_APP_ID: app.app_id,
|
||||
CONF_OAUTH_CLIENT_ID: oauth_client_id,
|
||||
CONF_OAUTH_CLIENT_SECRET: oauth_client_secret,
|
||||
CONF_CLIENT_ID: oauth_client_id,
|
||||
CONF_CLIENT_SECRET: oauth_client_secret,
|
||||
CONF_LOCATION_ID: str(uuid4()),
|
||||
CONF_INSTALLED_APP_ID: str(uuid4()),
|
||||
CONF_ACCESS_TOKEN: token,
|
||||
|
@ -316,8 +316,8 @@ async def test_entry_created_existing_app_copies_oauth_client(
|
|||
assert result["data"]["location_id"] == location.location_id
|
||||
assert result["data"]["access_token"] == token
|
||||
assert result["data"]["refresh_token"] == request.refresh_token
|
||||
assert result["data"]["client_secret"] == oauth_client_secret
|
||||
assert result["data"]["client_id"] == oauth_client_id
|
||||
assert result["data"][CONF_CLIENT_SECRET] == oauth_client_secret
|
||||
assert result["data"][CONF_CLIENT_ID] == oauth_client_id
|
||||
assert result["title"] == location.name
|
||||
entry = next(
|
||||
(
|
||||
|
@ -405,8 +405,8 @@ async def test_entry_created_with_cloudhook(
|
|||
assert result["data"]["location_id"] == location.location_id
|
||||
assert result["data"]["access_token"] == token
|
||||
assert result["data"]["refresh_token"] == request.refresh_token
|
||||
assert result["data"]["client_secret"] == app_oauth_client.client_secret
|
||||
assert result["data"]["client_id"] == app_oauth_client.client_id
|
||||
assert result["data"][CONF_CLIENT_SECRET] == app_oauth_client.client_secret
|
||||
assert result["data"][CONF_CLIENT_ID] == app_oauth_client.client_id
|
||||
assert result["title"] == location.name
|
||||
entry = next(
|
||||
(entry for entry in hass.config_entries.async_entries(DOMAIN)), None,
|
||||
|
|
|
@ -5,14 +5,14 @@ import pytest
|
|||
|
||||
from homeassistant import config_entries, data_entry_flow, setup
|
||||
from homeassistant.components.somfy import DOMAIN, config_flow
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from tests.async_mock import patch
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
CLIENT_SECRET_VALUE = "5678"
|
||||
|
||||
CLIENT_ID_VALUE = "1234"
|
||||
CLIENT_SECRET_VALUE = "5678"
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
|
@ -56,18 +56,18 @@ async def test_full_flow(hass, aiohttp_client, aioclient_mock):
|
|||
"""Check full flow."""
|
||||
assert await setup.async_setup_component(
|
||||
hass,
|
||||
"somfy",
|
||||
DOMAIN,
|
||||
{
|
||||
"somfy": {
|
||||
"client_id": CLIENT_ID_VALUE,
|
||||
"client_secret": CLIENT_SECRET_VALUE,
|
||||
DOMAIN: {
|
||||
CONF_CLIENT_ID: CLIENT_ID_VALUE,
|
||||
CONF_CLIENT_SECRET: CLIENT_SECRET_VALUE,
|
||||
},
|
||||
"http": {"base_url": "https://example.com"},
|
||||
},
|
||||
)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"somfy", context={"source": config_entries.SOURCE_USER}
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
state = config_entry_oauth2_flow._encode_jwt(hass, {"flow_id": result["flow_id"]})
|
||||
|
||||
|
@ -97,7 +97,7 @@ async def test_full_flow(hass, aiohttp_client, aioclient_mock):
|
|||
with patch("homeassistant.components.somfy.api.ConfigEntrySomfyApi"):
|
||||
result = await hass.config_entries.flow.async_configure(result["flow_id"])
|
||||
|
||||
assert result["data"]["auth_implementation"] == "somfy"
|
||||
assert result["data"]["auth_implementation"] == DOMAIN
|
||||
|
||||
result["data"]["token"].pop("expires_at")
|
||||
assert result["data"]["token"] == {
|
||||
|
@ -107,8 +107,8 @@ async def test_full_flow(hass, aiohttp_client, aioclient_mock):
|
|||
"expires_in": 60,
|
||||
}
|
||||
|
||||
assert "somfy" in hass.config.components
|
||||
entry = hass.config_entries.async_entries("somfy")[0]
|
||||
assert DOMAIN in hass.config.components
|
||||
entry = hass.config_entries.async_entries(DOMAIN)[0]
|
||||
assert entry.state == config_entries.ENTRY_STATE_LOADED
|
||||
|
||||
assert await hass.config_entries.async_unload(entry.entry_id)
|
||||
|
|
|
@ -2,12 +2,9 @@
|
|||
from spotipy import SpotifyException
|
||||
|
||||
from homeassistant import data_entry_flow, setup
|
||||
from homeassistant.components.spotify.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.components.spotify.const import DOMAIN
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
from tests.async_mock import patch
|
||||
|
|
|
@ -10,14 +10,13 @@ from toonapilib.toonapilibexceptions import (
|
|||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.toon import config_flow
|
||||
from homeassistant.components.toon.const import (
|
||||
from homeassistant.components.toon.const import CONF_DISPLAY, CONF_TENANT, DOMAIN
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_DISPLAY,
|
||||
CONF_TENANT,
|
||||
DOMAIN,
|
||||
CONF_PASSWORD,
|
||||
CONF_USERNAME,
|
||||
)
|
||||
from homeassistant.const import CONF_PASSWORD, CONF_USERNAME
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.async_mock import patch
|
||||
|
@ -76,8 +75,8 @@ async def test_show_authenticate_form(hass):
|
|||
@pytest.mark.parametrize(
|
||||
"side_effect,reason",
|
||||
[
|
||||
(InvalidConsumerKey, "client_id"),
|
||||
(InvalidConsumerSecret, "client_secret"),
|
||||
(InvalidConsumerKey, CONF_CLIENT_ID),
|
||||
(InvalidConsumerSecret, CONF_CLIENT_SECRET),
|
||||
(AgreementsRetrievalError, "no_agreements"),
|
||||
(Exception, "unknown_auth_fail"),
|
||||
],
|
||||
|
|
|
@ -3,6 +3,7 @@ from requests import HTTPError
|
|||
from twitch.resources import Channel, Follow, Stream, Subscription, User
|
||||
|
||||
from homeassistant.components import sensor
|
||||
from homeassistant.const import CONF_CLIENT_ID
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
||||
from tests.async_mock import MagicMock, patch
|
||||
|
@ -11,14 +12,14 @@ ENTITY_ID = "sensor.channel123"
|
|||
CONFIG = {
|
||||
sensor.DOMAIN: {
|
||||
"platform": "twitch",
|
||||
"client_id": "1234",
|
||||
CONF_CLIENT_ID: "1234",
|
||||
"channels": ["channel123"],
|
||||
}
|
||||
}
|
||||
CONFIG_WITH_OAUTH = {
|
||||
sensor.DOMAIN: {
|
||||
"platform": "twitch",
|
||||
"client_id": "1234",
|
||||
CONF_CLIENT_ID: "1234",
|
||||
"channels": ["channel123"],
|
||||
"token": "9876",
|
||||
}
|
||||
|
|
|
@ -19,7 +19,12 @@ import homeassistant.components.http as http
|
|||
import homeassistant.components.withings.const as const
|
||||
from homeassistant.config import async_process_ha_core_config
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import CONF_UNIT_SYSTEM, CONF_UNIT_SYSTEM_METRIC
|
||||
from homeassistant.const import (
|
||||
CONF_CLIENT_ID,
|
||||
CONF_CLIENT_SECRET,
|
||||
CONF_UNIT_SYSTEM,
|
||||
CONF_UNIT_SYSTEM_METRIC,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
from homeassistant.setup import async_setup_component
|
||||
|
@ -55,9 +60,9 @@ async def setup_hass(hass: HomeAssistant) -> dict:
|
|||
api.DOMAIN: {"base_url": "http://localhost/"},
|
||||
http.DOMAIN: {"server_port": 8080},
|
||||
const.DOMAIN: {
|
||||
const.CLIENT_ID: "my_client_id",
|
||||
const.CLIENT_SECRET: "my_client_secret",
|
||||
const.PROFILES: profiles,
|
||||
CONF_CLIENT_ID: "my_client_id",
|
||||
CONF_CLIENT_SECRET: "my_client_secret",
|
||||
const.CONF_PROFILES: profiles,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.components.withings import (
|
|||
const,
|
||||
)
|
||||
from homeassistant.config import async_process_ha_core_config
|
||||
from homeassistant.const import STATE_UNKNOWN
|
||||
from homeassistant.const import CONF_CLIENT_ID, CONF_CLIENT_SECRET, STATE_UNKNOWN
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from .common import (
|
||||
|
@ -55,9 +55,9 @@ def test_config_schema_basic_config() -> None:
|
|||
"""Test schema."""
|
||||
config_schema_validate(
|
||||
{
|
||||
const.CLIENT_ID: "my_client_id",
|
||||
const.CLIENT_SECRET: "my_client_secret",
|
||||
const.PROFILES: ["Person 1", "Person 2"],
|
||||
CONF_CLIENT_ID: "my_client_id",
|
||||
CONF_CLIENT_SECRET: "my_client_secret",
|
||||
const.CONF_PROFILES: ["Person 1", "Person 2"],
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -66,22 +66,22 @@ def test_config_schema_client_id() -> None:
|
|||
"""Test schema."""
|
||||
config_schema_assert_fail(
|
||||
{
|
||||
const.CLIENT_SECRET: "my_client_secret",
|
||||
const.PROFILES: ["Person 1", "Person 2"],
|
||||
CONF_CLIENT_SECRET: "my_client_secret",
|
||||
const.CONF_PROFILES: ["Person 1", "Person 2"],
|
||||
}
|
||||
)
|
||||
config_schema_assert_fail(
|
||||
{
|
||||
const.CLIENT_SECRET: "my_client_secret",
|
||||
const.CLIENT_ID: "",
|
||||
const.PROFILES: ["Person 1"],
|
||||
CONF_CLIENT_SECRET: "my_client_secret",
|
||||
CONF_CLIENT_ID: "",
|
||||
const.CONF_PROFILES: ["Person 1"],
|
||||
}
|
||||
)
|
||||
config_schema_validate(
|
||||
{
|
||||
const.CLIENT_SECRET: "my_client_secret",
|
||||
const.CLIENT_ID: "my_client_id",
|
||||
const.PROFILES: ["Person 1"],
|
||||
CONF_CLIENT_SECRET: "my_client_secret",
|
||||
CONF_CLIENT_ID: "my_client_id",
|
||||
const.CONF_PROFILES: ["Person 1"],
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -89,20 +89,20 @@ def test_config_schema_client_id() -> None:
|
|||
def test_config_schema_client_secret() -> None:
|
||||
"""Test schema."""
|
||||
config_schema_assert_fail(
|
||||
{const.CLIENT_ID: "my_client_id", const.PROFILES: ["Person 1"]}
|
||||
{CONF_CLIENT_ID: "my_client_id", const.CONF_PROFILES: ["Person 1"]}
|
||||
)
|
||||
config_schema_assert_fail(
|
||||
{
|
||||
const.CLIENT_ID: "my_client_id",
|
||||
const.CLIENT_SECRET: "",
|
||||
const.PROFILES: ["Person 1"],
|
||||
CONF_CLIENT_ID: "my_client_id",
|
||||
CONF_CLIENT_SECRET: "",
|
||||
const.CONF_PROFILES: ["Person 1"],
|
||||
}
|
||||
)
|
||||
config_schema_validate(
|
||||
{
|
||||
const.CLIENT_ID: "my_client_id",
|
||||
const.CLIENT_SECRET: "my_client_secret",
|
||||
const.PROFILES: ["Person 1"],
|
||||
CONF_CLIENT_ID: "my_client_id",
|
||||
CONF_CLIENT_SECRET: "my_client_secret",
|
||||
const.CONF_PROFILES: ["Person 1"],
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -110,41 +110,41 @@ def test_config_schema_client_secret() -> None:
|
|||
def test_config_schema_profiles() -> None:
|
||||
"""Test schema."""
|
||||
config_schema_assert_fail(
|
||||
{const.CLIENT_ID: "my_client_id", const.CLIENT_SECRET: "my_client_secret"}
|
||||
{CONF_CLIENT_ID: "my_client_id", CONF_CLIENT_SECRET: "my_client_secret"}
|
||||
)
|
||||
config_schema_assert_fail(
|
||||
{
|
||||
const.CLIENT_ID: "my_client_id",
|
||||
const.CLIENT_SECRET: "my_client_secret",
|
||||
const.PROFILES: "",
|
||||
CONF_CLIENT_ID: "my_client_id",
|
||||
CONF_CLIENT_SECRET: "my_client_secret",
|
||||
const.CONF_PROFILES: "",
|
||||
}
|
||||
)
|
||||
config_schema_assert_fail(
|
||||
{
|
||||
const.CLIENT_ID: "my_client_id",
|
||||
const.CLIENT_SECRET: "my_client_secret",
|
||||
const.PROFILES: [],
|
||||
CONF_CLIENT_ID: "my_client_id",
|
||||
CONF_CLIENT_SECRET: "my_client_secret",
|
||||
const.CONF_PROFILES: [],
|
||||
}
|
||||
)
|
||||
config_schema_assert_fail(
|
||||
{
|
||||
const.CLIENT_ID: "my_client_id",
|
||||
const.CLIENT_SECRET: "my_client_secret",
|
||||
const.PROFILES: ["Person 1", "Person 1"],
|
||||
CONF_CLIENT_ID: "my_client_id",
|
||||
CONF_CLIENT_SECRET: "my_client_secret",
|
||||
const.CONF_PROFILES: ["Person 1", "Person 1"],
|
||||
}
|
||||
)
|
||||
config_schema_validate(
|
||||
{
|
||||
const.CLIENT_ID: "my_client_id",
|
||||
const.CLIENT_SECRET: "my_client_secret",
|
||||
const.PROFILES: ["Person 1"],
|
||||
CONF_CLIENT_ID: "my_client_id",
|
||||
CONF_CLIENT_SECRET: "my_client_secret",
|
||||
const.CONF_PROFILES: ["Person 1"],
|
||||
}
|
||||
)
|
||||
config_schema_validate(
|
||||
{
|
||||
const.CLIENT_ID: "my_client_id",
|
||||
const.CLIENT_SECRET: "my_client_secret",
|
||||
const.PROFILES: ["Person 1", "Person 2"],
|
||||
CONF_CLIENT_ID: "my_client_id",
|
||||
CONF_CLIENT_SECRET: "my_client_secret",
|
||||
const.CONF_PROFILES: ["Person 1", "Person 2"],
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -163,7 +163,7 @@ async def test_upgrade_token(
|
|||
) -> None:
|
||||
"""Test upgrading from old config data format to new one."""
|
||||
config = await setup_hass(hass)
|
||||
profiles = config[const.DOMAIN][const.PROFILES]
|
||||
profiles = config[const.DOMAIN][const.CONF_PROFILES]
|
||||
|
||||
await async_process_ha_core_config(
|
||||
hass, {"internal_url": "http://example.local"},
|
||||
|
@ -197,7 +197,7 @@ async def test_upgrade_token(
|
|||
"token_expiry": token.get("expires_at"),
|
||||
"token_type": token.get("type"),
|
||||
"userid": token.get("userid"),
|
||||
"client_id": token.get("my_client_id"),
|
||||
CONF_CLIENT_ID: token.get("my_client_id"),
|
||||
"consumer_secret": token.get("my_consumer_secret"),
|
||||
},
|
||||
},
|
||||
|
@ -228,7 +228,7 @@ async def test_upgrade_token(
|
|||
assert token.get("expires_at") > time.time()
|
||||
assert token.get("type") == "Bearer"
|
||||
assert token.get("userid") == "myuserid"
|
||||
assert not token.get("client_id")
|
||||
assert not token.get(CONF_CLIENT_ID)
|
||||
assert not token.get("consumer_secret")
|
||||
|
||||
|
||||
|
@ -237,7 +237,7 @@ async def test_auth_failure(
|
|||
) -> None:
|
||||
"""Test auth failure."""
|
||||
config = await setup_hass(hass)
|
||||
profiles = config[const.DOMAIN][const.PROFILES]
|
||||
profiles = config[const.DOMAIN][const.CONF_PROFILES]
|
||||
|
||||
await async_process_ha_core_config(
|
||||
hass, {"internal_url": "http://example.local"},
|
||||
|
@ -276,7 +276,7 @@ async def test_auth_failure(
|
|||
async def test_full_setup(hass: HomeAssistant, aiohttp_client, aioclient_mock) -> None:
|
||||
"""Test the whole component lifecycle."""
|
||||
config = await setup_hass(hass)
|
||||
profiles = config[const.DOMAIN][const.PROFILES]
|
||||
profiles = config[const.DOMAIN][const.CONF_PROFILES]
|
||||
|
||||
await async_process_ha_core_config(
|
||||
hass, {"internal_url": "http://example.local"},
|
||||
|
|
Loading…
Add table
Reference in a new issue