From bd6fd10100b9df704f0ad28a2e2b087c774a1a50 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 25 Jun 2024 12:01:49 +0200 Subject: [PATCH] Use VolDictType for service schemas --- homeassistant/components/camera/__init__.py | 8 ++++---- .../components/elkm1/alarm_control_panel.py | 3 ++- homeassistant/components/elkm1/const.py | 3 ++- homeassistant/components/elkm1/sensor.py | 3 ++- .../components/environment_canada/camera.py | 3 ++- homeassistant/components/flux_led/light.py | 7 ++++--- homeassistant/components/geniushub/switch.py | 4 ++-- homeassistant/components/harmony/remote.py | 3 ++- homeassistant/components/isy994/services.py | 7 +++++-- homeassistant/components/izone/climate.py | 4 ++-- homeassistant/components/keymitt_ble/switch.py | 3 ++- homeassistant/components/kodi/media_player.py | 4 ++-- homeassistant/components/lifx/light.py | 5 +++-- homeassistant/components/light/__init__.py | 9 ++++++--- homeassistant/components/lyric/climate.py | 3 ++- homeassistant/components/motion_blinds/cover.py | 3 ++- homeassistant/components/nexia/climate.py | 5 +++-- homeassistant/components/rainbird/switch.py | 3 ++- homeassistant/components/rainmachine/switch.py | 6 ++++-- homeassistant/components/renson/fan.py | 7 ++++--- homeassistant/components/roku/media_player.py | 3 ++- homeassistant/components/siren/__init__.py | 4 ++-- homeassistant/components/smarttub/binary_sensor.py | 5 +++-- homeassistant/components/smarttub/sensor.py | 3 ++- homeassistant/components/switcher_kis/switch.py | 5 +++-- homeassistant/components/tado/climate.py | 5 +++-- homeassistant/components/tado/water_heater.py | 3 ++- homeassistant/components/upb/const.py | 3 ++- homeassistant/components/vizio/const.py | 3 ++- homeassistant/components/wemo/fan.py | 3 ++- homeassistant/components/yardian/switch.py | 3 ++- homeassistant/components/yeelight/__init__.py | 4 ++-- homeassistant/components/yeelight/light.py | 13 +++++++------ 33 files changed, 91 insertions(+), 59 deletions(-) diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 4d2ba00900fd21..428e8d856fbc26 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -64,7 +64,7 @@ from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.network import get_url from homeassistant.helpers.template import Template -from homeassistant.helpers.typing import ConfigType +from homeassistant.helpers.typing import ConfigType, VolDictType from homeassistant.loader import bind_hass from .const import ( # noqa: F401 @@ -130,14 +130,14 @@ class CameraEntityFeature(IntFlag): MIN_STREAM_INTERVAL: Final = 0.5 # seconds -CAMERA_SERVICE_SNAPSHOT: Final = {vol.Required(ATTR_FILENAME): cv.template} +CAMERA_SERVICE_SNAPSHOT: VolDictType = {vol.Required(ATTR_FILENAME): cv.template} -CAMERA_SERVICE_PLAY_STREAM: Final = { +CAMERA_SERVICE_PLAY_STREAM: VolDictType = { vol.Required(ATTR_MEDIA_PLAYER): cv.entities_domain(DOMAIN_MP), vol.Optional(ATTR_FORMAT, default="hls"): vol.In(OUTPUT_FORMATS), } -CAMERA_SERVICE_RECORD: Final = { +CAMERA_SERVICE_RECORD: VolDictType = { vol.Required(CONF_FILENAME): cv.template, vol.Optional(CONF_DURATION, default=30): vol.Coerce(int), vol.Optional(CONF_LOOKBACK, default=0): vol.Coerce(int), diff --git a/homeassistant/components/elkm1/alarm_control_panel.py b/homeassistant/components/elkm1/alarm_control_panel.py index eb8d7360ce2a5b..b24d0f869c6a59 100644 --- a/homeassistant/components/elkm1/alarm_control_panel.py +++ b/homeassistant/components/elkm1/alarm_control_panel.py @@ -31,6 +31,7 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.restore_state import RestoreEntity +from homeassistant.helpers.typing import VolDictType from . import ElkAttachedEntity, ElkEntity, ElkM1ConfigEntry, create_elk_entities from .const import ( @@ -41,7 +42,7 @@ ) from .models import ELKM1Data -DISPLAY_MESSAGE_SERVICE_SCHEMA = { +DISPLAY_MESSAGE_SERVICE_SCHEMA: VolDictType = { vol.Optional("clear", default=2): vol.All(vol.Coerce(int), vol.In([0, 1, 2])), vol.Optional("beep", default=False): cv.boolean, vol.Optional("timeout", default=0): vol.All( diff --git a/homeassistant/components/elkm1/const.py b/homeassistant/components/elkm1/const.py index 9e952c7ee0b299..61d1994b79767c 100644 --- a/homeassistant/components/elkm1/const.py +++ b/homeassistant/components/elkm1/const.py @@ -6,6 +6,7 @@ import voluptuous as vol from homeassistant.const import ATTR_CODE, CONF_ZONE +from homeassistant.helpers.typing import VolDictType DOMAIN = "elkm1" @@ -48,6 +49,6 @@ ATTR_CHANGED_BY_TIME = "changed_by_time" ATTR_VALUE = "value" -ELK_USER_CODE_SERVICE_SCHEMA = { +ELK_USER_CODE_SERVICE_SCHEMA: VolDictType = { vol.Required(ATTR_CODE): vol.All(vol.Coerce(int), vol.Range(0, 999999)) } diff --git a/homeassistant/components/elkm1/sensor.py b/homeassistant/components/elkm1/sensor.py index 801a09b76ebc18..7d3601f0bd068f 100644 --- a/homeassistant/components/elkm1/sensor.py +++ b/homeassistant/components/elkm1/sensor.py @@ -20,6 +20,7 @@ from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import entity_platform from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from . import ElkAttachedEntity, ElkEntity, ElkM1ConfigEntry, create_elk_entities from .const import ATTR_VALUE, ELK_USER_CODE_SERVICE_SCHEMA @@ -30,7 +31,7 @@ SERVICE_SENSOR_ZONE_TRIGGER = "sensor_zone_trigger" UNDEFINED_TEMPERATURE = -40 -ELK_SET_COUNTER_SERVICE_SCHEMA = { +ELK_SET_COUNTER_SERVICE_SCHEMA: VolDictType = { vol.Required(ATTR_VALUE): vol.All(vol.Coerce(int), vol.Range(0, 65535)) } diff --git a/homeassistant/components/environment_canada/camera.py b/homeassistant/components/environment_canada/camera.py index 73032f59ac2223..1625cd253dacf1 100644 --- a/homeassistant/components/environment_canada/camera.py +++ b/homeassistant/components/environment_canada/camera.py @@ -11,13 +11,14 @@ AddEntitiesCallback, async_get_current_platform, ) +from homeassistant.helpers.typing import VolDictType from homeassistant.helpers.update_coordinator import CoordinatorEntity from . import device_info from .const import ATTR_OBSERVATION_TIME, DOMAIN SERVICE_SET_RADAR_TYPE = "set_radar_type" -SET_RADAR_TYPE_SCHEMA = { +SET_RADAR_TYPE_SCHEMA: VolDictType = { vol.Required("radar_type"): vol.In(["Auto", "Rain", "Snow"]), } diff --git a/homeassistant/components/flux_led/light.py b/homeassistant/components/flux_led/light.py index 6456eb36dbbd06..f4982a13c3a89c 100644 --- a/homeassistant/components/flux_led/light.py +++ b/homeassistant/components/flux_led/light.py @@ -28,6 +28,7 @@ from homeassistant.helpers import entity_platform import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.util.color import ( color_temperature_kelvin_to_mired, @@ -88,7 +89,7 @@ SERVICE_SET_ZONES: Final = "set_zones" SERVICE_SET_MUSIC_MODE: Final = "set_music_mode" -CUSTOM_EFFECT_DICT: Final = { +CUSTOM_EFFECT_DICT: VolDictType = { vol.Required(CONF_COLORS): vol.All( cv.ensure_list, vol.Length(min=1, max=16), @@ -102,7 +103,7 @@ ), } -SET_MUSIC_MODE_DICT: Final = { +SET_MUSIC_MODE_DICT: VolDictType = { vol.Optional(ATTR_SENSITIVITY, default=100): vol.All( vol.Coerce(int), vol.Range(min=0, max=100) ), @@ -121,7 +122,7 @@ ), } -SET_ZONES_DICT: Final = { +SET_ZONES_DICT: VolDictType = { vol.Required(CONF_COLORS): vol.All( cv.ensure_list, vol.Length(min=1, max=2048), diff --git a/homeassistant/components/geniushub/switch.py b/homeassistant/components/geniushub/switch.py index b703df57f908ab..85f7f1bb03aeb8 100644 --- a/homeassistant/components/geniushub/switch.py +++ b/homeassistant/components/geniushub/switch.py @@ -11,7 +11,7 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.entity_platform import AddEntitiesCallback -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, VolDictType from . import ATTR_DURATION, DOMAIN, GeniusZone @@ -19,7 +19,7 @@ SVC_SET_SWITCH_OVERRIDE = "set_switch_override" -SET_SWITCH_OVERRIDE_SCHEMA = { +SET_SWITCH_OVERRIDE_SCHEMA: VolDictType = { vol.Optional(ATTR_DURATION): vol.All( cv.time_period, vol.Range(min=timedelta(minutes=5), max=timedelta(days=1)), diff --git a/homeassistant/components/harmony/remote.py b/homeassistant/components/harmony/remote.py index 0c9bdcb9c6e2f0..a52f298dc41fb1 100644 --- a/homeassistant/components/harmony/remote.py +++ b/homeassistant/components/harmony/remote.py @@ -26,6 +26,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.restore_state import RestoreEntity +from homeassistant.helpers.typing import VolDictType from .const import ( ACTIVITY_POWER_OFF, @@ -50,7 +51,7 @@ ATTR_CHANNEL = "channel" -HARMONY_CHANGE_CHANNEL_SCHEMA = { +HARMONY_CHANGE_CHANNEL_SCHEMA: VolDictType = { vol.Required(ATTR_CHANNEL): cv.positive_int, } diff --git a/homeassistant/components/isy994/services.py b/homeassistant/components/isy994/services.py index fedf7f8e902f1b..ffcea5cc8f8519 100644 --- a/homeassistant/components/isy994/services.py +++ b/homeassistant/components/isy994/services.py @@ -18,6 +18,7 @@ from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity_platform import async_get_platforms from homeassistant.helpers.service import entity_service_call +from homeassistant.helpers.typing import VolDictType from .const import _LOGGER, DOMAIN @@ -102,12 +103,14 @@ def valid_isy_commands(value: Any) -> str: vol.Required(CONF_SIZE): vol.All(vol.Coerce(int), vol.In(VALID_PARAMETER_SIZES)), } -SERVICE_SET_USER_CODE_SCHEMA = { +SERVICE_SET_USER_CODE_SCHEMA: VolDictType = { vol.Required(CONF_USER_NUM): vol.Coerce(int), vol.Required(CONF_CODE): vol.Coerce(int), } -SERVICE_DELETE_USER_CODE_SCHEMA = {vol.Required(CONF_USER_NUM): vol.Coerce(int)} +SERVICE_DELETE_USER_CODE_SCHEMA: VolDictType = { + vol.Required(CONF_USER_NUM): vol.Coerce(int) +} SERVICE_SEND_PROGRAM_COMMAND_SCHEMA = vol.All( cv.has_at_least_one_key(CONF_ADDRESS, CONF_NAME), diff --git a/homeassistant/components/izone/climate.py b/homeassistant/components/izone/climate.py index 14267a626fc5a1..3a1279a9bd43e4 100644 --- a/homeassistant/components/izone/climate.py +++ b/homeassistant/components/izone/climate.py @@ -35,7 +35,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.temperature import display_temp as show_temp -from homeassistant.helpers.typing import ConfigType +from homeassistant.helpers.typing import ConfigType, VolDictType from .const import ( DATA_CONFIG, @@ -65,7 +65,7 @@ IZONE_SERVICE_AIRFLOW_MIN = "airflow_min" IZONE_SERVICE_AIRFLOW_MAX = "airflow_max" -IZONE_SERVICE_AIRFLOW_SCHEMA = { +IZONE_SERVICE_AIRFLOW_SCHEMA: VolDictType = { vol.Required(ATTR_AIRFLOW): vol.All( vol.Coerce(int), vol.Range(min=0, max=100), msg="invalid airflow" ), diff --git a/homeassistant/components/keymitt_ble/switch.py b/homeassistant/components/keymitt_ble/switch.py index 2c255ecdf2804c..ca458c5020f3fb 100644 --- a/homeassistant/components/keymitt_ble/switch.py +++ b/homeassistant/components/keymitt_ble/switch.py @@ -14,13 +14,14 @@ AddEntitiesCallback, async_get_current_platform, ) +from homeassistant.helpers.typing import VolDictType from .const import DOMAIN from .coordinator import MicroBotDataUpdateCoordinator from .entity import MicroBotEntity CALIBRATE = "calibrate" -CALIBRATE_SCHEMA = { +CALIBRATE_SCHEMA: VolDictType = { vol.Required("depth"): cv.positive_int, vol.Required("duration"): cv.positive_int, vol.Required("mode"): vol.In(["normal", "invert", "toggle"]), diff --git a/homeassistant/components/kodi/media_player.py b/homeassistant/components/kodi/media_player.py index 2bfe21b6eaab07..3ba5804f8b3ca5 100644 --- a/homeassistant/components/kodi/media_player.py +++ b/homeassistant/components/kodi/media_player.py @@ -49,7 +49,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.network import is_internal_request -from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, VolDictType import homeassistant.util.dt as dt_util from .browse_media import ( @@ -147,7 +147,7 @@ ATTR_METHOD = "method" -KODI_ADD_MEDIA_SCHEMA = { +KODI_ADD_MEDIA_SCHEMA: VolDictType = { vol.Required(ATTR_MEDIA_TYPE): cv.string, vol.Optional(ATTR_MEDIA_ID): cv.string, vol.Optional(ATTR_MEDIA_NAME): cv.string, diff --git a/homeassistant/components/lifx/light.py b/homeassistant/components/lifx/light.py index 90632f82d9e1d7..caa1140b0999b2 100644 --- a/homeassistant/components/lifx/light.py +++ b/homeassistant/components/lifx/light.py @@ -25,6 +25,7 @@ import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.event import async_call_later +from homeassistant.helpers.typing import VolDictType from .const import ( _LOGGER, @@ -53,7 +54,7 @@ SERVICE_LIFX_SET_STATE = "set_state" -LIFX_SET_STATE_SCHEMA = { +LIFX_SET_STATE_SCHEMA: VolDictType = { **LIGHT_TURN_ON_SCHEMA, ATTR_INFRARED: vol.All(vol.Coerce(int), vol.Clamp(min=0, max=255)), ATTR_ZONES: vol.All(cv.ensure_list, [cv.positive_int]), @@ -63,7 +64,7 @@ SERVICE_LIFX_SET_HEV_CYCLE_STATE = "set_hev_cycle_state" -LIFX_SET_HEV_CYCLE_STATE_SCHEMA = { +LIFX_SET_HEV_CYCLE_STATE_SCHEMA: VolDictType = { ATTR_POWER: vol.Required(cv.boolean), ATTR_DURATION: vol.All(vol.Coerce(float), vol.Clamp(min=0, max=86400)), } diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index 6d3065c48c9c15..16367c35ec5422 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -31,7 +31,7 @@ ) from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription from homeassistant.helpers.entity_component import EntityComponent -from homeassistant.helpers.typing import ConfigType +from homeassistant.helpers.typing import ConfigType, VolDictType from homeassistant.loader import bind_hass import homeassistant.util.color as color_util @@ -247,7 +247,7 @@ def get_supported_color_modes(hass: HomeAssistant, entity_id: str) -> set[str] | VALID_BRIGHTNESS_STEP_PCT = vol.All(vol.Coerce(float), vol.Clamp(min=-100, max=100)) VALID_FLASH = vol.In([FLASH_SHORT, FLASH_LONG]) -LIGHT_TURN_ON_SCHEMA = { +LIGHT_TURN_ON_SCHEMA: VolDictType = { vol.Exclusive(ATTR_PROFILE, COLOR_GROUP): cv.string, ATTR_TRANSITION: VALID_TRANSITION, vol.Exclusive(ATTR_BRIGHTNESS, ATTR_BRIGHTNESS): VALID_BRIGHTNESS, @@ -286,7 +286,10 @@ def get_supported_color_modes(hass: HomeAssistant, entity_id: str) -> set[str] | ATTR_EFFECT: cv.string, } -LIGHT_TURN_OFF_SCHEMA = {ATTR_TRANSITION: VALID_TRANSITION, ATTR_FLASH: VALID_FLASH} +LIGHT_TURN_OFF_SCHEMA: VolDictType = { + ATTR_TRANSITION: VALID_TRANSITION, + ATTR_FLASH: VALID_FLASH, +} _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/lyric/climate.py b/homeassistant/components/lyric/climate.py index f8ae978c2fd044..50add155915590 100644 --- a/homeassistant/components/lyric/climate.py +++ b/homeassistant/components/lyric/climate.py @@ -37,6 +37,7 @@ from homeassistant.helpers import entity_platform import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from . import LyricDeviceEntity @@ -111,7 +112,7 @@ SERVICE_HOLD_TIME = "set_hold_time" ATTR_TIME_PERIOD = "time_period" -SCHEMA_HOLD_TIME = { +SCHEMA_HOLD_TIME: VolDictType = { vol.Required(ATTR_TIME_PERIOD, default="01:00:00"): vol.All( cv.time_period, cv.positive_timedelta, diff --git a/homeassistant/components/motion_blinds/cover.py b/homeassistant/components/motion_blinds/cover.py index eb40a1d66cab3d..2cbee96adb71c8 100644 --- a/homeassistant/components/motion_blinds/cover.py +++ b/homeassistant/components/motion_blinds/cover.py @@ -20,6 +20,7 @@ from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.event import async_call_later +from homeassistant.helpers.typing import VolDictType from .const import ( ATTR_ABSOLUTE_POSITION, @@ -75,7 +76,7 @@ } -SET_ABSOLUTE_POSITION_SCHEMA = { +SET_ABSOLUTE_POSITION_SCHEMA: VolDictType = { vol.Required(ATTR_ABSOLUTE_POSITION): vol.All(cv.positive_int, vol.Range(max=100)), vol.Optional(ATTR_TILT_POSITION): vol.All(cv.positive_int, vol.Range(max=100)), vol.Optional(ATTR_WIDTH): vol.All(cv.positive_int, vol.Range(max=100)), diff --git a/homeassistant/components/nexia/climate.py b/homeassistant/components/nexia/climate.py index 7d09f7108284b7..7c28062f4b89d4 100644 --- a/homeassistant/components/nexia/climate.py +++ b/homeassistant/components/nexia/climate.py @@ -37,6 +37,7 @@ from homeassistant.helpers import entity_platform import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from .const import ( ATTR_AIRCLEANER_MODE, @@ -55,11 +56,11 @@ SERVICE_SET_HUMIDIFY_SETPOINT = "set_humidify_setpoint" SERVICE_SET_HVAC_RUN_MODE = "set_hvac_run_mode" -SET_AIRCLEANER_SCHEMA = { +SET_AIRCLEANER_SCHEMA: VolDictType = { vol.Required(ATTR_AIRCLEANER_MODE): cv.string, } -SET_HUMIDITY_SCHEMA = { +SET_HUMIDITY_SCHEMA: VolDictType = { vol.Required(ATTR_HUMIDITY): vol.All(vol.Coerce(int), vol.Range(min=35, max=65)), } diff --git a/homeassistant/components/rainbird/switch.py b/homeassistant/components/rainbird/switch.py index 7f43553aa4114a..62a2a7c4a32746 100644 --- a/homeassistant/components/rainbird/switch.py +++ b/homeassistant/components/rainbird/switch.py @@ -14,6 +14,7 @@ from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import ATTR_DURATION, CONF_IMPORTED_NAMES, DOMAIN, MANUFACTURER @@ -23,7 +24,7 @@ SERVICE_START_IRRIGATION = "start_irrigation" -SERVICE_SCHEMA_IRRIGATION = { +SERVICE_SCHEMA_IRRIGATION: VolDictType = { vol.Required(ATTR_DURATION): cv.positive_float, } diff --git a/homeassistant/components/rainmachine/switch.py b/homeassistant/components/rainmachine/switch.py index 328d5193e1eb34..667e609e11cc0c 100644 --- a/homeassistant/components/rainmachine/switch.py +++ b/homeassistant/components/rainmachine/switch.py @@ -6,7 +6,7 @@ from collections.abc import Awaitable, Callable, Coroutine from dataclasses import dataclass from datetime import datetime -from typing import Any, Concatenate +from typing import Any, Concatenate, cast from regenmaschine.errors import RainMachineError import voluptuous as vol @@ -18,6 +18,7 @@ from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from . import RainMachineData, RainMachineEntity, async_update_programs_and_zones from .const import ( @@ -191,7 +192,8 @@ async def async_setup_entry( ("stop_program", {}, "async_stop_program"), ("stop_zone", {}, "async_stop_zone"), ): - platform.async_register_entity_service(service_name, schema, method) + schema_dict = cast(VolDictType, schema) + platform.async_register_entity_service(service_name, schema_dict, method) data: RainMachineData = hass.data[DOMAIN][entry.entry_id] entities: list[RainMachineBaseSwitch] = [] diff --git a/homeassistant/components/renson/fan.py b/homeassistant/components/renson/fan.py index 226d623af2bba1..bff84017e290df 100644 --- a/homeassistant/components/renson/fan.py +++ b/homeassistant/components/renson/fan.py @@ -21,6 +21,7 @@ from homeassistant.helpers import entity_platform import homeassistant.helpers.config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from homeassistant.util.percentage import ( percentage_to_ranged_value, ranged_value_to_percentage, @@ -51,20 +52,20 @@ Level.LEVEL4.value: 4, } -SET_TIMER_LEVEL_SCHEMA = { +SET_TIMER_LEVEL_SCHEMA: VolDictType = { vol.Required("timer_level"): vol.In( ["level1", "level2", "level3", "level4", "holiday", "breeze"] ), vol.Required("minutes"): cv.positive_int, } -SET_BREEZE_SCHEMA = { +SET_BREEZE_SCHEMA: VolDictType = { vol.Required("breeze_level"): vol.In(["level1", "level2", "level3", "level4"]), vol.Required("temperature"): cv.positive_int, vol.Required("activate"): bool, } -SET_POLLUTION_SETTINGS_SCHEMA = { +SET_POLLUTION_SETTINGS_SCHEMA: VolDictType = { vol.Required("day_pollution_level"): vol.In( ["level1", "level2", "level3", "level4"] ), diff --git a/homeassistant/components/roku/media_player.py b/homeassistant/components/roku/media_player.py index 92361909219256..881dda38f15288 100644 --- a/homeassistant/components/roku/media_player.py +++ b/homeassistant/components/roku/media_player.py @@ -28,6 +28,7 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_platform from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from .browse_media import async_browse_media from .const import ( @@ -78,7 +79,7 @@ ATTR_THUMBNAIL: "albumArtUrl", } -SEARCH_SCHEMA = {vol.Required(ATTR_KEYWORD): str} +SEARCH_SCHEMA: VolDictType = {vol.Required(ATTR_KEYWORD): str} async def async_setup_entry( diff --git a/homeassistant/components/siren/__init__.py b/homeassistant/components/siren/__init__.py index a0a599dd2df7b7..e5837fdd1bf05d 100644 --- a/homeassistant/components/siren/__init__.py +++ b/homeassistant/components/siren/__init__.py @@ -24,7 +24,7 @@ ) from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription from homeassistant.helpers.entity_component import EntityComponent -from homeassistant.helpers.typing import ConfigType +from homeassistant.helpers.typing import ConfigType, VolDictType from .const import ( # noqa: F401 _DEPRECATED_SUPPORT_DURATION, @@ -44,7 +44,7 @@ SCAN_INTERVAL = timedelta(seconds=60) -TURN_ON_SCHEMA = { +TURN_ON_SCHEMA: VolDictType = { vol.Optional(ATTR_TONE): vol.Any(vol.Coerce(int), cv.string), vol.Optional(ATTR_DURATION): cv.positive_int, vol.Optional(ATTR_VOLUME_LEVEL): cv.small_float, diff --git a/homeassistant/components/smarttub/binary_sensor.py b/homeassistant/components/smarttub/binary_sensor.py index cca0c6bc2ced73..f665f5e61b3b4e 100644 --- a/homeassistant/components/smarttub/binary_sensor.py +++ b/homeassistant/components/smarttub/binary_sensor.py @@ -13,6 +13,7 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import entity_platform from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from .const import ATTR_ERRORS, ATTR_REMINDERS, DOMAIN, SMARTTUB_CONTROLLER from .entity import SmartTubEntity, SmartTubSensorBase @@ -29,12 +30,12 @@ # how many days to snooze the reminder for ATTR_REMINDER_DAYS = "days" -RESET_REMINDER_SCHEMA = { +RESET_REMINDER_SCHEMA: VolDictType = { vol.Required(ATTR_REMINDER_DAYS): vol.All( vol.Coerce(int), vol.Range(min=30, max=365) ) } -SNOOZE_REMINDER_SCHEMA = { +SNOOZE_REMINDER_SCHEMA: VolDictType = { vol.Required(ATTR_REMINDER_DAYS): vol.All( vol.Coerce(int), vol.Range(min=10, max=120) ) diff --git a/homeassistant/components/smarttub/sensor.py b/homeassistant/components/smarttub/sensor.py index 3694ca81a6b515..585e8859432d60 100644 --- a/homeassistant/components/smarttub/sensor.py +++ b/homeassistant/components/smarttub/sensor.py @@ -10,6 +10,7 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from .const import DOMAIN, SMARTTUB_CONTROLLER from .entity import SmartTubSensorBase @@ -31,7 +32,7 @@ ), ) -SET_SECONDARY_FILTRATION_SCHEMA = { +SET_SECONDARY_FILTRATION_SCHEMA: VolDictType = { vol.Required(ATTR_MODE): vol.In( { mode.name.lower() diff --git a/homeassistant/components/switcher_kis/switch.py b/homeassistant/components/switcher_kis/switch.py index 2280d6bc8453c7..aac5da10ae145e 100644 --- a/homeassistant/components/switcher_kis/switch.py +++ b/homeassistant/components/switcher_kis/switch.py @@ -21,6 +21,7 @@ from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import ( @@ -37,11 +38,11 @@ API_CONTROL_DEVICE = "control_device" API_SET_AUTO_SHUTDOWN = "set_auto_shutdown" -SERVICE_SET_AUTO_OFF_SCHEMA = { +SERVICE_SET_AUTO_OFF_SCHEMA: VolDictType = { vol.Required(CONF_AUTO_OFF): cv.time_period_str, } -SERVICE_TURN_ON_WITH_TIMER_SCHEMA = { +SERVICE_TURN_ON_WITH_TIMER_SCHEMA: VolDictType = { vol.Required(CONF_TIMER_MINUTES): vol.All( cv.positive_int, vol.Range(min=1, max=150) ), diff --git a/homeassistant/components/tado/climate.py b/homeassistant/components/tado/climate.py index 2698b6e1446025..40bdb19b31bdda 100644 --- a/homeassistant/components/tado/climate.py +++ b/homeassistant/components/tado/climate.py @@ -28,6 +28,7 @@ from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from . import TadoConnector from .const import ( @@ -80,7 +81,7 @@ ATTR_TIME_PERIOD = "time_period" ATTR_REQUESTED_OVERLAY = "requested_overlay" -CLIMATE_TIMER_SCHEMA = { +CLIMATE_TIMER_SCHEMA: VolDictType = { vol.Required(ATTR_TEMPERATURE): vol.Coerce(float), vol.Exclusive(ATTR_TIME_PERIOD, CONST_EXCLUSIVE_OVERLAY_GROUP): vol.All( cv.time_period, cv.positive_timedelta, lambda td: td.total_seconds() @@ -93,7 +94,7 @@ SERVICE_TEMP_OFFSET = "set_climate_temperature_offset" ATTR_OFFSET = "offset" -CLIMATE_TEMP_OFFSET_SCHEMA = { +CLIMATE_TEMP_OFFSET_SCHEMA: VolDictType = { vol.Required(ATTR_OFFSET, default=0): vol.Coerce(float), } diff --git a/homeassistant/components/tado/water_heater.py b/homeassistant/components/tado/water_heater.py index 1b3b811d231ef2..0954db71460c15 100644 --- a/homeassistant/components/tado/water_heater.py +++ b/homeassistant/components/tado/water_heater.py @@ -15,6 +15,7 @@ from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from . import TadoConnector from .const import ( @@ -55,7 +56,7 @@ SERVICE_WATER_HEATER_TIMER = "set_water_heater_timer" ATTR_TIME_PERIOD = "time_period" -WATER_HEATER_TIMER_SCHEMA = { +WATER_HEATER_TIMER_SCHEMA: VolDictType = { vol.Required(ATTR_TIME_PERIOD, default="01:00:00"): vol.All( cv.time_period, cv.positive_timedelta, lambda td: td.total_seconds() ), diff --git a/homeassistant/components/upb/const.py b/homeassistant/components/upb/const.py index 8a2c435a70f3a4..16f2f1b7923cd4 100644 --- a/homeassistant/components/upb/const.py +++ b/homeassistant/components/upb/const.py @@ -3,6 +3,7 @@ import voluptuous as vol import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import VolDictType DOMAIN = "upb" @@ -29,7 +30,7 @@ ), ) -UPB_BLINK_RATE_SCHEMA = { +UPB_BLINK_RATE_SCHEMA: VolDictType = { vol.Required(ATTR_BLINK_RATE, default=0.5): vol.All( vol.Coerce(float), vol.Range(min=0, max=4.25) ) diff --git a/homeassistant/components/vizio/const.py b/homeassistant/components/vizio/const.py index 03caa723771576..4eb96256d2e14e 100644 --- a/homeassistant/components/vizio/const.py +++ b/homeassistant/components/vizio/const.py @@ -19,6 +19,7 @@ CONF_NAME, ) import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.typing import VolDictType SERVICE_UPDATE_SETTING = "update_setting" @@ -26,7 +27,7 @@ ATTR_SETTING_NAME = "setting_name" ATTR_NEW_VALUE = "new_value" -UPDATE_SETTING_SCHEMA = { +UPDATE_SETTING_SCHEMA: VolDictType = { vol.Required(ATTR_SETTING_TYPE): vol.All(cv.string, vol.Lower, cv.slugify), vol.Required(ATTR_SETTING_NAME): vol.All(cv.string, vol.Lower, cv.slugify), vol.Required(ATTR_NEW_VALUE): vol.Any(vol.Coerce(int), cv.string), diff --git a/homeassistant/components/wemo/fan.py b/homeassistant/components/wemo/fan.py index 3ef8aa67a3d1d7..e1b9aaf23880bf 100644 --- a/homeassistant/components/wemo/fan.py +++ b/homeassistant/components/wemo/fan.py @@ -14,6 +14,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import entity_platform from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from homeassistant.util.percentage import ( percentage_to_ranged_value, ranged_value_to_percentage, @@ -37,7 +38,7 @@ SPEED_RANGE = (FanMode.Minimum, FanMode.Maximum) # off is not included -SET_HUMIDITY_SCHEMA = { +SET_HUMIDITY_SCHEMA: VolDictType = { vol.Required(ATTR_TARGET_HUMIDITY): vol.All( vol.Coerce(float), vol.Range(min=0, max=100) ), diff --git a/homeassistant/components/yardian/switch.py b/homeassistant/components/yardian/switch.py index 549331b6b5fec8..910bacc1c2efe4 100644 --- a/homeassistant/components/yardian/switch.py +++ b/homeassistant/components/yardian/switch.py @@ -11,13 +11,14 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import VolDictType from homeassistant.helpers.update_coordinator import CoordinatorEntity from .const import DEFAULT_WATERING_DURATION, DOMAIN from .coordinator import YardianUpdateCoordinator SERVICE_START_IRRIGATION = "start_irrigation" -SERVICE_SCHEMA_START_IRRIGATION = { +SERVICE_SCHEMA_START_IRRIGATION: VolDictType = { vol.Required("duration"): cv.positive_int, } diff --git a/homeassistant/components/yeelight/__init__.py b/homeassistant/components/yeelight/__init__.py index 0ed75318ac7b30..9b71bbc3b16e7c 100644 --- a/homeassistant/components/yeelight/__init__.py +++ b/homeassistant/components/yeelight/__init__.py @@ -20,7 +20,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady import homeassistant.helpers.config_validation as cv -from homeassistant.helpers.typing import ConfigType +from homeassistant.helpers.typing import ConfigType, VolDictType from .const import ( ACTION_OFF, @@ -59,7 +59,7 @@ _LOGGER = logging.getLogger(__name__) -YEELIGHT_FLOW_TRANSITION_SCHEMA = { +YEELIGHT_FLOW_TRANSITION_SCHEMA: VolDictType = { vol.Optional(ATTR_COUNT, default=0): cv.positive_int, vol.Optional(ATTR_ACTION, default=ACTION_RECOVER): vol.Any( ACTION_RECOVER, ACTION_OFF, ACTION_STAY diff --git a/homeassistant/components/yeelight/light.py b/homeassistant/components/yeelight/light.py index 1d514c131d2b36..d0d535108590ab 100644 --- a/homeassistant/components/yeelight/light.py +++ b/homeassistant/components/yeelight/light.py @@ -38,6 +38,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.event import async_call_later +from homeassistant.helpers.typing import VolDictType import homeassistant.util.color as color_util from homeassistant.util.color import ( color_temperature_kelvin_to_mired as kelvin_to_mired, @@ -170,22 +171,22 @@ VALID_BRIGHTNESS = vol.All(vol.Coerce(int), vol.Range(min=1, max=100)) -SERVICE_SCHEMA_SET_MODE = { +SERVICE_SCHEMA_SET_MODE: VolDictType = { vol.Required(ATTR_MODE): vol.In([mode.name.lower() for mode in PowerMode]) } -SERVICE_SCHEMA_SET_MUSIC_MODE = {vol.Required(ATTR_MODE_MUSIC): cv.boolean} +SERVICE_SCHEMA_SET_MUSIC_MODE: VolDictType = {vol.Required(ATTR_MODE_MUSIC): cv.boolean} SERVICE_SCHEMA_START_FLOW = YEELIGHT_FLOW_TRANSITION_SCHEMA -SERVICE_SCHEMA_SET_COLOR_SCENE = { +SERVICE_SCHEMA_SET_COLOR_SCENE: VolDictType = { vol.Required(ATTR_RGB_COLOR): vol.All( vol.Coerce(tuple), vol.ExactSequence((cv.byte, cv.byte, cv.byte)) ), vol.Required(ATTR_BRIGHTNESS): VALID_BRIGHTNESS, } -SERVICE_SCHEMA_SET_HSV_SCENE = { +SERVICE_SCHEMA_SET_HSV_SCENE: VolDictType = { vol.Required(ATTR_HS_COLOR): vol.All( vol.Coerce(tuple), vol.ExactSequence( @@ -198,14 +199,14 @@ vol.Required(ATTR_BRIGHTNESS): VALID_BRIGHTNESS, } -SERVICE_SCHEMA_SET_COLOR_TEMP_SCENE = { +SERVICE_SCHEMA_SET_COLOR_TEMP_SCENE: VolDictType = { vol.Required(ATTR_KELVIN): vol.All(vol.Coerce(int), vol.Range(min=1700, max=6500)), vol.Required(ATTR_BRIGHTNESS): VALID_BRIGHTNESS, } SERVICE_SCHEMA_SET_COLOR_FLOW_SCENE = YEELIGHT_FLOW_TRANSITION_SCHEMA -SERVICE_SCHEMA_SET_AUTO_DELAY_OFF_SCENE = { +SERVICE_SCHEMA_SET_AUTO_DELAY_OFF_SCENE: VolDictType = { vol.Required(ATTR_MINUTES): vol.All(vol.Coerce(int), vol.Range(min=1, max=60)), vol.Required(ATTR_BRIGHTNESS): VALID_BRIGHTNESS, }