forked from home-assistant/core
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4ec81d4b67 | |||
| ac62028c19 | |||
| ff9e1ddeed | |||
| 3a82aecd38 | |||
| 3a41878a8c | |||
| 3ab0b63540 | |||
| 3752fa3123 | |||
| 07df3b9565 | |||
| 43ef5bab18 | |||
| 150ce05e26 | |||
| 70bd998d7c | |||
| 3600dec6e0 | |||
| 277b916fcd | |||
| 623826261b | |||
| 1ac5ecbe69 | |||
| 3981592ccd | |||
| 9c45874206 | |||
| 17cd00ba83 | |||
| c02be99ab7 | |||
| 7c2a2b08c7 | |||
| f858d6f9ec | |||
| 8507b62016 | |||
| 8c6636994f |
@@ -23,7 +23,7 @@ from .const import (
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.115")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
|
||||
async def _await_cancel(task):
|
||||
|
||||
@@ -32,7 +32,7 @@ from .helpers import async_get_blueprints
|
||||
_CONDITION_SCHEMA = vol.All(cv.ensure_list, [cv.CONDITION_SCHEMA])
|
||||
|
||||
PLATFORM_SCHEMA = vol.All(
|
||||
cv.deprecated(CONF_HIDE_ENTITY, invalidation_version="0.110"),
|
||||
cv.deprecated(CONF_HIDE_ENTITY),
|
||||
script.make_script_schema(
|
||||
{
|
||||
# str on purpose
|
||||
|
||||
@@ -30,7 +30,7 @@ from .coordinator import CanaryDataUpdateCoordinator
|
||||
MIN_TIME_BETWEEN_SESSION_RENEW = timedelta(seconds=90)
|
||||
|
||||
PLATFORM_SCHEMA = vol.All(
|
||||
cv.deprecated(CONF_FFMPEG_ARGUMENTS, invalidation_version="0.118"),
|
||||
cv.deprecated(CONF_FFMPEG_ARGUMENTS),
|
||||
PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Optional(
|
||||
|
||||
@@ -29,3 +29,8 @@ async def async_setup_entry(hass, entry: config_entries.ConfigEntry):
|
||||
hass.config_entries.async_forward_entry_setup(entry, "media_player")
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
async def async_remove_entry(hass, entry):
|
||||
"""Remove Home Assistant Cast user."""
|
||||
await home_assistant_cast.async_remove_user(hass, entry)
|
||||
|
||||
@@ -72,3 +72,14 @@ async def async_setup_ha_cast(
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def async_remove_user(
|
||||
hass: core.HomeAssistant, entry: config_entries.ConfigEntry
|
||||
):
|
||||
"""Remove Home Assistant Cast user."""
|
||||
user_id: Optional[str] = entry.data.get("user_id")
|
||||
|
||||
if user_id is not None:
|
||||
user = await hass.auth.async_get_user(user_id)
|
||||
await hass.auth.async_remove_user(user)
|
||||
|
||||
@@ -33,10 +33,10 @@ _LOGGER = logging.getLogger(__name__)
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.All(
|
||||
cv.deprecated(CONF_EMAIL, invalidation_version="0.119"),
|
||||
cv.deprecated(CONF_API_KEY, invalidation_version="0.119"),
|
||||
cv.deprecated(CONF_ZONE, invalidation_version="0.119"),
|
||||
cv.deprecated(CONF_RECORDS, invalidation_version="0.119"),
|
||||
cv.deprecated(CONF_EMAIL),
|
||||
cv.deprecated(CONF_API_KEY),
|
||||
cv.deprecated(CONF_ZONE),
|
||||
cv.deprecated(CONF_RECORDS),
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_EMAIL): cv.string,
|
||||
|
||||
@@ -30,7 +30,7 @@ COMPONENT_TYPES = ["climate", "sensor", "switch"]
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
vol.All(
|
||||
cv.deprecated(DOMAIN, invalidation_version="0.113.0"),
|
||||
cv.deprecated(DOMAIN),
|
||||
{
|
||||
DOMAIN: vol.Schema(
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ from .const import (
|
||||
DOMAIN,
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.120")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = ["media_player", "remote"]
|
||||
SCAN_INTERVAL = timedelta(seconds=30)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"domain": "dsmr",
|
||||
"name": "DSMR Slimme Meter",
|
||||
"documentation": "https://www.home-assistant.io/integrations/dsmr",
|
||||
"requirements": ["dsmr_parser==0.23"],
|
||||
"requirements": ["dsmr_parser==0.25"],
|
||||
"codeowners": ["@Robbie1221"],
|
||||
"config_flow": false
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"domain": "enphase_envoy",
|
||||
"name": "Enphase Envoy",
|
||||
"documentation": "https://www.home-assistant.io/integrations/enphase_envoy",
|
||||
"requirements": ["envoy_reader==0.17.0"],
|
||||
"requirements": ["envoy_reader==0.17.3"],
|
||||
"codeowners": [
|
||||
"@gtdiehl"
|
||||
]
|
||||
|
||||
@@ -20,7 +20,7 @@ from .const import (
|
||||
|
||||
DEFAULT_UPDATE_INTERVAL = timedelta(minutes=30)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.119")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = ["sensor"]
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"domain": "frontend",
|
||||
"name": "Home Assistant Frontend",
|
||||
"documentation": "https://www.home-assistant.io/integrations/frontend",
|
||||
"requirements": ["home-assistant-frontend==20201210.0"],
|
||||
"requirements": ["home-assistant-frontend==20201212.0"],
|
||||
"dependencies": [
|
||||
"api",
|
||||
"auth",
|
||||
|
||||
@@ -11,8 +11,6 @@ from homeassistant.helpers import config_validation as cv
|
||||
|
||||
from .const import (
|
||||
CONF_ALIASES,
|
||||
CONF_ALLOW_UNLOCK,
|
||||
CONF_API_KEY,
|
||||
CONF_CLIENT_EMAIL,
|
||||
CONF_ENTITY_CONFIG,
|
||||
CONF_EXPOSE,
|
||||
@@ -36,6 +34,9 @@ from .const import EVENT_COMMAND_RECEIVED, EVENT_SYNC_RECEIVED # noqa: F401, is
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
CONF_ALLOW_UNLOCK = "allow_unlock"
|
||||
CONF_API_KEY = "api_key"
|
||||
|
||||
ENTITY_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_NAME): cv.string,
|
||||
@@ -61,8 +62,6 @@ def _check_report_state(data):
|
||||
|
||||
|
||||
GOOGLE_ASSISTANT_SCHEMA = vol.All(
|
||||
cv.deprecated(CONF_ALLOW_UNLOCK, invalidation_version="0.95"),
|
||||
cv.deprecated(CONF_API_KEY, invalidation_version="0.105"),
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_PROJECT_ID): cv.string,
|
||||
@@ -72,13 +71,14 @@ GOOGLE_ASSISTANT_SCHEMA = vol.All(
|
||||
vol.Optional(
|
||||
CONF_EXPOSED_DOMAINS, default=DEFAULT_EXPOSED_DOMAINS
|
||||
): cv.ensure_list,
|
||||
vol.Optional(CONF_API_KEY): cv.string,
|
||||
vol.Optional(CONF_ENTITY_CONFIG): {cv.entity_id: ENTITY_SCHEMA},
|
||||
vol.Optional(CONF_ALLOW_UNLOCK): cv.boolean,
|
||||
# str on purpose, makes sure it is configured correctly.
|
||||
vol.Optional(CONF_SECURE_DEVICES_PIN): str,
|
||||
vol.Optional(CONF_REPORT_STATE, default=False): cv.boolean,
|
||||
vol.Optional(CONF_SERVICE_ACCOUNT): GOOGLE_SERVICE_ACCOUNT,
|
||||
# deprecated configuration options
|
||||
vol.Remove(CONF_ALLOW_UNLOCK): cv.boolean,
|
||||
vol.Remove(CONF_API_KEY): cv.string,
|
||||
},
|
||||
extra=vol.PREVENT_EXTRA,
|
||||
),
|
||||
@@ -113,7 +113,7 @@ async def async_setup(hass: HomeAssistant, yaml_config: Dict[str, Any]):
|
||||
await google_config.async_sync_entities(agent_user_id)
|
||||
|
||||
# Register service only if key is provided
|
||||
if CONF_API_KEY in config or CONF_SERVICE_ACCOUNT in config:
|
||||
if CONF_SERVICE_ACCOUNT in config:
|
||||
hass.services.async_register(
|
||||
DOMAIN, SERVICE_REQUEST_SYNC, request_sync_service_handler
|
||||
)
|
||||
|
||||
@@ -30,9 +30,7 @@ CONF_EXPOSE_BY_DEFAULT = "expose_by_default"
|
||||
CONF_EXPOSED_DOMAINS = "exposed_domains"
|
||||
CONF_PROJECT_ID = "project_id"
|
||||
CONF_ALIASES = "aliases"
|
||||
CONF_API_KEY = "api_key"
|
||||
CONF_ROOM_HINT = "room"
|
||||
CONF_ALLOW_UNLOCK = "allow_unlock"
|
||||
CONF_SECURE_DEVICES_PIN = "secure_devices_pin"
|
||||
CONF_REPORT_STATE = "report_state"
|
||||
CONF_SERVICE_ACCOUNT = "service_account"
|
||||
|
||||
@@ -19,7 +19,6 @@ from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from .const import (
|
||||
CONF_API_KEY,
|
||||
CONF_CLIENT_EMAIL,
|
||||
CONF_ENTITY_CONFIG,
|
||||
CONF_EXPOSE,
|
||||
@@ -135,11 +134,7 @@ class GoogleConfig(AbstractConfig):
|
||||
return True
|
||||
|
||||
async def _async_request_sync_devices(self, agent_user_id: str):
|
||||
if CONF_API_KEY in self._config:
|
||||
await self.async_call_homegraph_api_key(
|
||||
REQUEST_SYNC_BASE_URL, {"agentUserId": agent_user_id}
|
||||
)
|
||||
elif CONF_SERVICE_ACCOUNT in self._config:
|
||||
if CONF_SERVICE_ACCOUNT in self._config:
|
||||
await self.async_call_homegraph_api(
|
||||
REQUEST_SYNC_BASE_URL, {"agentUserId": agent_user_id}
|
||||
)
|
||||
@@ -164,25 +159,6 @@ class GoogleConfig(AbstractConfig):
|
||||
self._access_token = token["access_token"]
|
||||
self._access_token_renew = now + timedelta(seconds=token["expires_in"])
|
||||
|
||||
async def async_call_homegraph_api_key(self, url, data):
|
||||
"""Call a homegraph api with api key authentication."""
|
||||
websession = async_get_clientsession(self.hass)
|
||||
try:
|
||||
res = await websession.post(
|
||||
url, params={"key": self._config.get(CONF_API_KEY)}, json=data
|
||||
)
|
||||
_LOGGER.debug(
|
||||
"Response on %s with data %s was %s", url, data, await res.text()
|
||||
)
|
||||
res.raise_for_status()
|
||||
return res.status
|
||||
except ClientResponseError as error:
|
||||
_LOGGER.error("Request for %s failed: %d", url, error.status)
|
||||
return error.status
|
||||
except (asyncio.TimeoutError, ClientError):
|
||||
_LOGGER.error("Could not contact %s", url)
|
||||
return HTTP_INTERNAL_SERVER_ERROR
|
||||
|
||||
async def async_call_homegraph_api(self, url, data):
|
||||
"""Call a homegraph api with authentication."""
|
||||
session = async_get_clientsession(self.hass)
|
||||
|
||||
@@ -80,13 +80,13 @@ SUPPORT_HYPERION = SUPPORT_COLOR | SUPPORT_BRIGHTNESS | SUPPORT_EFFECT
|
||||
|
||||
# Usage of YAML for configuration of the Hyperion component is deprecated.
|
||||
PLATFORM_SCHEMA = vol.All(
|
||||
cv.deprecated(CONF_HDMI_PRIORITY, invalidation_version="0.118"),
|
||||
cv.deprecated(CONF_HDMI_PRIORITY),
|
||||
cv.deprecated(CONF_HOST),
|
||||
cv.deprecated(CONF_PORT),
|
||||
cv.deprecated(CONF_DEFAULT_COLOR, invalidation_version="0.118"),
|
||||
cv.deprecated(CONF_DEFAULT_COLOR),
|
||||
cv.deprecated(CONF_NAME),
|
||||
cv.deprecated(CONF_PRIORITY),
|
||||
cv.deprecated(CONF_EFFECT_LIST, invalidation_version="0.118"),
|
||||
cv.deprecated(CONF_EFFECT_LIST),
|
||||
PLATFORM_SCHEMA.extend(
|
||||
{
|
||||
vol.Required(CONF_HOST): cv.string,
|
||||
|
||||
@@ -365,9 +365,7 @@ class InputDatetime(RestoreEntity):
|
||||
def async_set_datetime(self, date=None, time=None, datetime=None, timestamp=None):
|
||||
"""Set a new date / time."""
|
||||
if timestamp:
|
||||
datetime = dt_util.as_local(dt_util.utc_from_timestamp(timestamp)).replace(
|
||||
tzinfo=None
|
||||
)
|
||||
datetime = dt_util.as_local(dt_util.utc_from_timestamp(timestamp))
|
||||
|
||||
if datetime:
|
||||
date = datetime.date()
|
||||
@@ -388,8 +386,8 @@ class InputDatetime(RestoreEntity):
|
||||
if not time:
|
||||
time = self._current_datetime.time()
|
||||
|
||||
self._current_datetime = py_datetime.datetime.combine(date, time).replace(
|
||||
tzinfo=dt_util.DEFAULT_TIME_ZONE
|
||||
self._current_datetime = dt_util.DEFAULT_TIME_ZONE.localize(
|
||||
py_datetime.datetime.combine(date, time)
|
||||
)
|
||||
self.async_write_ha_state()
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ from .const import DOMAIN, PLATFORM
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.All(
|
||||
cv.deprecated(CONF_NAME, invalidation_version="0.110"),
|
||||
cv.deprecated(CONF_NAME),
|
||||
vol.Schema({vol.Optional(CONF_NAME, default=DOMAIN): cv.string}),
|
||||
)
|
||||
},
|
||||
|
||||
@@ -21,8 +21,10 @@ from homeassistant.const import (
|
||||
CONF_LATITUDE,
|
||||
CONF_LONGITUDE,
|
||||
CONF_NAME,
|
||||
LENGTH_INCHES,
|
||||
LENGTH_KILOMETERS,
|
||||
LENGTH_MILES,
|
||||
LENGTH_MILLIMETERS,
|
||||
PRESSURE_HPA,
|
||||
PRESSURE_INHG,
|
||||
TEMP_CELSIUS,
|
||||
@@ -32,7 +34,14 @@ from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
from homeassistant.util.distance import convert as convert_distance
|
||||
from homeassistant.util.pressure import convert as convert_pressure
|
||||
|
||||
from .const import ATTR_MAP, CONDITIONS_MAP, CONF_TRACK_HOME, DOMAIN, FORECAST_MAP
|
||||
from .const import (
|
||||
ATTR_FORECAST_PRECIPITATION,
|
||||
ATTR_MAP,
|
||||
CONDITIONS_MAP,
|
||||
CONF_TRACK_HOME,
|
||||
DOMAIN,
|
||||
FORECAST_MAP,
|
||||
)
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -221,6 +230,14 @@ class MetWeather(CoordinatorEntity, WeatherEntity):
|
||||
for k, v in FORECAST_MAP.items()
|
||||
if met_item.get(v) is not None
|
||||
}
|
||||
if not self._is_metric:
|
||||
if ATTR_FORECAST_PRECIPITATION in ha_item:
|
||||
precip_inches = convert_distance(
|
||||
ha_item[ATTR_FORECAST_PRECIPITATION],
|
||||
LENGTH_MILLIMETERS,
|
||||
LENGTH_INCHES,
|
||||
)
|
||||
ha_item[ATTR_FORECAST_PRECIPITATION] = round(precip_inches, 2)
|
||||
if ha_item.get(ATTR_FORECAST_CONDITION):
|
||||
ha_item[ATTR_FORECAST_CONDITION] = format_condition(
|
||||
ha_item[ATTR_FORECAST_CONDITION]
|
||||
|
||||
@@ -191,7 +191,7 @@ def embedded_broker_deprecated(value):
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.All(
|
||||
cv.deprecated(CONF_TLS_VERSION, invalidation_version="0.115"),
|
||||
cv.deprecated(CONF_TLS_VERSION),
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Optional(CONF_CLIENT_ID): cv.string,
|
||||
|
||||
@@ -30,7 +30,7 @@ ATTR_SYSTEM_NAME = "system_name"
|
||||
DEFAULT_ATTRIBUTION = "Data provided by Notion"
|
||||
DEFAULT_SCAN_INTERVAL = timedelta(minutes=1)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.119")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
|
||||
async def async_setup(hass: HomeAssistant, config: dict) -> bool:
|
||||
|
||||
@@ -74,7 +74,7 @@ SERVICE_STOP_PROGRAM_SCHEMA = vol.Schema(
|
||||
|
||||
SERVICE_STOP_ZONE_SCHEMA = vol.Schema({vol.Required(CONF_ZONE_ID): cv.positive_int})
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.119")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = ["binary_sensor", "sensor", "switch"]
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/recollect_waste",
|
||||
"requirements": [
|
||||
"aiorecollect==0.2.2"
|
||||
"aiorecollect==1.0.1"
|
||||
],
|
||||
"codeowners": [
|
||||
"@bachya"
|
||||
|
||||
@@ -120,9 +120,11 @@ class RecollectWasteSensor(CoordinatorEntity):
|
||||
self._state = pickup_event.date
|
||||
self._attributes.update(
|
||||
{
|
||||
ATTR_PICKUP_TYPES: pickup_event.pickup_types,
|
||||
ATTR_PICKUP_TYPES: [t.name for t in pickup_event.pickup_types],
|
||||
ATTR_AREA_NAME: pickup_event.area_name,
|
||||
ATTR_NEXT_PICKUP_TYPES: next_pickup_event.pickup_types,
|
||||
ATTR_NEXT_PICKUP_TYPES: [
|
||||
t.name for t in next_pickup_event.pickup_types
|
||||
],
|
||||
ATTR_NEXT_PICKUP_DATE: next_date,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -30,7 +30,7 @@ from .const import (
|
||||
DOMAIN,
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.120")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
PLATFORMS = [MEDIA_PLAYER_DOMAIN, REMOTE_DOMAIN]
|
||||
SCAN_INTERVAL = timedelta(seconds=15)
|
||||
|
||||
@@ -33,7 +33,7 @@ from .const import (
|
||||
ENTITY_COMPONENTS,
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.117")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
|
||||
LOGGER_INFO_REGEX = re.compile(r"^(\w+)\.?(\w+)?\.?(\w+)?\.?(\w+)?(?:\..*)?$")
|
||||
|
||||
@@ -27,12 +27,6 @@ HOST_SCHEMA = vol.Schema({vol.Required(CONF_HOST): str})
|
||||
HTTP_CONNECT_ERRORS = (asyncio.TimeoutError, aiohttp.ClientError)
|
||||
|
||||
|
||||
def _remove_prefix(shelly_str):
|
||||
if shelly_str.startswith("shellyswitch"):
|
||||
return shelly_str[6:]
|
||||
return shelly_str
|
||||
|
||||
|
||||
async def validate_input(hass: core.HomeAssistant, host, data):
|
||||
"""Validate the user input allows us to connect.
|
||||
|
||||
@@ -159,7 +153,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self.host = zeroconf_info["host"]
|
||||
# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
|
||||
self.context["title_placeholders"] = {
|
||||
"name": _remove_prefix(zeroconf_info["properties"]["id"])
|
||||
"name": zeroconf_info.get("name", "").split(".")[0]
|
||||
}
|
||||
return await self.async_step_confirm_discovery()
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ SERVICE_SET_SYSTEM_PROPERTIES_SCHEMA = SERVICE_BASE_SCHEMA.extend(
|
||||
}
|
||||
)
|
||||
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN, invalidation_version="0.119")
|
||||
CONFIG_SCHEMA = cv.deprecated(DOMAIN)
|
||||
|
||||
|
||||
@callback
|
||||
|
||||
@@ -15,6 +15,15 @@ from homeassistant.helpers import aiohttp_client
|
||||
from . import async_get_client_id
|
||||
from .const import DOMAIN, LOGGER # pylint: disable=unused-import
|
||||
|
||||
FULL_DATA_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_USERNAME): str,
|
||||
vol.Required(CONF_PASSWORD): str,
|
||||
vol.Optional(CONF_CODE): str,
|
||||
}
|
||||
)
|
||||
PASSWORD_DATA_SCHEMA = vol.Schema({vol.Required(CONF_PASSWORD): str})
|
||||
|
||||
|
||||
class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Handle a SimpliSafe config flow."""
|
||||
@@ -24,15 +33,6 @@ class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize the config flow."""
|
||||
self.full_data_schema = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_USERNAME): str,
|
||||
vol.Required(CONF_PASSWORD): str,
|
||||
vol.Optional(CONF_CODE): str,
|
||||
}
|
||||
)
|
||||
self.password_data_schema = vol.Schema({vol.Required(CONF_PASSWORD): str})
|
||||
|
||||
self._code = None
|
||||
self._password = None
|
||||
self._username = None
|
||||
@@ -125,21 +125,19 @@ class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Handle re-auth completion."""
|
||||
if not user_input:
|
||||
return self.async_show_form(
|
||||
step_id="reauth_confirm", data_schema=self.password_data_schema
|
||||
step_id="reauth_confirm", data_schema=PASSWORD_DATA_SCHEMA
|
||||
)
|
||||
|
||||
self._password = user_input[CONF_PASSWORD]
|
||||
|
||||
return await self._async_login_during_step(
|
||||
step_id="reauth_confirm", form_schema=self.password_data_schema
|
||||
step_id="reauth_confirm", form_schema=PASSWORD_DATA_SCHEMA
|
||||
)
|
||||
|
||||
async def async_step_user(self, user_input=None):
|
||||
"""Handle the start of the config flow."""
|
||||
if not user_input:
|
||||
return self.async_show_form(
|
||||
step_id="user", data_schema=self.full_data_schema
|
||||
)
|
||||
return self.async_show_form(step_id="user", data_schema=FULL_DATA_SCHEMA)
|
||||
|
||||
await self.async_set_unique_id(user_input[CONF_USERNAME])
|
||||
self._abort_if_unique_id_configured()
|
||||
@@ -149,7 +147,7 @@ class SimpliSafeFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self._username = user_input[CONF_USERNAME]
|
||||
|
||||
return await self._async_login_during_step(
|
||||
step_id="user", form_schema=self.full_data_schema
|
||||
step_id="user", form_schema=FULL_DATA_SCHEMA
|
||||
)
|
||||
|
||||
|
||||
@@ -171,7 +169,9 @@ class SimpliSafeOptionsFlowHandler(config_entries.OptionsFlow):
|
||||
{
|
||||
vol.Optional(
|
||||
CONF_CODE,
|
||||
default=self.config_entry.options.get(CONF_CODE),
|
||||
description={
|
||||
"suggested_value": self.config_entry.options.get(CONF_CODE)
|
||||
},
|
||||
): str
|
||||
}
|
||||
),
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "Tasmota (beta)",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/tasmota",
|
||||
"requirements": ["hatasmota==0.1.4"],
|
||||
"requirements": ["hatasmota==0.1.6"],
|
||||
"dependencies": ["mqtt"],
|
||||
"mqtt": ["tasmota/discovery/#"],
|
||||
"codeowners": ["@emontnemery"]
|
||||
|
||||
@@ -43,6 +43,8 @@ async def async_discover_and_construct(
|
||||
) -> Device:
|
||||
"""Discovery devices and construct a Device for one."""
|
||||
# pylint: disable=invalid-name
|
||||
_LOGGER.debug("Constructing device: %s::%s", udn, st)
|
||||
|
||||
discovery_infos = await Device.async_discover(hass)
|
||||
_LOGGER.debug("Discovered devices: %s", discovery_infos)
|
||||
if not discovery_infos:
|
||||
@@ -53,7 +55,7 @@ async def async_discover_and_construct(
|
||||
# Get the discovery info with specified UDN/ST.
|
||||
filtered = [di for di in discovery_infos if di[DISCOVERY_UDN] == udn]
|
||||
if st:
|
||||
filtered = [di for di in discovery_infos if di[DISCOVERY_ST] == st]
|
||||
filtered = [di for di in filtered if di[DISCOVERY_ST] == st]
|
||||
if not filtered:
|
||||
_LOGGER.warning(
|
||||
'Wanted UPnP/IGD device with UDN/ST "%s"/"%s" not found, aborting',
|
||||
@@ -74,6 +76,7 @@ async def async_discover_and_construct(
|
||||
)
|
||||
_LOGGER.info("Detected multiple UPnP/IGD devices, using: %s", device_name)
|
||||
|
||||
_LOGGER.debug("Constructing from discovery_info: %s", discovery_info)
|
||||
location = discovery_info[DISCOVERY_LOCATION]
|
||||
return await Device.async_create_device(hass, location)
|
||||
|
||||
@@ -104,7 +107,7 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType):
|
||||
|
||||
async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry) -> bool:
|
||||
"""Set up UPnP/IGD device from a config entry."""
|
||||
_LOGGER.debug("async_setup_entry, config_entry: %s", config_entry.data)
|
||||
_LOGGER.debug("Setting up config entry: %s", config_entry.unique_id)
|
||||
|
||||
# Discover and construct.
|
||||
udn = config_entry.data.get(CONFIG_ENTRY_UDN)
|
||||
@@ -123,6 +126,11 @@ async def async_setup_entry(hass: HomeAssistantType, config_entry: ConfigEntry)
|
||||
|
||||
# Ensure entry has a unique_id.
|
||||
if not config_entry.unique_id:
|
||||
_LOGGER.debug(
|
||||
"Setting unique_id: %s, for config_entry: %s",
|
||||
device.unique_id,
|
||||
config_entry,
|
||||
)
|
||||
hass.config_entries.async_update_entry(
|
||||
entry=config_entry,
|
||||
unique_id=device.unique_id,
|
||||
@@ -152,6 +160,8 @@ async def async_unload_entry(
|
||||
hass: HomeAssistantType, config_entry: ConfigEntry
|
||||
) -> bool:
|
||||
"""Unload a UPnP/IGD device from a config entry."""
|
||||
_LOGGER.debug("Unloading config entry: %s", config_entry.unique_id)
|
||||
|
||||
udn = config_entry.data.get(CONFIG_ENTRY_UDN)
|
||||
if udn in hass.data[DOMAIN][DOMAIN_DEVICES]:
|
||||
del hass.data[DOMAIN][DOMAIN_DEVICES][udn]
|
||||
|
||||
@@ -154,6 +154,7 @@ class UpnpFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
# Store discovery.
|
||||
_LOGGER.debug("New discovery, continuing")
|
||||
name = discovery_info.get("friendlyName", "")
|
||||
discovery = {
|
||||
DISCOVERY_UDN: udn,
|
||||
|
||||
@@ -109,7 +109,7 @@ class Device:
|
||||
|
||||
def __str__(self) -> str:
|
||||
"""Get string representation."""
|
||||
return f"IGD Device: {self.name}/{self.udn}"
|
||||
return f"IGD Device: {self.name}/{self.udn}::{self.device_type}"
|
||||
|
||||
async def async_get_traffic_data(self) -> Mapping[str, any]:
|
||||
"""
|
||||
|
||||
@@ -40,7 +40,7 @@ DOMAIN = const.DOMAIN
|
||||
CONFIG_SCHEMA = vol.Schema(
|
||||
{
|
||||
DOMAIN: vol.All(
|
||||
cv.deprecated(const.CONF_PROFILES, invalidation_version="0.114"),
|
||||
cv.deprecated(const.CONF_PROFILES),
|
||||
vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_CLIENT_ID): vol.All(cv.string, vol.Length(min=1)),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"domain": "zeroconf",
|
||||
"name": "Zero-configuration networking (zeroconf)",
|
||||
"documentation": "https://www.home-assistant.io/integrations/zeroconf",
|
||||
"requirements": ["zeroconf==0.28.6"],
|
||||
"requirements": ["zeroconf==0.28.7"],
|
||||
"dependencies": ["api"],
|
||||
"codeowners": ["@bdraco"],
|
||||
"quality_scale": "internal"
|
||||
|
||||
@@ -89,12 +89,12 @@ class Metering(ZigbeeChannel):
|
||||
@property
|
||||
def divisor(self) -> int:
|
||||
"""Return divisor for the value."""
|
||||
return self.cluster.get("divisor")
|
||||
return self.cluster.get("divisor") or 1
|
||||
|
||||
@property
|
||||
def multiplier(self) -> int:
|
||||
"""Return multiplier for the value."""
|
||||
return self.cluster.get("multiplier")
|
||||
return self.cluster.get("multiplier") or 1
|
||||
|
||||
async def async_configure(self) -> None:
|
||||
"""Configure channel."""
|
||||
|
||||
@@ -254,8 +254,10 @@ class ZHADevice(LogMixin):
|
||||
"device_event_type": "device_offline"
|
||||
}
|
||||
}
|
||||
|
||||
if hasattr(self._zigpy_device, "device_automation_triggers"):
|
||||
triggers.update(self._zigpy_device.device_automation_triggers)
|
||||
|
||||
return triggers
|
||||
|
||||
@property
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"bellows==0.21.0",
|
||||
"pyserial==3.4",
|
||||
"pyserial-asyncio==0.4",
|
||||
"zha-quirks==0.0.48",
|
||||
"zha-quirks==0.0.49",
|
||||
"zigpy-cc==0.5.2",
|
||||
"zigpy-deconz==0.11.0",
|
||||
"zigpy==0.28.2",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Constants used by Home Assistant components."""
|
||||
MAJOR_VERSION = 1
|
||||
MINOR_VERSION = 0
|
||||
PATCH_VERSION = "0b5"
|
||||
MAJOR_VERSION = 2020
|
||||
MINOR_VERSION = 12
|
||||
PATCH_VERSION = "1"
|
||||
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
|
||||
__version__ = f"{__short_version__}.{PATCH_VERSION}"
|
||||
REQUIRED_PYTHON_VER = (3, 7, 1)
|
||||
|
||||
@@ -28,7 +28,6 @@ from typing import (
|
||||
from urllib.parse import urlparse
|
||||
from uuid import UUID
|
||||
|
||||
from pkg_resources import parse_version
|
||||
import voluptuous as vol
|
||||
import voluptuous_serialize
|
||||
|
||||
@@ -80,7 +79,6 @@ from homeassistant.const import (
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
WEEKDAYS,
|
||||
__version__,
|
||||
)
|
||||
from homeassistant.core import split_entity_id, valid_entity_id
|
||||
from homeassistant.exceptions import TemplateError
|
||||
@@ -712,7 +710,6 @@ class multi_select:
|
||||
def deprecated(
|
||||
key: str,
|
||||
replacement_key: Optional[str] = None,
|
||||
invalidation_version: Optional[str] = None,
|
||||
default: Optional[Any] = None,
|
||||
) -> Callable[[Dict], Dict]:
|
||||
"""
|
||||
@@ -725,8 +722,6 @@ def deprecated(
|
||||
- No warning if only replacement_key provided
|
||||
- No warning if neither key nor replacement_key are provided
|
||||
- Adds replacement_key with default value in this case
|
||||
- Once the invalidation_version is crossed, raises vol.Invalid if key
|
||||
is detected
|
||||
"""
|
||||
module = inspect.getmodule(inspect.stack()[1][0])
|
||||
if module is not None:
|
||||
@@ -737,56 +732,24 @@ def deprecated(
|
||||
# https://github.com/home-assistant/core/issues/24982
|
||||
module_name = __name__
|
||||
|
||||
if replacement_key and invalidation_version:
|
||||
warning = (
|
||||
"The '{key}' option is deprecated,"
|
||||
" please replace it with '{replacement_key}'."
|
||||
" This option {invalidation_status} invalid in version"
|
||||
" {invalidation_version}"
|
||||
)
|
||||
elif replacement_key:
|
||||
if replacement_key:
|
||||
warning = (
|
||||
"The '{key}' option is deprecated,"
|
||||
" please replace it with '{replacement_key}'"
|
||||
)
|
||||
elif invalidation_version:
|
||||
warning = (
|
||||
"The '{key}' option is deprecated,"
|
||||
" please remove it from your configuration."
|
||||
" This option {invalidation_status} invalid in version"
|
||||
" {invalidation_version}"
|
||||
)
|
||||
else:
|
||||
warning = (
|
||||
"The '{key}' option is deprecated,"
|
||||
" please remove it from your configuration"
|
||||
)
|
||||
|
||||
def check_for_invalid_version() -> None:
|
||||
"""Raise error if current version has reached invalidation."""
|
||||
if not invalidation_version:
|
||||
return
|
||||
|
||||
if parse_version(__version__) >= parse_version(invalidation_version):
|
||||
raise vol.Invalid(
|
||||
warning.format(
|
||||
key=key,
|
||||
replacement_key=replacement_key,
|
||||
invalidation_status="became",
|
||||
invalidation_version=invalidation_version,
|
||||
)
|
||||
)
|
||||
|
||||
def validator(config: Dict) -> Dict:
|
||||
"""Check if key is in config and log warning."""
|
||||
if key in config:
|
||||
check_for_invalid_version()
|
||||
KeywordStyleAdapter(logging.getLogger(module_name)).warning(
|
||||
warning,
|
||||
key=key,
|
||||
replacement_key=replacement_key,
|
||||
invalidation_status="will become",
|
||||
invalidation_version=invalidation_version,
|
||||
)
|
||||
|
||||
value = config[key]
|
||||
|
||||
@@ -13,7 +13,7 @@ defusedxml==0.6.0
|
||||
distro==1.5.0
|
||||
emoji==0.5.4
|
||||
hass-nabucasa==0.39.0
|
||||
home-assistant-frontend==20201210.0
|
||||
home-assistant-frontend==20201212.0
|
||||
httpx==0.16.1
|
||||
importlib-metadata==1.6.0;python_version<'3.8'
|
||||
jinja2>=2.11.2
|
||||
@@ -30,7 +30,7 @@ sqlalchemy==1.3.20
|
||||
voluptuous-serialize==2.4.0
|
||||
voluptuous==0.12.0
|
||||
yarl==1.4.2
|
||||
zeroconf==0.28.6
|
||||
zeroconf==0.28.7
|
||||
|
||||
pycryptodome>=3.6.6
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ aiopvpc==2.0.2
|
||||
aiopylgtv==0.3.3
|
||||
|
||||
# homeassistant.components.recollect_waste
|
||||
aiorecollect==0.2.2
|
||||
aiorecollect==1.0.1
|
||||
|
||||
# homeassistant.components.shelly
|
||||
aioshelly==0.5.1
|
||||
@@ -508,7 +508,7 @@ doorbirdpy==2.1.0
|
||||
dovado==0.4.1
|
||||
|
||||
# homeassistant.components.dsmr
|
||||
dsmr_parser==0.23
|
||||
dsmr_parser==0.25
|
||||
|
||||
# homeassistant.components.dwd_weather_warnings
|
||||
dwdwfsapi==1.0.3
|
||||
@@ -559,7 +559,7 @@ env_canada==0.2.4
|
||||
# envirophat==0.0.6
|
||||
|
||||
# homeassistant.components.enphase_envoy
|
||||
envoy_reader==0.17.0
|
||||
envoy_reader==0.17.3
|
||||
|
||||
# homeassistant.components.season
|
||||
ephem==3.7.7.0
|
||||
@@ -738,7 +738,7 @@ hass-nabucasa==0.39.0
|
||||
hass_splunk==0.1.1
|
||||
|
||||
# homeassistant.components.tasmota
|
||||
hatasmota==0.1.4
|
||||
hatasmota==0.1.6
|
||||
|
||||
# homeassistant.components.jewish_calendar
|
||||
hdate==0.9.12
|
||||
@@ -765,7 +765,7 @@ hole==0.5.1
|
||||
holidays==0.10.3
|
||||
|
||||
# homeassistant.components.frontend
|
||||
home-assistant-frontend==20201210.0
|
||||
home-assistant-frontend==20201212.0
|
||||
|
||||
# homeassistant.components.zwave
|
||||
homeassistant-pyozw==0.1.10
|
||||
@@ -2342,10 +2342,10 @@ zeep[async]==4.0.0
|
||||
zengge==0.2
|
||||
|
||||
# homeassistant.components.zeroconf
|
||||
zeroconf==0.28.6
|
||||
zeroconf==0.28.7
|
||||
|
||||
# homeassistant.components.zha
|
||||
zha-quirks==0.0.48
|
||||
zha-quirks==0.0.49
|
||||
|
||||
# homeassistant.components.zhong_hong
|
||||
zhong_hong_hvac==1.0.9
|
||||
|
||||
@@ -131,7 +131,7 @@ aiopvpc==2.0.2
|
||||
aiopylgtv==0.3.3
|
||||
|
||||
# homeassistant.components.recollect_waste
|
||||
aiorecollect==0.2.2
|
||||
aiorecollect==1.0.1
|
||||
|
||||
# homeassistant.components.shelly
|
||||
aioshelly==0.5.1
|
||||
@@ -269,7 +269,7 @@ distro==1.5.0
|
||||
doorbirdpy==2.1.0
|
||||
|
||||
# homeassistant.components.dsmr
|
||||
dsmr_parser==0.23
|
||||
dsmr_parser==0.25
|
||||
|
||||
# homeassistant.components.dynalite
|
||||
dynalite_devices==0.1.46
|
||||
@@ -376,7 +376,7 @@ hangups==0.4.11
|
||||
hass-nabucasa==0.39.0
|
||||
|
||||
# homeassistant.components.tasmota
|
||||
hatasmota==0.1.4
|
||||
hatasmota==0.1.6
|
||||
|
||||
# homeassistant.components.jewish_calendar
|
||||
hdate==0.9.12
|
||||
@@ -394,7 +394,7 @@ hole==0.5.1
|
||||
holidays==0.10.3
|
||||
|
||||
# homeassistant.components.frontend
|
||||
home-assistant-frontend==20201210.0
|
||||
home-assistant-frontend==20201212.0
|
||||
|
||||
# homeassistant.components.zwave
|
||||
homeassistant-pyozw==0.1.10
|
||||
@@ -1141,10 +1141,10 @@ yeelight==0.5.4
|
||||
zeep[async]==4.0.0
|
||||
|
||||
# homeassistant.components.zeroconf
|
||||
zeroconf==0.28.6
|
||||
zeroconf==0.28.7
|
||||
|
||||
# homeassistant.components.zha
|
||||
zha-quirks==0.0.48
|
||||
zha-quirks==0.0.49
|
||||
|
||||
# homeassistant.components.zha
|
||||
zigpy-cc==0.5.2
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""Test Home Assistant Cast."""
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.cast import home_assistant_cast
|
||||
from homeassistant.config import async_process_ha_core_config
|
||||
|
||||
@@ -86,3 +87,32 @@ async def test_use_cloud_url(hass, mock_zeroconf):
|
||||
assert len(calls) == 1
|
||||
controller = calls[0][0]
|
||||
assert controller.hass_url == "https://something.nabu.casa"
|
||||
|
||||
|
||||
async def test_remove_entry(hass, mock_zeroconf):
|
||||
"""Test removing config entry removes user."""
|
||||
entry = MockConfigEntry(
|
||||
connection_class=config_entries.CONN_CLASS_LOCAL_PUSH,
|
||||
data={},
|
||||
domain="cast",
|
||||
title="Google Cast",
|
||||
)
|
||||
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.cast.media_player._async_setup_platform"
|
||||
), patch(
|
||||
"pychromecast.discovery.discover_chromecasts", return_value=(True, None)
|
||||
), patch(
|
||||
"pychromecast.discovery.stop_discovery"
|
||||
):
|
||||
assert await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
assert "cast" in hass.config.components
|
||||
|
||||
user_id = entry.data.get("user_id")
|
||||
assert await hass.auth.async_get_user(user_id)
|
||||
|
||||
assert await hass.config_entries.async_remove(entry.entry_id)
|
||||
assert not await hass.auth.async_get_user(user_id)
|
||||
|
||||
@@ -44,7 +44,7 @@ async def test_setup_provide_implementation(hass):
|
||||
"homeassistant.components.cloud.account_link._get_services",
|
||||
return_value=[
|
||||
{"service": "test", "min_version": "0.1.0"},
|
||||
{"service": "too_new", "min_version": "100.0.0"},
|
||||
{"service": "too_new", "min_version": "1000000.0.0"},
|
||||
],
|
||||
):
|
||||
assert (
|
||||
|
||||
@@ -697,6 +697,15 @@ async def test_timestamp(hass):
|
||||
).strftime(FMT_DATETIME)
|
||||
== "2020-12-13 10:00:00"
|
||||
)
|
||||
# Use datetime.datetime.fromtimestamp
|
||||
assert (
|
||||
dt_util.as_local(
|
||||
datetime.datetime.fromtimestamp(
|
||||
state_without_tz.attributes[ATTR_TIMESTAMP]
|
||||
)
|
||||
).strftime(FMT_DATETIME)
|
||||
== "2020-12-13 10:00:00"
|
||||
)
|
||||
|
||||
# Test initial time sets timestamp correctly.
|
||||
state_time = hass.states.get("input_datetime.test_time_initial")
|
||||
@@ -704,5 +713,24 @@ async def test_timestamp(hass):
|
||||
assert state_time.state == "10:00:00"
|
||||
assert state_time.attributes[ATTR_TIMESTAMP] == 10 * 60 * 60
|
||||
|
||||
# Test that setting the timestamp of an entity works.
|
||||
await hass.services.async_call(
|
||||
DOMAIN,
|
||||
"set_datetime",
|
||||
{
|
||||
ATTR_ENTITY_ID: "input_datetime.test_datetime_initial_with_tz",
|
||||
ATTR_TIMESTAMP: state_without_tz.attributes[ATTR_TIMESTAMP],
|
||||
},
|
||||
blocking=True,
|
||||
)
|
||||
state_with_tz_updated = hass.states.get(
|
||||
"input_datetime.test_datetime_initial_with_tz"
|
||||
)
|
||||
assert state_with_tz_updated.state == "2020-12-13 10:00:00"
|
||||
assert (
|
||||
state_with_tz_updated.attributes[ATTR_TIMESTAMP]
|
||||
== state_without_tz.attributes[ATTR_TIMESTAMP]
|
||||
)
|
||||
|
||||
finally:
|
||||
dt_util.set_default_time_zone(ORIG_TIMEZONE)
|
||||
|
||||
@@ -20,11 +20,6 @@ DISCOVERY_INFO = {
|
||||
"name": "shelly1pm-12345",
|
||||
"properties": {"id": "shelly1pm-12345"},
|
||||
}
|
||||
SWITCH25_DISCOVERY_INFO = {
|
||||
"host": "1.1.1.1",
|
||||
"name": "shellyswitch25-12345",
|
||||
"properties": {"id": "shellyswitch25-12345"},
|
||||
}
|
||||
|
||||
|
||||
async def test_form(hass):
|
||||
@@ -67,7 +62,7 @@ async def test_form(hass):
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_title_without_name_and_prefix(hass):
|
||||
async def test_title_without_name(hass):
|
||||
"""Test we set the title to the hostname when the device doesn't have a name."""
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
@@ -330,29 +325,6 @@ async def test_zeroconf(hass):
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_zeroconf_with_switch_prefix(hass):
|
||||
"""Test we get remove shelly from the prefix."""
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
|
||||
with patch(
|
||||
"aioshelly.get_info",
|
||||
return_value={"mac": "test-mac", "type": "SHSW-1", "auth": False},
|
||||
):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
data=SWITCH25_DISCOVERY_INFO,
|
||||
context={"source": config_entries.SOURCE_ZEROCONF},
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["errors"] == {}
|
||||
context = next(
|
||||
flow["context"]
|
||||
for flow in hass.config_entries.flow.async_progress()
|
||||
if flow["flow_id"] == result["flow_id"]
|
||||
)
|
||||
assert context["title_placeholders"]["name"] == "switch25-12345"
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"error", [(asyncio.TimeoutError, "cannot_connect"), (ValueError, "unknown")]
|
||||
)
|
||||
|
||||
@@ -698,116 +698,6 @@ def test_deprecated_with_replacement_key(caplog, schema):
|
||||
assert test_data == output
|
||||
|
||||
|
||||
def test_deprecated_with_invalidation_version(caplog, schema, version):
|
||||
"""
|
||||
Test deprecation behaves correctly with only an invalidation_version.
|
||||
|
||||
Expected behavior:
|
||||
- Outputs the appropriate deprecation warning if key is detected
|
||||
- Processes schema without changing any values
|
||||
- No warning or difference in output if key is not provided
|
||||
- Once the invalidation_version is crossed, raises vol.Invalid if key
|
||||
is detected
|
||||
"""
|
||||
deprecated_schema = vol.All(
|
||||
cv.deprecated("mars", invalidation_version="9999.99.9"), schema
|
||||
)
|
||||
|
||||
message = (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please remove it from your configuration. "
|
||||
"This option will become invalid in version 9999.99.9"
|
||||
)
|
||||
|
||||
test_data = {"mars": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 1
|
||||
assert message in caplog.text
|
||||
assert test_data == output
|
||||
|
||||
caplog.clear()
|
||||
assert len(caplog.records) == 0
|
||||
|
||||
test_data = {"venus": False}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert test_data == output
|
||||
|
||||
invalidated_schema = vol.All(
|
||||
cv.deprecated("mars", invalidation_version="0.1.0"), schema
|
||||
)
|
||||
test_data = {"mars": True}
|
||||
with pytest.raises(vol.MultipleInvalid) as exc_info:
|
||||
invalidated_schema(test_data)
|
||||
assert str(exc_info.value) == (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please remove it from your configuration. This option became "
|
||||
"invalid in version 0.1.0"
|
||||
)
|
||||
|
||||
|
||||
def test_deprecated_with_replacement_key_and_invalidation_version(
|
||||
caplog, schema, version
|
||||
):
|
||||
"""
|
||||
Test deprecation behaves with a replacement key & invalidation_version.
|
||||
|
||||
Expected behavior:
|
||||
- Outputs the appropriate deprecation warning if key is detected
|
||||
- Processes schema moving the value from key to replacement_key
|
||||
- Processes schema changing nothing if only replacement_key provided
|
||||
- No warning if only replacement_key provided
|
||||
- No warning or difference in output if neither key nor
|
||||
replacement_key are provided
|
||||
- Once the invalidation_version is crossed, raises vol.Invalid if key
|
||||
is detected
|
||||
"""
|
||||
deprecated_schema = vol.All(
|
||||
cv.deprecated(
|
||||
"mars", replacement_key="jupiter", invalidation_version="9999.99.9"
|
||||
),
|
||||
schema,
|
||||
)
|
||||
|
||||
warning = (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please replace it with 'jupiter'. This option will become "
|
||||
"invalid in version 9999.99.9"
|
||||
)
|
||||
|
||||
test_data = {"mars": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 1
|
||||
assert warning in caplog.text
|
||||
assert {"jupiter": True} == output
|
||||
|
||||
caplog.clear()
|
||||
assert len(caplog.records) == 0
|
||||
|
||||
test_data = {"jupiter": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert test_data == output
|
||||
|
||||
test_data = {"venus": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert test_data == output
|
||||
|
||||
invalidated_schema = vol.All(
|
||||
cv.deprecated("mars", replacement_key="jupiter", invalidation_version="0.1.0"),
|
||||
schema,
|
||||
)
|
||||
test_data = {"mars": True}
|
||||
with pytest.raises(vol.MultipleInvalid) as exc_info:
|
||||
invalidated_schema(test_data)
|
||||
assert str(exc_info.value) == (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please replace it with 'jupiter'. This option became "
|
||||
"invalid in version 0.1.0"
|
||||
)
|
||||
|
||||
|
||||
def test_deprecated_with_default(caplog, schema):
|
||||
"""
|
||||
Test deprecation behaves correctly with a default value.
|
||||
@@ -894,69 +784,6 @@ def test_deprecated_with_replacement_key_and_default(caplog, schema):
|
||||
assert {"jupiter": True} == output
|
||||
|
||||
|
||||
def test_deprecated_with_replacement_key_invalidation_version_default(
|
||||
caplog, schema, version
|
||||
):
|
||||
"""
|
||||
Test deprecation with a replacement key, invalidation_version & default.
|
||||
|
||||
Expected behavior:
|
||||
- Outputs the appropriate deprecation warning if key is detected
|
||||
- Processes schema moving the value from key to replacement_key
|
||||
- Processes schema changing nothing if only replacement_key provided
|
||||
- No warning if only replacement_key provided
|
||||
- No warning if neither key nor replacement_key are provided
|
||||
- Adds replacement_key with default value in this case
|
||||
- Once the invalidation_version is crossed, raises vol.Invalid if key
|
||||
is detected
|
||||
"""
|
||||
deprecated_schema = vol.All(
|
||||
cv.deprecated(
|
||||
"mars",
|
||||
replacement_key="jupiter",
|
||||
invalidation_version="9999.99.9",
|
||||
default=False,
|
||||
),
|
||||
schema,
|
||||
)
|
||||
|
||||
test_data = {"mars": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 1
|
||||
assert (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please replace it with 'jupiter'. This option will become "
|
||||
"invalid in version 9999.99.9"
|
||||
) in caplog.text
|
||||
assert {"jupiter": True} == output
|
||||
|
||||
caplog.clear()
|
||||
assert len(caplog.records) == 0
|
||||
|
||||
test_data = {"jupiter": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert test_data == output
|
||||
|
||||
test_data = {"venus": True}
|
||||
output = deprecated_schema(test_data.copy())
|
||||
assert len(caplog.records) == 0
|
||||
assert {"venus": True, "jupiter": False} == output
|
||||
|
||||
invalidated_schema = vol.All(
|
||||
cv.deprecated("mars", replacement_key="jupiter", invalidation_version="0.1.0"),
|
||||
schema,
|
||||
)
|
||||
test_data = {"mars": True}
|
||||
with pytest.raises(vol.MultipleInvalid) as exc_info:
|
||||
invalidated_schema(test_data)
|
||||
assert str(exc_info.value) == (
|
||||
"The 'mars' option is deprecated, "
|
||||
"please replace it with 'jupiter'. This option became "
|
||||
"invalid in version 0.1.0"
|
||||
)
|
||||
|
||||
|
||||
def test_deprecated_cant_find_module():
|
||||
"""Test if the current module cannot be inspected."""
|
||||
with patch("inspect.getmodule", return_value=None):
|
||||
@@ -964,7 +791,6 @@ def test_deprecated_cant_find_module():
|
||||
cv.deprecated(
|
||||
"mars",
|
||||
replacement_key="jupiter",
|
||||
invalidation_version="1.0.0",
|
||||
default=False,
|
||||
)
|
||||
|
||||
|
||||
@@ -1116,7 +1116,7 @@ async def test_component_config_exceptions(hass, caplog):
|
||||
("non_existing", vol.Schema({"zone": int}), None),
|
||||
("zone", vol.Schema({}), None),
|
||||
("plex", vol.Schema(vol.All({"plex": {"host": str}})), "dict"),
|
||||
("openuv", cv.deprecated("openuv", invalidation_version="0.115"), None),
|
||||
("openuv", cv.deprecated("openuv"), None),
|
||||
],
|
||||
)
|
||||
def test_identify_config_schema(domain, schema, expected):
|
||||
|
||||
Reference in New Issue
Block a user