mirror of
https://github.com/home-assistant/core.git
synced 2026-01-09 00:58:32 +01:00
Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e670a8f3b6 | ||
|
|
d1ad474a8d | ||
|
|
af4849c183 | ||
|
|
19531b90a3 | ||
|
|
62f8d6cc04 | ||
|
|
99d7c83917 | ||
|
|
59c20686c1 | ||
|
|
78f81b6e37 | ||
|
|
a58219bbc7 | ||
|
|
f76211d58a | ||
|
|
0cac5b7cb3 | ||
|
|
89168dd372 | ||
|
|
9c5dba6a24 | ||
|
|
2be5547c57 | ||
|
|
8394685493 | ||
|
|
c8bb6eb3bf | ||
|
|
217e3c44d6 | ||
|
|
4ec81d4b67 | ||
|
|
ac62028c19 | ||
|
|
ff9e1ddeed | ||
|
|
3a82aecd38 | ||
|
|
3a41878a8c | ||
|
|
3ab0b63540 | ||
|
|
3752fa3123 | ||
|
|
07df3b9565 | ||
|
|
43ef5bab18 | ||
|
|
150ce05e26 | ||
|
|
70bd998d7c | ||
|
|
3600dec6e0 | ||
|
|
277b916fcd | ||
|
|
623826261b | ||
|
|
1ac5ecbe69 | ||
|
|
3981592ccd | ||
|
|
9c45874206 | ||
|
|
17cd00ba83 | ||
|
|
c02be99ab7 | ||
|
|
7c2a2b08c7 | ||
|
|
f858d6f9ec | ||
|
|
8507b62016 | ||
|
|
8c6636994f | ||
|
|
9c6ff9af91 | ||
|
|
3986df63dc | ||
|
|
42d1644762 | ||
|
|
83b7439a08 | ||
|
|
a01cf72d67 |
@@ -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
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""Import logic for blueprint."""
|
||||
from dataclasses import dataclass
|
||||
import html
|
||||
import re
|
||||
from typing import Optional
|
||||
|
||||
@@ -107,7 +108,7 @@ def _extract_blueprint_from_community_topic(
|
||||
if block_syntax not in ("auto", "yaml"):
|
||||
continue
|
||||
|
||||
block_content = block_content.strip()
|
||||
block_content = html.unescape(block_content.strip())
|
||||
|
||||
try:
|
||||
data = yaml.parse_yaml(block_content)
|
||||
|
||||
@@ -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(
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "deCONZ",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/deconz",
|
||||
"requirements": ["pydeconz==76"],
|
||||
"requirements": ["pydeconz==77"],
|
||||
"ssdp": [
|
||||
{
|
||||
"manufacturer": "Royal Philips Electronics"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "Denon AVR Network Receivers",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/denonavr",
|
||||
"requirements": ["denonavr==0.9.7", "getmac==0.8.2"],
|
||||
"requirements": ["denonavr==0.9.8", "getmac==0.8.2"],
|
||||
"codeowners": ["@scarface-4711", "@starkillerOG"],
|
||||
"ssdp": [
|
||||
{
|
||||
|
||||
@@ -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"
|
||||
]
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
"domain": "environment_canada",
|
||||
"name": "Environment Canada",
|
||||
"documentation": "https://www.home-assistant.io/integrations/environment_canada",
|
||||
"requirements": ["env_canada==0.2.4"],
|
||||
"requirements": ["env_canada==0.2.5"],
|
||||
"codeowners": ["@michaeldavie"]
|
||||
}
|
||||
|
||||
@@ -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==20201204.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)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "HomeKit",
|
||||
"documentation": "https://www.home-assistant.io/integrations/homekit",
|
||||
"requirements": [
|
||||
"HAP-python==3.0.0",
|
||||
"HAP-python==3.1.0",
|
||||
"fnvhash==0.1.0",
|
||||
"PyQRCode==1.2.1",
|
||||
"base36==0.1.1",
|
||||
|
||||
@@ -248,4 +248,5 @@ class HomeKitWindowCover(HomeKitEntity, CoverEntity):
|
||||
ENTITY_TYPES = {
|
||||
ServicesTypes.GARAGE_DOOR_OPENER: HomeKitGarageDoorCover,
|
||||
ServicesTypes.WINDOW_COVERING: HomeKitWindowCover,
|
||||
ServicesTypes.WINDOW: HomeKitWindowCover,
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ async def async_setup_entry(hass, entry):
|
||||
)
|
||||
|
||||
websession = aiohttp_client.async_get_clientsession(hass)
|
||||
client = Client(entry.data[CONF_ZIP_CODE], websession)
|
||||
client = Client(entry.data[CONF_ZIP_CODE], session=websession)
|
||||
|
||||
async def async_get_data_from_api(api_coro):
|
||||
"""Get data from a particular API coroutine."""
|
||||
|
||||
@@ -30,7 +30,7 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
websession = aiohttp_client.async_get_clientsession(self.hass)
|
||||
|
||||
try:
|
||||
Client(user_input[CONF_ZIP_CODE], websession)
|
||||
Client(user_input[CONF_ZIP_CODE], session=websession)
|
||||
except InvalidZipError:
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
"name": "IQVIA",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/iqvia",
|
||||
"requirements": ["numpy==1.19.2", "pyiqvia==0.2.1"],
|
||||
"requirements": ["numpy==1.19.2", "pyiqvia==0.3.1"],
|
||||
"codeowners": ["@bachya"]
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"domain": "myq",
|
||||
"name": "MyQ",
|
||||
"documentation": "https://www.home-assistant.io/integrations/myq",
|
||||
"requirements": ["pymyq==2.0.11"],
|
||||
"requirements": ["pymyq==2.0.12"],
|
||||
"codeowners": ["@bdraco"],
|
||||
"config_flow": true,
|
||||
"homekit": {
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
"domain": "nissan_leaf",
|
||||
"name": "Nissan Leaf",
|
||||
"documentation": "https://www.home-assistant.io/integrations/nissan_leaf",
|
||||
"requirements": ["pycarwings2==2.9"],
|
||||
"requirements": ["pycarwings2==2.10"],
|
||||
"codeowners": ["@filcole"]
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -161,7 +161,7 @@ class NWSWeather(WeatherEntity):
|
||||
temp_c = None
|
||||
if self.observation:
|
||||
temp_c = self.observation.get("temperature")
|
||||
if temp_c:
|
||||
if temp_c is not None:
|
||||
return convert_temperature(temp_c, TEMP_CELSIUS, TEMP_FAHRENHEIT)
|
||||
return None
|
||||
|
||||
@@ -273,7 +273,7 @@ class NWSWeather(WeatherEntity):
|
||||
|
||||
data[ATTR_FORECAST_WIND_BEARING] = forecast_entry.get("windBearing")
|
||||
wind_speed = forecast_entry.get("windSpeedAvg")
|
||||
if wind_speed:
|
||||
if wind_speed is not None:
|
||||
if self.is_metric:
|
||||
data[ATTR_FORECAST_WIND_SPEED] = round(
|
||||
convert_distance(wind_speed, LENGTH_MILES, LENGTH_KILOMETERS)
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -275,7 +275,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
]:
|
||||
hass.services.async_register(DOMAIN, service, method, schema=schema)
|
||||
|
||||
hass.data[DOMAIN][DATA_LISTENER] = entry.add_update_listener(async_reload_entry)
|
||||
hass.data[DOMAIN][DATA_LISTENER][entry.entry_id] = entry.add_update_listener(
|
||||
async_reload_entry
|
||||
)
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/roon",
|
||||
"requirements": [
|
||||
"roonapi==0.0.25"
|
||||
"roonapi==0.0.28"
|
||||
],
|
||||
"codeowners": [
|
||||
"@pavoni"
|
||||
|
||||
@@ -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
|
||||
}
|
||||
),
|
||||
|
||||
@@ -56,7 +56,7 @@ class TriggerInstance:
|
||||
event_trigger.CONF_EVENT_TYPE: TASMOTA_EVENT,
|
||||
event_trigger.CONF_EVENT_DATA: {
|
||||
"mac": self.trigger.tasmota_trigger.cfg.mac,
|
||||
"source": self.trigger.tasmota_trigger.cfg.source,
|
||||
"source": self.trigger.tasmota_trigger.cfg.subtype,
|
||||
"event": self.trigger.tasmota_trigger.cfg.event,
|
||||
},
|
||||
}
|
||||
@@ -126,7 +126,7 @@ class Trigger:
|
||||
def _on_trigger():
|
||||
data = {
|
||||
"mac": self.tasmota_trigger.cfg.mac,
|
||||
"source": self.tasmota_trigger.cfg.source,
|
||||
"source": self.tasmota_trigger.cfg.subtype,
|
||||
"event": self.tasmota_trigger.cfg.event,
|
||||
}
|
||||
self.hass.bus.async_fire(
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -52,25 +52,33 @@ async def async_attach_trigger(
|
||||
if not result_as_boolean(result):
|
||||
return
|
||||
|
||||
entity_id = event.data.get("entity_id")
|
||||
from_s = event.data.get("old_state")
|
||||
to_s = event.data.get("new_state")
|
||||
entity_id = event and event.data.get("entity_id")
|
||||
from_s = event and event.data.get("old_state")
|
||||
to_s = event and event.data.get("new_state")
|
||||
|
||||
if entity_id is not None:
|
||||
description = f"{entity_id} via template"
|
||||
else:
|
||||
description = "time change or manual update via template"
|
||||
|
||||
template_variables = {
|
||||
"platform": platform_type,
|
||||
"entity_id": entity_id,
|
||||
"from_state": from_s,
|
||||
"to_state": to_s,
|
||||
}
|
||||
trigger_variables = {
|
||||
"for": time_delta,
|
||||
"description": description,
|
||||
}
|
||||
|
||||
@callback
|
||||
def call_action(*_):
|
||||
"""Call action with right context."""
|
||||
nonlocal trigger_variables
|
||||
hass.async_run_hass_job(
|
||||
job,
|
||||
{
|
||||
"trigger": {
|
||||
"platform": "template",
|
||||
"entity_id": entity_id,
|
||||
"from_state": from_s,
|
||||
"to_state": to_s,
|
||||
"for": time_delta if not time_delta else period,
|
||||
"description": f"{entity_id} via template",
|
||||
}
|
||||
},
|
||||
{"trigger": {**template_variables, **trigger_variables}},
|
||||
(to_s.context if to_s else None),
|
||||
)
|
||||
|
||||
@@ -78,18 +86,9 @@ async def async_attach_trigger(
|
||||
call_action()
|
||||
return
|
||||
|
||||
variables = {
|
||||
"trigger": {
|
||||
"platform": platform_type,
|
||||
"entity_id": entity_id,
|
||||
"from_state": from_s,
|
||||
"to_state": to_s,
|
||||
}
|
||||
}
|
||||
|
||||
try:
|
||||
period = cv.positive_time_period(
|
||||
template.render_complex(time_delta, variables)
|
||||
template.render_complex(time_delta, {"trigger": template_variables})
|
||||
)
|
||||
except (exceptions.TemplateError, vol.Invalid) as ex:
|
||||
_LOGGER.error(
|
||||
@@ -97,6 +96,8 @@ async def async_attach_trigger(
|
||||
)
|
||||
return
|
||||
|
||||
trigger_variables["for"] = period
|
||||
|
||||
delay_cancel = async_call_later(hass, period.seconds, call_action)
|
||||
|
||||
info = async_track_template_result(
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "IKEA TRÅDFRI",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/tradfri",
|
||||
"requirements": ["pytradfri[async]==7.0.4"],
|
||||
"requirements": ["pytradfri[async]==7.0.5"],
|
||||
"homekit": {
|
||||
"models": ["TRADFRI"]
|
||||
},
|
||||
|
||||
@@ -397,7 +397,12 @@ class UniFiController:
|
||||
await self.api.login()
|
||||
self.api.start_websocket()
|
||||
|
||||
except (asyncio.TimeoutError, aiounifi.AiounifiException):
|
||||
except (
|
||||
asyncio.TimeoutError,
|
||||
aiounifi.BadGateway,
|
||||
aiounifi.ServiceUnavailable,
|
||||
aiounifi.AiounifiException,
|
||||
):
|
||||
self.hass.loop.call_later(RETRY_TIMER, self.reconnect)
|
||||
|
||||
@callback
|
||||
@@ -464,7 +469,12 @@ async def get_controller(
|
||||
LOGGER.warning("Connected to UniFi at %s but not registered.", host)
|
||||
raise AuthenticationRequired from err
|
||||
|
||||
except (asyncio.TimeoutError, aiounifi.RequestError) as err:
|
||||
except (
|
||||
asyncio.TimeoutError,
|
||||
aiounifi.BadGateway,
|
||||
aiounifi.ServiceUnavailable,
|
||||
aiounifi.RequestError,
|
||||
) as err:
|
||||
LOGGER.error("Error connecting to the UniFi controller at %s", host)
|
||||
raise CannotConnect from err
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "Ubiquiti UniFi",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/unifi",
|
||||
"requirements": ["aiounifi==25"],
|
||||
"requirements": ["aiounifi==26"],
|
||||
"codeowners": ["@Kane610"],
|
||||
"quality_scale": "platinum"
|
||||
}
|
||||
|
||||
@@ -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]:
|
||||
"""
|
||||
|
||||
@@ -204,7 +204,7 @@ class Volumio(MediaPlayerEntity):
|
||||
|
||||
async def async_media_pause(self):
|
||||
"""Send media_pause command to media player."""
|
||||
if self._state["trackType"] == "webradio":
|
||||
if self._state.get("trackType") == "webradio":
|
||||
await self._volumio.stop()
|
||||
else:
|
||||
await self._volumio.pause()
|
||||
|
||||
@@ -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 = "0b4"
|
||||
MAJOR_VERSION = 2020
|
||||
MINOR_VERSION = 12
|
||||
PATCH_VERSION = "2"
|
||||
__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==20201204.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
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ Adafruit-SHT31==1.0.2
|
||||
# Adafruit_BBIO==1.1.1
|
||||
|
||||
# homeassistant.components.homekit
|
||||
HAP-python==3.0.0
|
||||
HAP-python==3.1.0
|
||||
|
||||
# homeassistant.components.mastodon
|
||||
Mastodon.py==1.5.1
|
||||
@@ -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
|
||||
@@ -224,7 +224,7 @@ aioshelly==0.5.1
|
||||
aioswitcher==1.2.1
|
||||
|
||||
# homeassistant.components.unifi
|
||||
aiounifi==25
|
||||
aiounifi==26
|
||||
|
||||
# homeassistant.components.yandex_transport
|
||||
aioymaps==1.1.0
|
||||
@@ -481,7 +481,7 @@ defusedxml==0.6.0
|
||||
deluge-client==1.7.1
|
||||
|
||||
# homeassistant.components.denonavr
|
||||
denonavr==0.9.7
|
||||
denonavr==0.9.8
|
||||
|
||||
# homeassistant.components.devolo_home_control
|
||||
devolo-home-control-api==0.16.0
|
||||
@@ -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
|
||||
@@ -553,13 +553,13 @@ enocean==0.50
|
||||
enturclient==0.2.1
|
||||
|
||||
# homeassistant.components.environment_canada
|
||||
env_canada==0.2.4
|
||||
env_canada==0.2.5
|
||||
|
||||
# homeassistant.components.envirophat
|
||||
# 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==20201204.0
|
||||
home-assistant-frontend==20201212.0
|
||||
|
||||
# homeassistant.components.zwave
|
||||
homeassistant-pyozw==0.1.10
|
||||
@@ -1298,7 +1298,7 @@ pyblackbird==0.5
|
||||
pybotvac==0.0.17
|
||||
|
||||
# homeassistant.components.nissan_leaf
|
||||
pycarwings2==2.9
|
||||
pycarwings2==2.10
|
||||
|
||||
# homeassistant.components.cloudflare
|
||||
pycfdns==1.2.1
|
||||
@@ -1337,7 +1337,7 @@ pydaikin==2.3.1
|
||||
pydanfossair==0.1.0
|
||||
|
||||
# homeassistant.components.deconz
|
||||
pydeconz==76
|
||||
pydeconz==77
|
||||
|
||||
# homeassistant.components.delijn
|
||||
pydelijn==0.6.1
|
||||
@@ -1455,7 +1455,7 @@ pyipma==2.0.5
|
||||
pyipp==0.11.0
|
||||
|
||||
# homeassistant.components.iqvia
|
||||
pyiqvia==0.2.1
|
||||
pyiqvia==0.3.1
|
||||
|
||||
# homeassistant.components.irish_rail_transport
|
||||
pyirishrail==0.0.2
|
||||
@@ -1542,7 +1542,7 @@ pymsteams==0.1.12
|
||||
pymusiccast==0.1.6
|
||||
|
||||
# homeassistant.components.myq
|
||||
pymyq==2.0.11
|
||||
pymyq==2.0.12
|
||||
|
||||
# homeassistant.components.mysensors
|
||||
pymysensors==0.18.0
|
||||
@@ -1858,7 +1858,7 @@ pytraccar==0.9.0
|
||||
pytrackr==0.0.5
|
||||
|
||||
# homeassistant.components.tradfri
|
||||
pytradfri[async]==7.0.4
|
||||
pytradfri[async]==7.0.5
|
||||
|
||||
# homeassistant.components.trafikverket_train
|
||||
# homeassistant.components.trafikverket_weatherstation
|
||||
@@ -1958,7 +1958,7 @@ rokuecp==0.6.0
|
||||
roombapy==1.6.2
|
||||
|
||||
# homeassistant.components.roon
|
||||
roonapi==0.0.25
|
||||
roonapi==0.0.28
|
||||
|
||||
# homeassistant.components.rova
|
||||
rova==0.1.0
|
||||
@@ -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
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
-r requirements_test.txt
|
||||
|
||||
# homeassistant.components.homekit
|
||||
HAP-python==3.0.0
|
||||
HAP-python==3.1.0
|
||||
|
||||
# homeassistant.components.flick_electric
|
||||
PyFlick==0.0.2
|
||||
@@ -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
|
||||
@@ -140,7 +140,7 @@ aioshelly==0.5.1
|
||||
aioswitcher==1.2.1
|
||||
|
||||
# homeassistant.components.unifi
|
||||
aiounifi==25
|
||||
aiounifi==26
|
||||
|
||||
# homeassistant.components.yandex_transport
|
||||
aioymaps==1.1.0
|
||||
@@ -254,7 +254,7 @@ debugpy==1.2.0
|
||||
defusedxml==0.6.0
|
||||
|
||||
# homeassistant.components.denonavr
|
||||
denonavr==0.9.7
|
||||
denonavr==0.9.8
|
||||
|
||||
# homeassistant.components.devolo_home_control
|
||||
devolo-home-control-api==0.16.0
|
||||
@@ -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==20201204.0
|
||||
home-assistant-frontend==20201212.0
|
||||
|
||||
# homeassistant.components.zwave
|
||||
homeassistant-pyozw==0.1.10
|
||||
@@ -673,7 +673,7 @@ pycountry==19.8.18
|
||||
pydaikin==2.3.1
|
||||
|
||||
# homeassistant.components.deconz
|
||||
pydeconz==76
|
||||
pydeconz==77
|
||||
|
||||
# homeassistant.components.dexcom
|
||||
pydexcom==0.2.0
|
||||
@@ -734,7 +734,7 @@ pyipma==2.0.5
|
||||
pyipp==0.11.0
|
||||
|
||||
# homeassistant.components.iqvia
|
||||
pyiqvia==0.2.1
|
||||
pyiqvia==0.3.1
|
||||
|
||||
# homeassistant.components.isy994
|
||||
pyisy==2.1.0
|
||||
@@ -782,7 +782,7 @@ pymodbus==2.3.0
|
||||
pymonoprice==0.3
|
||||
|
||||
# homeassistant.components.myq
|
||||
pymyq==2.0.11
|
||||
pymyq==2.0.12
|
||||
|
||||
# homeassistant.components.nut
|
||||
pynut2==2.1.2
|
||||
@@ -915,7 +915,7 @@ pytile==4.0.0
|
||||
pytraccar==0.9.0
|
||||
|
||||
# homeassistant.components.tradfri
|
||||
pytradfri[async]==7.0.4
|
||||
pytradfri[async]==7.0.5
|
||||
|
||||
# homeassistant.components.vera
|
||||
pyvera==0.3.11
|
||||
@@ -960,7 +960,7 @@ rokuecp==0.6.0
|
||||
roombapy==1.6.2
|
||||
|
||||
# homeassistant.components.roon
|
||||
roonapi==0.0.25
|
||||
roonapi==0.0.28
|
||||
|
||||
# homeassistant.components.rpi_power
|
||||
rpi-bad-power==0.1.0
|
||||
@@ -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
|
||||
|
||||
@@ -16,6 +16,70 @@ def community_post():
|
||||
return load_fixture("blueprint/community_post.json")
|
||||
|
||||
|
||||
COMMUNITY_POST_INPUTS = {
|
||||
"remote": {
|
||||
"name": "Remote",
|
||||
"description": "IKEA remote to use",
|
||||
"selector": {
|
||||
"device": {
|
||||
"integration": "zha",
|
||||
"manufacturer": "IKEA of Sweden",
|
||||
"model": "TRADFRI remote control",
|
||||
}
|
||||
},
|
||||
},
|
||||
"light": {
|
||||
"name": "Light(s)",
|
||||
"description": "The light(s) to control",
|
||||
"selector": {"target": {"entity": {"domain": "light"}}},
|
||||
},
|
||||
"force_brightness": {
|
||||
"name": "Force turn on brightness",
|
||||
"description": 'Force the brightness to the set level below, when the "on" button on the remote is pushed and lights turn on.\n',
|
||||
"default": False,
|
||||
"selector": {"boolean": {}},
|
||||
},
|
||||
"brightness": {
|
||||
"name": "Brightness",
|
||||
"description": "Brightness of the light(s) when turning on",
|
||||
"default": 50,
|
||||
"selector": {
|
||||
"number": {
|
||||
"min": 0.0,
|
||||
"max": 100.0,
|
||||
"mode": "slider",
|
||||
"step": 1.0,
|
||||
"unit_of_measurement": "%",
|
||||
}
|
||||
},
|
||||
},
|
||||
"button_left_short": {
|
||||
"name": "Left button - short press",
|
||||
"description": "Action to run on short left button press",
|
||||
"default": [],
|
||||
"selector": {"action": {}},
|
||||
},
|
||||
"button_left_long": {
|
||||
"name": "Left button - long press",
|
||||
"description": "Action to run on long left button press",
|
||||
"default": [],
|
||||
"selector": {"action": {}},
|
||||
},
|
||||
"button_right_short": {
|
||||
"name": "Right button - short press",
|
||||
"description": "Action to run on short right button press",
|
||||
"default": [],
|
||||
"selector": {"action": {}},
|
||||
},
|
||||
"button_right_long": {
|
||||
"name": "Right button - long press",
|
||||
"description": "Action to run on long right button press",
|
||||
"default": [],
|
||||
"selector": {"action": {}},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def test_get_community_post_import_url():
|
||||
"""Test variations of generating import forum url."""
|
||||
assert (
|
||||
@@ -57,10 +121,7 @@ def test_extract_blueprint_from_community_topic(community_post):
|
||||
)
|
||||
assert imported_blueprint is not None
|
||||
assert imported_blueprint.blueprint.domain == "automation"
|
||||
assert imported_blueprint.blueprint.inputs == {
|
||||
"service_to_call": None,
|
||||
"trigger_event": None,
|
||||
}
|
||||
assert imported_blueprint.blueprint.inputs == COMMUNITY_POST_INPUTS
|
||||
|
||||
|
||||
def test_extract_blueprint_from_community_topic_invalid_yaml():
|
||||
@@ -103,15 +164,16 @@ async def test_fetch_blueprint_from_community_url(hass, aioclient_mock, communit
|
||||
)
|
||||
assert isinstance(imported_blueprint, importer.ImportedBlueprint)
|
||||
assert imported_blueprint.blueprint.domain == "automation"
|
||||
assert imported_blueprint.blueprint.inputs == {
|
||||
"service_to_call": None,
|
||||
"trigger_event": None,
|
||||
}
|
||||
assert imported_blueprint.suggested_filename == "balloob/test-topic"
|
||||
assert imported_blueprint.blueprint.inputs == COMMUNITY_POST_INPUTS
|
||||
assert (
|
||||
imported_blueprint.suggested_filename
|
||||
== "frenck/zha-ikea-five-button-remote-for-lights"
|
||||
)
|
||||
assert (
|
||||
imported_blueprint.blueprint.metadata["source_url"]
|
||||
== "https://community.home-assistant.io/t/test-topic/123/2"
|
||||
)
|
||||
assert "gt;" not in imported_blueprint.raw_data
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
"""
|
||||
Test against characteristics captured from a Velux Gateway.
|
||||
|
||||
https://github.com/home-assistant/core/issues/44314
|
||||
"""
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_OPEN,
|
||||
SUPPORT_SET_POSITION,
|
||||
)
|
||||
|
||||
from tests.components.homekit_controller.common import (
|
||||
Helper,
|
||||
setup_accessories_from_file,
|
||||
setup_test_accessories,
|
||||
)
|
||||
|
||||
|
||||
async def test_simpleconnect_cover_setup(hass):
|
||||
"""Test that a velux gateway can be correctly setup in HA."""
|
||||
accessories = await setup_accessories_from_file(hass, "velux_gateway.json")
|
||||
config_entry, pairing = await setup_test_accessories(hass, accessories)
|
||||
|
||||
entity_registry = await hass.helpers.entity_registry.async_get_registry()
|
||||
|
||||
# Check that the cover is correctly found and set up
|
||||
cover_id = "cover.velux_window"
|
||||
cover = entity_registry.async_get(cover_id)
|
||||
assert cover.unique_id == "homekit-1111111a114a111a-8"
|
||||
|
||||
cover_helper = Helper(
|
||||
hass,
|
||||
cover_id,
|
||||
pairing,
|
||||
accessories[0],
|
||||
config_entry,
|
||||
)
|
||||
|
||||
cover_state = await cover_helper.poll_and_get_state()
|
||||
assert cover_state.attributes["friendly_name"] == "VELUX Window"
|
||||
assert cover_state.state == "closed"
|
||||
assert cover_state.attributes["supported_features"] == (
|
||||
SUPPORT_CLOSE | SUPPORT_SET_POSITION | SUPPORT_OPEN
|
||||
)
|
||||
|
||||
# Check that one of the sensors is correctly found and set up
|
||||
sensor_id = "sensor.velux_sensor_temperature"
|
||||
sensor = entity_registry.async_get(sensor_id)
|
||||
assert sensor.unique_id == "homekit-a11b111-8"
|
||||
|
||||
sensor_helper = Helper(
|
||||
hass,
|
||||
sensor_id,
|
||||
pairing,
|
||||
accessories[0],
|
||||
config_entry,
|
||||
)
|
||||
|
||||
sensor_state = await sensor_helper.poll_and_get_state()
|
||||
assert sensor_state.attributes["friendly_name"] == "VELUX Sensor Temperature"
|
||||
assert sensor_state.state == "18.9"
|
||||
|
||||
# The cover and sensor are different devices (accessories) attached to the same bridge
|
||||
assert cover.device_id != sensor.device_id
|
||||
|
||||
device_registry = await hass.helpers.device_registry.async_get_registry()
|
||||
|
||||
device = device_registry.async_get(cover.device_id)
|
||||
assert device.manufacturer == "VELUX"
|
||||
assert device.name == "VELUX Window"
|
||||
assert device.model == "VELUX Window"
|
||||
assert device.sw_version == "48"
|
||||
|
||||
bridge = device_registry.async_get(device.via_device_id)
|
||||
assert bridge.manufacturer == "VELUX"
|
||||
assert bridge.name == "VELUX Gateway"
|
||||
assert bridge.model == "VELUX Gateway"
|
||||
assert bridge.sw_version == "70"
|
||||
@@ -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")]
|
||||
)
|
||||
|
||||
@@ -21,7 +21,42 @@ from tests.common import (
|
||||
from tests.components.blueprint.conftest import stub_blueprint_populate # noqa
|
||||
|
||||
|
||||
async def test_get_triggers(hass, device_reg, entity_reg, mqtt_mock, setup_tasmota):
|
||||
async def test_get_triggers_btn(hass, device_reg, entity_reg, mqtt_mock, setup_tasmota):
|
||||
"""Test we get the expected triggers from a discovered mqtt device."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG)
|
||||
config["btn"][0] = 1
|
||||
config["btn"][1] = 1
|
||||
config["so"]["13"] = 1
|
||||
config["so"]["73"] = 1
|
||||
mac = config["mac"]
|
||||
|
||||
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config))
|
||||
await hass.async_block_till_done()
|
||||
|
||||
device_entry = device_reg.async_get_device(set(), {("mac", mac)})
|
||||
expected_triggers = [
|
||||
{
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": device_entry.id,
|
||||
"discovery_id": "00000049A3BC_button_1_SINGLE",
|
||||
"type": "button_short_press",
|
||||
"subtype": "button_1",
|
||||
},
|
||||
{
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": device_entry.id,
|
||||
"discovery_id": "00000049A3BC_button_2_SINGLE",
|
||||
"type": "button_short_press",
|
||||
"subtype": "button_2",
|
||||
},
|
||||
]
|
||||
triggers = await async_get_device_automations(hass, "trigger", device_entry.id)
|
||||
assert_lists_same(triggers, expected_triggers)
|
||||
|
||||
|
||||
async def test_get_triggers_swc(hass, device_reg, entity_reg, mqtt_mock, setup_tasmota):
|
||||
"""Test we get the expected triggers from a discovered mqtt device."""
|
||||
config = copy.deepcopy(DEFAULT_CONFIG)
|
||||
config["swc"][0] = 0
|
||||
@@ -239,13 +274,83 @@ async def test_update_remove_triggers(
|
||||
assert triggers == []
|
||||
|
||||
|
||||
async def test_if_fires_on_mqtt_message(
|
||||
async def test_if_fires_on_mqtt_message_btn(
|
||||
hass, device_reg, calls, mqtt_mock, setup_tasmota
|
||||
):
|
||||
"""Test triggers firing."""
|
||||
"""Test button triggers firing."""
|
||||
# Discover a device with 2 device triggers
|
||||
config = copy.deepcopy(DEFAULT_CONFIG)
|
||||
config["btn"][0] = 1
|
||||
config["btn"][2] = 1
|
||||
config["so"]["73"] = 1
|
||||
mac = config["mac"]
|
||||
|
||||
async_fire_mqtt_message(hass, f"{DEFAULT_PREFIX}/{mac}/config", json.dumps(config))
|
||||
await hass.async_block_till_done()
|
||||
device_entry = device_reg.async_get_device(set(), {("mac", mac)})
|
||||
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
automation.DOMAIN,
|
||||
{
|
||||
automation.DOMAIN: [
|
||||
{
|
||||
"trigger": {
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": device_entry.id,
|
||||
"discovery_id": "00000049A3BC_button_1_SINGLE",
|
||||
"type": "button_short_press",
|
||||
"subtype": "button_1",
|
||||
},
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {"some": ("short_press_1")},
|
||||
},
|
||||
},
|
||||
{
|
||||
"trigger": {
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": device_entry.id,
|
||||
"discovery_id": "00000049A3BC_button_3_SINGLE",
|
||||
"subtype": "button_3",
|
||||
"type": "button_short_press",
|
||||
},
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {"some": ("short_press_3")},
|
||||
},
|
||||
},
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
# Fake button 1 single press.
|
||||
async_fire_mqtt_message(
|
||||
hass, "tasmota_49A3BC/stat/RESULT", '{"Button1":{"Action":"SINGLE"}}'
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == "short_press_1"
|
||||
|
||||
# Fake button 3 single press.
|
||||
async_fire_mqtt_message(
|
||||
hass, "tasmota_49A3BC/stat/RESULT", '{"Button3":{"Action":"SINGLE"}}'
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 2
|
||||
assert calls[1].data["some"] == "short_press_3"
|
||||
|
||||
|
||||
async def test_if_fires_on_mqtt_message_swc(
|
||||
hass, device_reg, calls, mqtt_mock, setup_tasmota
|
||||
):
|
||||
"""Test switch triggers firing."""
|
||||
# Discover a device with 2 device triggers
|
||||
config = copy.deepcopy(DEFAULT_CONFIG)
|
||||
config["swc"][0] = 0
|
||||
config["swc"][1] = 0
|
||||
config["swc"][2] = 9
|
||||
config["swn"][2] = "custom_switch"
|
||||
mac = config["mac"]
|
||||
@@ -270,7 +375,21 @@ async def test_if_fires_on_mqtt_message(
|
||||
},
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {"some": ("short_press")},
|
||||
"data_template": {"some": ("short_press_1")},
|
||||
},
|
||||
},
|
||||
{
|
||||
"trigger": {
|
||||
"platform": "device",
|
||||
"domain": DOMAIN,
|
||||
"device_id": device_entry.id,
|
||||
"discovery_id": "00000049A3BC_switch_2_TOGGLE",
|
||||
"type": "button_short_press",
|
||||
"subtype": "switch_2",
|
||||
},
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {"some": ("short_press_2")},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -284,28 +403,36 @@ async def test_if_fires_on_mqtt_message(
|
||||
},
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {"some": ("long_press")},
|
||||
"data_template": {"some": ("long_press_3")},
|
||||
},
|
||||
},
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
# Fake short press.
|
||||
# Fake switch 1 short press.
|
||||
async_fire_mqtt_message(
|
||||
hass, "tasmota_49A3BC/stat/RESULT", '{"Switch1":{"Action":"TOGGLE"}}'
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
assert calls[0].data["some"] == "short_press"
|
||||
assert calls[0].data["some"] == "short_press_1"
|
||||
|
||||
# Fake long press.
|
||||
# Fake switch 2 short press.
|
||||
async_fire_mqtt_message(
|
||||
hass, "tasmota_49A3BC/stat/RESULT", '{"Switch2":{"Action":"TOGGLE"}}'
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 2
|
||||
assert calls[1].data["some"] == "short_press_2"
|
||||
|
||||
# Fake switch 3 long press.
|
||||
async_fire_mqtt_message(
|
||||
hass, "tasmota_49A3BC/stat/RESULT", '{"custom_switch":{"Action":"HOLD"}}'
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 2
|
||||
assert calls[1].data["some"] == "long_press"
|
||||
assert len(calls) == 3
|
||||
assert calls[2].data["some"] == "long_press_3"
|
||||
|
||||
|
||||
async def test_if_fires_on_mqtt_message_late_discover(
|
||||
|
||||
@@ -11,6 +11,7 @@ from homeassistant.core import Context, callback
|
||||
from homeassistant.setup import async_setup_component
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from tests.async_mock import patch
|
||||
from tests.common import (
|
||||
assert_setup_component,
|
||||
async_fire_time_changed,
|
||||
@@ -626,6 +627,7 @@ async def test_if_fires_on_change_with_for_0_advanced(hass, calls):
|
||||
|
||||
async def test_if_fires_on_change_with_for_2(hass, calls):
|
||||
"""Test for firing on change with for."""
|
||||
context = Context()
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
automation.DOMAIN,
|
||||
@@ -636,17 +638,33 @@ async def test_if_fires_on_change_with_for_2(hass, calls):
|
||||
"value_template": "{{ is_state('test.entity', 'world') }}",
|
||||
"for": 5,
|
||||
},
|
||||
"action": {"service": "test.automation"},
|
||||
"action": {
|
||||
"service": "test.automation",
|
||||
"data_template": {
|
||||
"some": "{{ trigger.%s }}"
|
||||
% "}} - {{ trigger.".join(
|
||||
(
|
||||
"platform",
|
||||
"entity_id",
|
||||
"from_state.state",
|
||||
"to_state.state",
|
||||
"for",
|
||||
)
|
||||
)
|
||||
},
|
||||
},
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
hass.states.async_set("test.entity", "world")
|
||||
hass.states.async_set("test.entity", "world", context=context)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 0
|
||||
async_fire_time_changed(hass, dt_util.utcnow() + timedelta(seconds=10))
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
assert calls[0].context.parent_id == context.id
|
||||
assert calls[0].data["some"] == "template - test.entity - hello - world - 0:00:05"
|
||||
|
||||
|
||||
async def test_if_not_fires_on_change_with_for(hass, calls):
|
||||
@@ -811,3 +829,58 @@ async def test_invalid_for_template_1(hass, calls):
|
||||
hass.states.async_set("test.entity", "world")
|
||||
await hass.async_block_till_done()
|
||||
assert mock_logger.error.called
|
||||
|
||||
|
||||
async def test_if_fires_on_time_change(hass, calls):
|
||||
"""Test for firing on time changes."""
|
||||
start_time = dt_util.utcnow() + timedelta(hours=24)
|
||||
time_that_will_not_match_right_away = start_time.replace(minute=1, second=0)
|
||||
with patch(
|
||||
"homeassistant.util.dt.utcnow", return_value=time_that_will_not_match_right_away
|
||||
):
|
||||
assert await async_setup_component(
|
||||
hass,
|
||||
automation.DOMAIN,
|
||||
{
|
||||
automation.DOMAIN: {
|
||||
"trigger": {
|
||||
"platform": "template",
|
||||
"value_template": "{{ utcnow().minute % 2 == 0 }}",
|
||||
},
|
||||
"action": {"service": "test.automation"},
|
||||
}
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 0
|
||||
|
||||
# Trigger once (match template)
|
||||
first_time = start_time.replace(minute=2, second=0)
|
||||
with patch("homeassistant.util.dt.utcnow", return_value=first_time):
|
||||
async_fire_time_changed(hass, first_time)
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
|
||||
# Trigger again (match template)
|
||||
second_time = start_time.replace(minute=4, second=0)
|
||||
with patch("homeassistant.util.dt.utcnow", return_value=second_time):
|
||||
async_fire_time_changed(hass, second_time)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
|
||||
# Trigger again (do not match template)
|
||||
third_time = start_time.replace(minute=5, second=0)
|
||||
with patch("homeassistant.util.dt.utcnow", return_value=third_time):
|
||||
async_fire_time_changed(hass, third_time)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 1
|
||||
|
||||
# Trigger again (match template)
|
||||
forth_time = start_time.replace(minute=8, second=0)
|
||||
with patch("homeassistant.util.dt.utcnow", return_value=forth_time):
|
||||
async_fire_time_changed(hass, forth_time)
|
||||
await hass.async_block_till_done()
|
||||
await hass.async_block_till_done()
|
||||
assert len(calls) == 2
|
||||
|
||||
@@ -295,6 +295,22 @@ async def test_get_controller_login_failed(hass):
|
||||
await get_controller(hass, **CONTROLLER_DATA)
|
||||
|
||||
|
||||
async def test_get_controller_controller_bad_gateway(hass):
|
||||
"""Check that get_controller can handle controller being unavailable."""
|
||||
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
|
||||
"aiounifi.Controller.login", side_effect=aiounifi.BadGateway
|
||||
), pytest.raises(CannotConnect):
|
||||
await get_controller(hass, **CONTROLLER_DATA)
|
||||
|
||||
|
||||
async def test_get_controller_controller_service_unavailable(hass):
|
||||
"""Check that get_controller can handle controller being unavailable."""
|
||||
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
|
||||
"aiounifi.Controller.login", side_effect=aiounifi.ServiceUnavailable
|
||||
), pytest.raises(CannotConnect):
|
||||
await get_controller(hass, **CONTROLLER_DATA)
|
||||
|
||||
|
||||
async def test_get_controller_controller_unavailable(hass):
|
||||
"""Check that get_controller can handle controller being unavailable."""
|
||||
with patch("aiounifi.Controller.check_unifi_os", return_value=True), patch(
|
||||
|
||||
749
tests/fixtures/blueprint/community_post.json
vendored
749
tests/fixtures/blueprint/community_post.json
vendored
File diff suppressed because one or more lines are too long
380
tests/fixtures/homekit_controller/velux_gateway.json
vendored
Normal file
380
tests/fixtures/homekit_controller/velux_gateway.json
vendored
Normal file
@@ -0,0 +1,380 @@
|
||||
[
|
||||
{
|
||||
"aid": 1,
|
||||
"services": [
|
||||
{
|
||||
"type": "0000003E-0000-1000-8000-0026BB765291",
|
||||
"iid": 1,
|
||||
"characteristics": [
|
||||
{
|
||||
"type": "00000023-0000-1000-8000-0026BB765291",
|
||||
"iid": 2,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "VELUX Gateway"
|
||||
},
|
||||
{
|
||||
"type": "00000020-0000-1000-8000-0026BB765291",
|
||||
"iid": 3,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "VELUX"
|
||||
},
|
||||
{
|
||||
"type": "00000021-0000-1000-8000-0026BB765291",
|
||||
"iid": 4,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "VELUX Gateway"
|
||||
},
|
||||
{
|
||||
"type": "00000030-0000-1000-8000-0026BB765291",
|
||||
"iid": 5,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "a1a11a1"
|
||||
},
|
||||
{
|
||||
"type": "00000014-0000-1000-8000-0026BB765291",
|
||||
"iid": 6,
|
||||
"perms": [
|
||||
"pw"
|
||||
],
|
||||
"format": "bool"
|
||||
},
|
||||
{
|
||||
"type": "00000052-0000-1000-8000-0026BB765291",
|
||||
"iid": 7,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "70"
|
||||
}
|
||||
],
|
||||
"hidden": false,
|
||||
"primary": false
|
||||
},
|
||||
{
|
||||
"type": "000000A2-0000-1000-8000-0026BB765291",
|
||||
"iid": 8,
|
||||
"characteristics": [
|
||||
{
|
||||
"type": "00000037-0000-1000-8000-0026BB765291",
|
||||
"iid": 9,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "1.1.0"
|
||||
}
|
||||
],
|
||||
"hidden": false,
|
||||
"primary": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"aid": 2,
|
||||
"services": [
|
||||
{
|
||||
"type": "0000003E-0000-1000-8000-0026BB765291",
|
||||
"iid": 1,
|
||||
"characteristics": [
|
||||
{
|
||||
"type": "00000023-0000-1000-8000-0026BB765291",
|
||||
"iid": 2,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "VELUX Sensor"
|
||||
},
|
||||
{
|
||||
"type": "00000020-0000-1000-8000-0026BB765291",
|
||||
"iid": 3,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "VELUX"
|
||||
},
|
||||
{
|
||||
"type": "00000021-0000-1000-8000-0026BB765291",
|
||||
"iid": 4,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "VELUX Sensor"
|
||||
},
|
||||
{
|
||||
"type": "00000030-0000-1000-8000-0026BB765291",
|
||||
"iid": 5,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "a11b111"
|
||||
},
|
||||
{
|
||||
"type": "00000014-0000-1000-8000-0026BB765291",
|
||||
"iid": 7,
|
||||
"perms": [
|
||||
"pw"
|
||||
],
|
||||
"format": "bool"
|
||||
},
|
||||
{
|
||||
"type": "00000052-0000-1000-8000-0026BB765291",
|
||||
"iid": 6,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "16"
|
||||
}
|
||||
],
|
||||
"hidden": false,
|
||||
"primary": false
|
||||
},
|
||||
{
|
||||
"type": "0000008A-0000-1000-8000-0026BB765291",
|
||||
"iid": 8,
|
||||
"characteristics": [
|
||||
{
|
||||
"type": "00000023-0000-1000-8000-0026BB765291",
|
||||
"iid": 9,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "Temperature sensor"
|
||||
},
|
||||
{
|
||||
"type": "00000011-0000-1000-8000-0026BB765291",
|
||||
"iid": 10,
|
||||
"perms": [
|
||||
"pr",
|
||||
"ev"
|
||||
],
|
||||
"format": "float",
|
||||
"value": 18.9,
|
||||
"minValue": 0,
|
||||
"maxValue": 50,
|
||||
"minStep": 0.1,
|
||||
"unit": "celsius"
|
||||
}
|
||||
],
|
||||
"hidden": false,
|
||||
"primary": true
|
||||
},
|
||||
{
|
||||
"type": "00000082-0000-1000-8000-0026BB765291",
|
||||
"iid": 11,
|
||||
"characteristics": [
|
||||
{
|
||||
"type": "00000023-0000-1000-8000-0026BB765291",
|
||||
"iid": 12,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "Humidity sensor"
|
||||
},
|
||||
{
|
||||
"type": "00000010-0000-1000-8000-0026BB765291",
|
||||
"iid": 13,
|
||||
"perms": [
|
||||
"pr",
|
||||
"ev"
|
||||
],
|
||||
"format": "float",
|
||||
"value": 58,
|
||||
"minValue": 0,
|
||||
"maxValue": 100,
|
||||
"minStep": 1,
|
||||
"unit": "percentage"
|
||||
}
|
||||
],
|
||||
"hidden": false,
|
||||
"primary": false
|
||||
},
|
||||
{
|
||||
"type": "00000097-0000-1000-8000-0026BB765291",
|
||||
"iid": 14,
|
||||
"characteristics": [
|
||||
{
|
||||
"type": "00000023-0000-1000-8000-0026BB765291",
|
||||
"iid": 15,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "Carbon Dioxide sensor"
|
||||
},
|
||||
{
|
||||
"type": "00000092-0000-1000-8000-0026BB765291",
|
||||
"iid": 16,
|
||||
"perms": [
|
||||
"pr",
|
||||
"ev"
|
||||
],
|
||||
"format": "uint8",
|
||||
"value": 0,
|
||||
"maxValue": 1,
|
||||
"minValue": 0,
|
||||
"minStep": 1
|
||||
},
|
||||
{
|
||||
"type": "00000093-0000-1000-8000-0026BB765291",
|
||||
"iid": 17,
|
||||
"perms": [
|
||||
"pr",
|
||||
"ev"
|
||||
],
|
||||
"format": "float",
|
||||
"value": 400,
|
||||
"minValue": 0,
|
||||
"maxValue": 5000
|
||||
}
|
||||
],
|
||||
"hidden": false,
|
||||
"primary": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"aid": 3,
|
||||
"services": [
|
||||
{
|
||||
"type": "0000003E-0000-1000-8000-0026BB765291",
|
||||
"iid": 1,
|
||||
"characteristics": [
|
||||
{
|
||||
"type": "00000023-0000-1000-8000-0026BB765291",
|
||||
"iid": 2,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "VELUX Window"
|
||||
},
|
||||
{
|
||||
"type": "00000020-0000-1000-8000-0026BB765291",
|
||||
"iid": 3,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "VELUX"
|
||||
},
|
||||
{
|
||||
"type": "00000021-0000-1000-8000-0026BB765291",
|
||||
"iid": 4,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "VELUX Window"
|
||||
},
|
||||
{
|
||||
"type": "00000030-0000-1000-8000-0026BB765291",
|
||||
"iid": 5,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "1111111a114a111a"
|
||||
},
|
||||
{
|
||||
"type": "00000014-0000-1000-8000-0026BB765291",
|
||||
"iid": 7,
|
||||
"perms": [
|
||||
"pw"
|
||||
],
|
||||
"format": "bool"
|
||||
},
|
||||
{
|
||||
"type": "00000052-0000-1000-8000-0026BB765291",
|
||||
"iid": 6,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "48"
|
||||
}
|
||||
],
|
||||
"hidden": false,
|
||||
"primary": false
|
||||
},
|
||||
{
|
||||
"type": "0000008B-0000-1000-8000-0026BB765291",
|
||||
"iid": 8,
|
||||
"characteristics": [
|
||||
{
|
||||
"type": "00000023-0000-1000-8000-0026BB765291",
|
||||
"iid": 9,
|
||||
"perms": [
|
||||
"pr"
|
||||
],
|
||||
"format": "string",
|
||||
"value": "Roof Window"
|
||||
},
|
||||
{
|
||||
"type": "0000007C-0000-1000-8000-0026BB765291",
|
||||
"iid": 11,
|
||||
"perms": [
|
||||
"pr",
|
||||
"pw",
|
||||
"ev"
|
||||
],
|
||||
"format": "uint8",
|
||||
"value": 0,
|
||||
"maxValue": 100,
|
||||
"minValue": 0,
|
||||
"unit": "percentage",
|
||||
"minStep": 1
|
||||
},
|
||||
{
|
||||
"type": "0000006D-0000-1000-8000-0026BB765291",
|
||||
"iid": 10,
|
||||
"perms": [
|
||||
"pr",
|
||||
"ev"
|
||||
],
|
||||
"format": "uint8",
|
||||
"value": 0,
|
||||
"maxValue": 100,
|
||||
"minValue": 0,
|
||||
"unit": "percentage",
|
||||
"minStep": 1
|
||||
},
|
||||
{
|
||||
"type": "00000072-0000-1000-8000-0026BB765291",
|
||||
"iid": 12,
|
||||
"perms": [
|
||||
"pr",
|
||||
"ev"
|
||||
],
|
||||
"format": "uint8",
|
||||
"value": 2,
|
||||
"maxValue": 2,
|
||||
"minValue": 0,
|
||||
"minStep": 1
|
||||
}
|
||||
],
|
||||
"hidden": false,
|
||||
"primary": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -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