Use VolDictType for service schemas (#120403)

This commit is contained in:
Marc Mueller 2024-06-25 12:33:41 +02:00 committed by GitHub
parent b4eee166aa
commit 3a5acd6a57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
33 changed files with 91 additions and 59 deletions

View File

@ -64,7 +64,7 @@ from homeassistant.helpers.entity_component import EntityComponent
from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.network import get_url from homeassistant.helpers.network import get_url
from homeassistant.helpers.template import Template 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 homeassistant.loader import bind_hass
from .const import ( # noqa: F401 from .const import ( # noqa: F401
@ -130,14 +130,14 @@ _RND: Final = SystemRandom()
MIN_STREAM_INTERVAL: Final = 0.5 # seconds 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.Required(ATTR_MEDIA_PLAYER): cv.entities_domain(DOMAIN_MP),
vol.Optional(ATTR_FORMAT, default="hls"): vol.In(OUTPUT_FORMATS), 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.Required(CONF_FILENAME): cv.template,
vol.Optional(CONF_DURATION, default=30): vol.Coerce(int), vol.Optional(CONF_DURATION, default=30): vol.Coerce(int),
vol.Optional(CONF_LOOKBACK, default=0): vol.Coerce(int), vol.Optional(CONF_LOOKBACK, default=0): vol.Coerce(int),

View File

@ -31,6 +31,7 @@ from homeassistant.helpers import entity_platform
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.typing import VolDictType
from . import ElkAttachedEntity, ElkEntity, ElkM1ConfigEntry, create_elk_entities from . import ElkAttachedEntity, ElkEntity, ElkM1ConfigEntry, create_elk_entities
from .const import ( from .const import (
@ -41,7 +42,7 @@ from .const import (
) )
from .models import ELKM1Data 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("clear", default=2): vol.All(vol.Coerce(int), vol.In([0, 1, 2])),
vol.Optional("beep", default=False): cv.boolean, vol.Optional("beep", default=False): cv.boolean,
vol.Optional("timeout", default=0): vol.All( vol.Optional("timeout", default=0): vol.All(

View File

@ -6,6 +6,7 @@ from elkm1_lib.const import Max
import voluptuous as vol import voluptuous as vol
from homeassistant.const import ATTR_CODE, CONF_ZONE from homeassistant.const import ATTR_CODE, CONF_ZONE
from homeassistant.helpers.typing import VolDictType
DOMAIN = "elkm1" DOMAIN = "elkm1"
@ -48,6 +49,6 @@ ATTR_CHANGED_BY_ID = "changed_by_id"
ATTR_CHANGED_BY_TIME = "changed_by_time" ATTR_CHANGED_BY_TIME = "changed_by_time"
ATTR_VALUE = "value" 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)) vol.Required(ATTR_CODE): vol.All(vol.Coerce(int), vol.Range(0, 999999))
} }

View File

@ -20,6 +20,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from . import ElkAttachedEntity, ElkEntity, ElkM1ConfigEntry, create_elk_entities from . import ElkAttachedEntity, ElkEntity, ElkM1ConfigEntry, create_elk_entities
from .const import ATTR_VALUE, ELK_USER_CODE_SERVICE_SCHEMA from .const import ATTR_VALUE, ELK_USER_CODE_SERVICE_SCHEMA
@ -30,7 +31,7 @@ SERVICE_SENSOR_ZONE_BYPASS = "sensor_zone_bypass"
SERVICE_SENSOR_ZONE_TRIGGER = "sensor_zone_trigger" SERVICE_SENSOR_ZONE_TRIGGER = "sensor_zone_trigger"
UNDEFINED_TEMPERATURE = -40 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)) vol.Required(ATTR_VALUE): vol.All(vol.Coerce(int), vol.Range(0, 65535))
} }

View File

@ -11,13 +11,14 @@ from homeassistant.helpers.entity_platform import (
AddEntitiesCallback, AddEntitiesCallback,
async_get_current_platform, async_get_current_platform,
) )
from homeassistant.helpers.typing import VolDictType
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
from . import device_info from . import device_info
from .const import ATTR_OBSERVATION_TIME, DOMAIN from .const import ATTR_OBSERVATION_TIME, DOMAIN
SERVICE_SET_RADAR_TYPE = "set_radar_type" 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"]), vol.Required("radar_type"): vol.In(["Auto", "Rain", "Snow"]),
} }

View File

@ -28,6 +28,7 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_platform
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.util.color import ( from homeassistant.util.color import (
color_temperature_kelvin_to_mired, color_temperature_kelvin_to_mired,
@ -88,7 +89,7 @@ SERVICE_CUSTOM_EFFECT: Final = "set_custom_effect"
SERVICE_SET_ZONES: Final = "set_zones" SERVICE_SET_ZONES: Final = "set_zones"
SERVICE_SET_MUSIC_MODE: Final = "set_music_mode" SERVICE_SET_MUSIC_MODE: Final = "set_music_mode"
CUSTOM_EFFECT_DICT: Final = { CUSTOM_EFFECT_DICT: VolDictType = {
vol.Required(CONF_COLORS): vol.All( vol.Required(CONF_COLORS): vol.All(
cv.ensure_list, cv.ensure_list,
vol.Length(min=1, max=16), vol.Length(min=1, max=16),
@ -102,7 +103,7 @@ CUSTOM_EFFECT_DICT: Final = {
), ),
} }
SET_MUSIC_MODE_DICT: Final = { SET_MUSIC_MODE_DICT: VolDictType = {
vol.Optional(ATTR_SENSITIVITY, default=100): vol.All( vol.Optional(ATTR_SENSITIVITY, default=100): vol.All(
vol.Coerce(int), vol.Range(min=0, max=100) vol.Coerce(int), vol.Range(min=0, max=100)
), ),
@ -121,7 +122,7 @@ SET_MUSIC_MODE_DICT: Final = {
), ),
} }
SET_ZONES_DICT: Final = { SET_ZONES_DICT: VolDictType = {
vol.Required(CONF_COLORS): vol.All( vol.Required(CONF_COLORS): vol.All(
cv.ensure_list, cv.ensure_list,
vol.Length(min=1, max=2048), vol.Length(min=1, max=2048),

View File

@ -11,7 +11,7 @@ from homeassistant.components.switch import SwitchDeviceClass, SwitchEntity
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback 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 from . import ATTR_DURATION, DOMAIN, GeniusZone
@ -19,7 +19,7 @@ GH_ON_OFF_ZONE = "on / off"
SVC_SET_SWITCH_OVERRIDE = "set_switch_override" SVC_SET_SWITCH_OVERRIDE = "set_switch_override"
SET_SWITCH_OVERRIDE_SCHEMA = { SET_SWITCH_OVERRIDE_SCHEMA: VolDictType = {
vol.Optional(ATTR_DURATION): vol.All( vol.Optional(ATTR_DURATION): vol.All(
cv.time_period, cv.time_period,
vol.Range(min=timedelta(minutes=5), max=timedelta(days=1)), vol.Range(min=timedelta(minutes=5), max=timedelta(days=1)),

View File

@ -26,6 +26,7 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.typing import VolDictType
from .const import ( from .const import (
ACTIVITY_POWER_OFF, ACTIVITY_POWER_OFF,
@ -50,7 +51,7 @@ PARALLEL_UPDATES = 0
ATTR_CHANNEL = "channel" ATTR_CHANNEL = "channel"
HARMONY_CHANGE_CHANNEL_SCHEMA = { HARMONY_CHANGE_CHANNEL_SCHEMA: VolDictType = {
vol.Required(ATTR_CHANNEL): cv.positive_int, vol.Required(ATTR_CHANNEL): cv.positive_int,
} }

View File

@ -18,6 +18,7 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
from homeassistant.helpers.entity_platform import async_get_platforms from homeassistant.helpers.entity_platform import async_get_platforms
from homeassistant.helpers.service import entity_service_call from homeassistant.helpers.service import entity_service_call
from homeassistant.helpers.typing import VolDictType
from .const import _LOGGER, DOMAIN from .const import _LOGGER, DOMAIN
@ -102,12 +103,14 @@ SERVICE_SET_ZWAVE_PARAMETER_SCHEMA = {
vol.Required(CONF_SIZE): vol.All(vol.Coerce(int), vol.In(VALID_PARAMETER_SIZES)), 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_USER_NUM): vol.Coerce(int),
vol.Required(CONF_CODE): 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( SERVICE_SEND_PROGRAM_COMMAND_SCHEMA = vol.All(
cv.has_at_least_one_key(CONF_ADDRESS, CONF_NAME), cv.has_at_least_one_key(CONF_ADDRESS, CONF_NAME),

View File

@ -35,7 +35,7 @@ from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.temperature import display_temp as show_temp 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 ( from .const import (
DATA_CONFIG, DATA_CONFIG,
@ -65,7 +65,7 @@ ATTR_AIRFLOW = "airflow"
IZONE_SERVICE_AIRFLOW_MIN = "airflow_min" IZONE_SERVICE_AIRFLOW_MIN = "airflow_min"
IZONE_SERVICE_AIRFLOW_MAX = "airflow_max" IZONE_SERVICE_AIRFLOW_MAX = "airflow_max"
IZONE_SERVICE_AIRFLOW_SCHEMA = { IZONE_SERVICE_AIRFLOW_SCHEMA: VolDictType = {
vol.Required(ATTR_AIRFLOW): vol.All( vol.Required(ATTR_AIRFLOW): vol.All(
vol.Coerce(int), vol.Range(min=0, max=100), msg="invalid airflow" vol.Coerce(int), vol.Range(min=0, max=100), msg="invalid airflow"
), ),

View File

@ -14,13 +14,14 @@ from homeassistant.helpers.entity_platform import (
AddEntitiesCallback, AddEntitiesCallback,
async_get_current_platform, async_get_current_platform,
) )
from homeassistant.helpers.typing import VolDictType
from .const import DOMAIN from .const import DOMAIN
from .coordinator import MicroBotDataUpdateCoordinator from .coordinator import MicroBotDataUpdateCoordinator
from .entity import MicroBotEntity from .entity import MicroBotEntity
CALIBRATE = "calibrate" CALIBRATE = "calibrate"
CALIBRATE_SCHEMA = { CALIBRATE_SCHEMA: VolDictType = {
vol.Required("depth"): cv.positive_int, vol.Required("depth"): cv.positive_int,
vol.Required("duration"): cv.positive_int, vol.Required("duration"): cv.positive_int,
vol.Required("mode"): vol.In(["normal", "invert", "toggle"]), vol.Required("mode"): vol.In(["normal", "invert", "toggle"]),

View File

@ -49,7 +49,7 @@ from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.network import is_internal_request 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 import homeassistant.util.dt as dt_util
from .browse_media import ( from .browse_media import (
@ -147,7 +147,7 @@ ATTR_MEDIA_ID = "media_id"
ATTR_METHOD = "method" ATTR_METHOD = "method"
KODI_ADD_MEDIA_SCHEMA = { KODI_ADD_MEDIA_SCHEMA: VolDictType = {
vol.Required(ATTR_MEDIA_TYPE): cv.string, vol.Required(ATTR_MEDIA_TYPE): cv.string,
vol.Optional(ATTR_MEDIA_ID): cv.string, vol.Optional(ATTR_MEDIA_ID): cv.string,
vol.Optional(ATTR_MEDIA_NAME): cv.string, vol.Optional(ATTR_MEDIA_NAME): cv.string,

View File

@ -25,6 +25,7 @@ from homeassistant.helpers import entity_platform
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import async_call_later from homeassistant.helpers.event import async_call_later
from homeassistant.helpers.typing import VolDictType
from .const import ( from .const import (
_LOGGER, _LOGGER,
@ -53,7 +54,7 @@ LIFX_STATE_SETTLE_DELAY = 0.3
SERVICE_LIFX_SET_STATE = "set_state" SERVICE_LIFX_SET_STATE = "set_state"
LIFX_SET_STATE_SCHEMA = { LIFX_SET_STATE_SCHEMA: VolDictType = {
**LIGHT_TURN_ON_SCHEMA, **LIGHT_TURN_ON_SCHEMA,
ATTR_INFRARED: vol.All(vol.Coerce(int), vol.Clamp(min=0, max=255)), ATTR_INFRARED: vol.All(vol.Coerce(int), vol.Clamp(min=0, max=255)),
ATTR_ZONES: vol.All(cv.ensure_list, [cv.positive_int]), ATTR_ZONES: vol.All(cv.ensure_list, [cv.positive_int]),
@ -63,7 +64,7 @@ LIFX_SET_STATE_SCHEMA = {
SERVICE_LIFX_SET_HEV_CYCLE_STATE = "set_hev_cycle_state" 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_POWER: vol.Required(cv.boolean),
ATTR_DURATION: vol.All(vol.Coerce(float), vol.Clamp(min=0, max=86400)), ATTR_DURATION: vol.All(vol.Coerce(float), vol.Clamp(min=0, max=86400)),
} }

View File

@ -31,7 +31,7 @@ from homeassistant.helpers.config_validation import ( # noqa: F401
) )
from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
from homeassistant.helpers.entity_component import EntityComponent 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 from homeassistant.loader import bind_hass
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
@ -247,7 +247,7 @@ VALID_BRIGHTNESS_STEP = vol.All(vol.Coerce(int), vol.Clamp(min=-255, max=255))
VALID_BRIGHTNESS_STEP_PCT = vol.All(vol.Coerce(float), vol.Clamp(min=-100, max=100)) VALID_BRIGHTNESS_STEP_PCT = vol.All(vol.Coerce(float), vol.Clamp(min=-100, max=100))
VALID_FLASH = vol.In([FLASH_SHORT, FLASH_LONG]) 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, vol.Exclusive(ATTR_PROFILE, COLOR_GROUP): cv.string,
ATTR_TRANSITION: VALID_TRANSITION, ATTR_TRANSITION: VALID_TRANSITION,
vol.Exclusive(ATTR_BRIGHTNESS, ATTR_BRIGHTNESS): VALID_BRIGHTNESS, vol.Exclusive(ATTR_BRIGHTNESS, ATTR_BRIGHTNESS): VALID_BRIGHTNESS,
@ -286,7 +286,10 @@ LIGHT_TURN_ON_SCHEMA = {
ATTR_EFFECT: cv.string, 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__) _LOGGER = logging.getLogger(__name__)

View File

@ -37,6 +37,7 @@ from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_platform
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from . import LyricDeviceEntity from . import LyricDeviceEntity
@ -111,7 +112,7 @@ HVAC_ACTIONS = {
SERVICE_HOLD_TIME = "set_hold_time" SERVICE_HOLD_TIME = "set_hold_time"
ATTR_TIME_PERIOD = "time_period" ATTR_TIME_PERIOD = "time_period"
SCHEMA_HOLD_TIME = { SCHEMA_HOLD_TIME: VolDictType = {
vol.Required(ATTR_TIME_PERIOD, default="01:00:00"): vol.All( vol.Required(ATTR_TIME_PERIOD, default="01:00:00"): vol.All(
cv.time_period, cv.time_period,
cv.positive_timedelta, cv.positive_timedelta,

View File

@ -20,6 +20,7 @@ from homeassistant.core import CALLBACK_TYPE, HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import async_call_later from homeassistant.helpers.event import async_call_later
from homeassistant.helpers.typing import VolDictType
from .const import ( from .const import (
ATTR_ABSOLUTE_POSITION, ATTR_ABSOLUTE_POSITION,
@ -75,7 +76,7 @@ TDBU_DEVICE_MAP = {
} }
SET_ABSOLUTE_POSITION_SCHEMA = { SET_ABSOLUTE_POSITION_SCHEMA: VolDictType = {
vol.Required(ATTR_ABSOLUTE_POSITION): vol.All(cv.positive_int, vol.Range(max=100)), 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_TILT_POSITION): vol.All(cv.positive_int, vol.Range(max=100)),
vol.Optional(ATTR_WIDTH): vol.All(cv.positive_int, vol.Range(max=100)), vol.Optional(ATTR_WIDTH): vol.All(cv.positive_int, vol.Range(max=100)),

View File

@ -37,6 +37,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_platform
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from .const import ( from .const import (
ATTR_AIRCLEANER_MODE, ATTR_AIRCLEANER_MODE,
@ -55,11 +56,11 @@ SERVICE_SET_AIRCLEANER_MODE = "set_aircleaner_mode"
SERVICE_SET_HUMIDIFY_SETPOINT = "set_humidify_setpoint" SERVICE_SET_HUMIDIFY_SETPOINT = "set_humidify_setpoint"
SERVICE_SET_HVAC_RUN_MODE = "set_hvac_run_mode" SERVICE_SET_HVAC_RUN_MODE = "set_hvac_run_mode"
SET_AIRCLEANER_SCHEMA = { SET_AIRCLEANER_SCHEMA: VolDictType = {
vol.Required(ATTR_AIRCLEANER_MODE): cv.string, 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)), vol.Required(ATTR_HUMIDITY): vol.All(vol.Coerce(int), vol.Range(min=35, max=65)),
} }

View File

@ -14,6 +14,7 @@ from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import ATTR_DURATION, CONF_IMPORTED_NAMES, DOMAIN, MANUFACTURER from .const import ATTR_DURATION, CONF_IMPORTED_NAMES, DOMAIN, MANUFACTURER
@ -23,7 +24,7 @@ _LOGGER = logging.getLogger(__name__)
SERVICE_START_IRRIGATION = "start_irrigation" SERVICE_START_IRRIGATION = "start_irrigation"
SERVICE_SCHEMA_IRRIGATION = { SERVICE_SCHEMA_IRRIGATION: VolDictType = {
vol.Required(ATTR_DURATION): cv.positive_float, vol.Required(ATTR_DURATION): cv.positive_float,
} }

View File

@ -6,7 +6,7 @@ import asyncio
from collections.abc import Awaitable, Callable, Coroutine from collections.abc import Awaitable, Callable, Coroutine
from dataclasses import dataclass from dataclasses import dataclass
from datetime import datetime from datetime import datetime
from typing import Any, Concatenate from typing import Any, Concatenate, cast
from regenmaschine.errors import RainMachineError from regenmaschine.errors import RainMachineError
import voluptuous as vol import voluptuous as vol
@ -18,6 +18,7 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from . import RainMachineData, RainMachineEntity, async_update_programs_and_zones from . import RainMachineData, RainMachineEntity, async_update_programs_and_zones
from .const import ( from .const import (
@ -191,7 +192,8 @@ async def async_setup_entry(
("stop_program", {}, "async_stop_program"), ("stop_program", {}, "async_stop_program"),
("stop_zone", {}, "async_stop_zone"), ("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] data: RainMachineData = hass.data[DOMAIN][entry.entry_id]
entities: list[RainMachineBaseSwitch] = [] entities: list[RainMachineBaseSwitch] = []

View File

@ -21,6 +21,7 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_platform
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from homeassistant.util.percentage import ( from homeassistant.util.percentage import (
percentage_to_ranged_value, percentage_to_ranged_value,
ranged_value_to_percentage, ranged_value_to_percentage,
@ -51,20 +52,20 @@ SPEED_MAPPING = {
Level.LEVEL4.value: 4, Level.LEVEL4.value: 4,
} }
SET_TIMER_LEVEL_SCHEMA = { SET_TIMER_LEVEL_SCHEMA: VolDictType = {
vol.Required("timer_level"): vol.In( vol.Required("timer_level"): vol.In(
["level1", "level2", "level3", "level4", "holiday", "breeze"] ["level1", "level2", "level3", "level4", "holiday", "breeze"]
), ),
vol.Required("minutes"): cv.positive_int, 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("breeze_level"): vol.In(["level1", "level2", "level3", "level4"]),
vol.Required("temperature"): cv.positive_int, vol.Required("temperature"): cv.positive_int,
vol.Required("activate"): bool, vol.Required("activate"): bool,
} }
SET_POLLUTION_SETTINGS_SCHEMA = { SET_POLLUTION_SETTINGS_SCHEMA: VolDictType = {
vol.Required("day_pollution_level"): vol.In( vol.Required("day_pollution_level"): vol.In(
["level1", "level2", "level3", "level4"] ["level1", "level2", "level3", "level4"]
), ),

View File

@ -28,6 +28,7 @@ from homeassistant.const import ATTR_NAME
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from .browse_media import async_browse_media from .browse_media import async_browse_media
from .const import ( from .const import (
@ -78,7 +79,7 @@ ATTRS_TO_PLAY_ON_ROKU_AUDIO_PARAMS = {
ATTR_THUMBNAIL: "albumArtUrl", ATTR_THUMBNAIL: "albumArtUrl",
} }
SEARCH_SCHEMA = {vol.Required(ATTR_KEYWORD): str} SEARCH_SCHEMA: VolDictType = {vol.Required(ATTR_KEYWORD): str}
async def async_setup_entry( async def async_setup_entry(

View File

@ -24,7 +24,7 @@ from homeassistant.helpers.deprecation import (
) )
from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription from homeassistant.helpers.entity import ToggleEntity, ToggleEntityDescription
from homeassistant.helpers.entity_component import EntityComponent 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 from .const import ( # noqa: F401
_DEPRECATED_SUPPORT_DURATION, _DEPRECATED_SUPPORT_DURATION,
@ -44,7 +44,7 @@ _LOGGER = logging.getLogger(__name__)
SCAN_INTERVAL = timedelta(seconds=60) 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_TONE): vol.Any(vol.Coerce(int), cv.string),
vol.Optional(ATTR_DURATION): cv.positive_int, vol.Optional(ATTR_DURATION): cv.positive_int,
vol.Optional(ATTR_VOLUME_LEVEL): cv.small_float, vol.Optional(ATTR_VOLUME_LEVEL): cv.small_float,

View File

@ -13,6 +13,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from .const import ATTR_ERRORS, ATTR_REMINDERS, DOMAIN, SMARTTUB_CONTROLLER from .const import ATTR_ERRORS, ATTR_REMINDERS, DOMAIN, SMARTTUB_CONTROLLER
from .entity import SmartTubEntity, SmartTubSensorBase from .entity import SmartTubEntity, SmartTubSensorBase
@ -29,12 +30,12 @@ ATTR_UPDATED_AT = "updated_at"
# how many days to snooze the reminder for # how many days to snooze the reminder for
ATTR_REMINDER_DAYS = "days" ATTR_REMINDER_DAYS = "days"
RESET_REMINDER_SCHEMA = { RESET_REMINDER_SCHEMA: VolDictType = {
vol.Required(ATTR_REMINDER_DAYS): vol.All( vol.Required(ATTR_REMINDER_DAYS): vol.All(
vol.Coerce(int), vol.Range(min=30, max=365) vol.Coerce(int), vol.Range(min=30, max=365)
) )
} }
SNOOZE_REMINDER_SCHEMA = { SNOOZE_REMINDER_SCHEMA: VolDictType = {
vol.Required(ATTR_REMINDER_DAYS): vol.All( vol.Required(ATTR_REMINDER_DAYS): vol.All(
vol.Coerce(int), vol.Range(min=10, max=120) vol.Coerce(int), vol.Range(min=10, max=120)
) )

View File

@ -10,6 +10,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from .const import DOMAIN, SMARTTUB_CONTROLLER from .const import DOMAIN, SMARTTUB_CONTROLLER
from .entity import SmartTubSensorBase from .entity import SmartTubSensorBase
@ -31,7 +32,7 @@ SET_PRIMARY_FILTRATION_SCHEMA = vol.All(
), ),
) )
SET_SECONDARY_FILTRATION_SCHEMA = { SET_SECONDARY_FILTRATION_SCHEMA: VolDictType = {
vol.Required(ATTR_MODE): vol.In( vol.Required(ATTR_MODE): vol.In(
{ {
mode.name.lower() mode.name.lower()

View File

@ -21,6 +21,7 @@ from homeassistant.helpers import (
from homeassistant.helpers.device_registry import DeviceInfo from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import ( from .const import (
@ -37,11 +38,11 @@ _LOGGER = logging.getLogger(__name__)
API_CONTROL_DEVICE = "control_device" API_CONTROL_DEVICE = "control_device"
API_SET_AUTO_SHUTDOWN = "set_auto_shutdown" 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, 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( vol.Required(CONF_TIMER_MINUTES): vol.All(
cv.positive_int, vol.Range(min=1, max=150) cv.positive_int, vol.Range(min=1, max=150)
), ),

View File

@ -28,6 +28,7 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from . import TadoConnector from . import TadoConnector
from .const import ( from .const import (
@ -80,7 +81,7 @@ SERVICE_CLIMATE_TIMER = "set_climate_timer"
ATTR_TIME_PERIOD = "time_period" ATTR_TIME_PERIOD = "time_period"
ATTR_REQUESTED_OVERLAY = "requested_overlay" ATTR_REQUESTED_OVERLAY = "requested_overlay"
CLIMATE_TIMER_SCHEMA = { CLIMATE_TIMER_SCHEMA: VolDictType = {
vol.Required(ATTR_TEMPERATURE): vol.Coerce(float), vol.Required(ATTR_TEMPERATURE): vol.Coerce(float),
vol.Exclusive(ATTR_TIME_PERIOD, CONST_EXCLUSIVE_OVERLAY_GROUP): vol.All( vol.Exclusive(ATTR_TIME_PERIOD, CONST_EXCLUSIVE_OVERLAY_GROUP): vol.All(
cv.time_period, cv.positive_timedelta, lambda td: td.total_seconds() cv.time_period, cv.positive_timedelta, lambda td: td.total_seconds()
@ -93,7 +94,7 @@ CLIMATE_TIMER_SCHEMA = {
SERVICE_TEMP_OFFSET = "set_climate_temperature_offset" SERVICE_TEMP_OFFSET = "set_climate_temperature_offset"
ATTR_OFFSET = "offset" ATTR_OFFSET = "offset"
CLIMATE_TEMP_OFFSET_SCHEMA = { CLIMATE_TEMP_OFFSET_SCHEMA: VolDictType = {
vol.Required(ATTR_OFFSET, default=0): vol.Coerce(float), vol.Required(ATTR_OFFSET, default=0): vol.Coerce(float),
} }

View File

@ -15,6 +15,7 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from . import TadoConnector from . import TadoConnector
from .const import ( from .const import (
@ -55,7 +56,7 @@ WATER_HEATER_MAP_TADO = {
SERVICE_WATER_HEATER_TIMER = "set_water_heater_timer" SERVICE_WATER_HEATER_TIMER = "set_water_heater_timer"
ATTR_TIME_PERIOD = "time_period" 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( vol.Required(ATTR_TIME_PERIOD, default="01:00:00"): vol.All(
cv.time_period, cv.positive_timedelta, lambda td: td.total_seconds() cv.time_period, cv.positive_timedelta, lambda td: td.total_seconds()
), ),

View File

@ -3,6 +3,7 @@
import voluptuous as vol import voluptuous as vol
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import VolDictType
DOMAIN = "upb" DOMAIN = "upb"
@ -29,7 +30,7 @@ UPB_BRIGHTNESS_RATE_SCHEMA = vol.All(
), ),
) )
UPB_BLINK_RATE_SCHEMA = { UPB_BLINK_RATE_SCHEMA: VolDictType = {
vol.Required(ATTR_BLINK_RATE, default=0.5): vol.All( vol.Required(ATTR_BLINK_RATE, default=0.5): vol.All(
vol.Coerce(float), vol.Range(min=0, max=4.25) vol.Coerce(float), vol.Range(min=0, max=4.25)
) )

View File

@ -19,6 +19,7 @@ from homeassistant.const import (
CONF_NAME, CONF_NAME,
) )
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import VolDictType
SERVICE_UPDATE_SETTING = "update_setting" SERVICE_UPDATE_SETTING = "update_setting"
@ -26,7 +27,7 @@ ATTR_SETTING_TYPE = "setting_type"
ATTR_SETTING_NAME = "setting_name" ATTR_SETTING_NAME = "setting_name"
ATTR_NEW_VALUE = "new_value" 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_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_SETTING_NAME): vol.All(cv.string, vol.Lower, cv.slugify),
vol.Required(ATTR_NEW_VALUE): vol.Any(vol.Coerce(int), cv.string), vol.Required(ATTR_NEW_VALUE): vol.Any(vol.Coerce(int), cv.string),

View File

@ -14,6 +14,7 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from homeassistant.util.percentage import ( from homeassistant.util.percentage import (
percentage_to_ranged_value, percentage_to_ranged_value,
ranged_value_to_percentage, ranged_value_to_percentage,
@ -37,7 +38,7 @@ ATTR_WATER_LEVEL = "water_level"
SPEED_RANGE = (FanMode.Minimum, FanMode.Maximum) # off is not included 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.Required(ATTR_TARGET_HUMIDITY): vol.All(
vol.Coerce(float), vol.Range(min=0, max=100) vol.Coerce(float), vol.Range(min=0, max=100)
), ),

View File

@ -11,13 +11,14 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers import config_validation as cv, entity_platform from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import VolDictType
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
from .const import DEFAULT_WATERING_DURATION, DOMAIN from .const import DEFAULT_WATERING_DURATION, DOMAIN
from .coordinator import YardianUpdateCoordinator from .coordinator import YardianUpdateCoordinator
SERVICE_START_IRRIGATION = "start_irrigation" SERVICE_START_IRRIGATION = "start_irrigation"
SERVICE_SCHEMA_START_IRRIGATION = { SERVICE_SCHEMA_START_IRRIGATION: VolDictType = {
vol.Required("duration"): cv.positive_int, vol.Required("duration"): cv.positive_int,
} }

View File

@ -20,7 +20,7 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType, VolDictType
from .const import ( from .const import (
ACTION_OFF, ACTION_OFF,
@ -59,7 +59,7 @@ from .scanner import YeelightScanner
_LOGGER = logging.getLogger(__name__) _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_COUNT, default=0): cv.positive_int,
vol.Optional(ATTR_ACTION, default=ACTION_RECOVER): vol.Any( vol.Optional(ATTR_ACTION, default=ACTION_RECOVER): vol.Any(
ACTION_RECOVER, ACTION_OFF, ACTION_STAY ACTION_RECOVER, ACTION_OFF, ACTION_STAY

View File

@ -38,6 +38,7 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.event import async_call_later from homeassistant.helpers.event import async_call_later
from homeassistant.helpers.typing import VolDictType
import homeassistant.util.color as color_util import homeassistant.util.color as color_util
from homeassistant.util.color import ( from homeassistant.util.color import (
color_temperature_kelvin_to_mired as kelvin_to_mired, color_temperature_kelvin_to_mired as kelvin_to_mired,
@ -170,22 +171,22 @@ EFFECTS_MAP = {
VALID_BRIGHTNESS = vol.All(vol.Coerce(int), vol.Range(min=1, max=100)) 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]) 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_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.Required(ATTR_RGB_COLOR): vol.All(
vol.Coerce(tuple), vol.ExactSequence((cv.byte, cv.byte, cv.byte)) vol.Coerce(tuple), vol.ExactSequence((cv.byte, cv.byte, cv.byte))
), ),
vol.Required(ATTR_BRIGHTNESS): VALID_BRIGHTNESS, 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.Required(ATTR_HS_COLOR): vol.All(
vol.Coerce(tuple), vol.Coerce(tuple),
vol.ExactSequence( vol.ExactSequence(
@ -198,14 +199,14 @@ SERVICE_SCHEMA_SET_HSV_SCENE = {
vol.Required(ATTR_BRIGHTNESS): VALID_BRIGHTNESS, 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_KELVIN): vol.All(vol.Coerce(int), vol.Range(min=1700, max=6500)),
vol.Required(ATTR_BRIGHTNESS): VALID_BRIGHTNESS, vol.Required(ATTR_BRIGHTNESS): VALID_BRIGHTNESS,
} }
SERVICE_SCHEMA_SET_COLOR_FLOW_SCENE = YEELIGHT_FLOW_TRANSITION_SCHEMA 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_MINUTES): vol.All(vol.Coerce(int), vol.Range(min=1, max=60)),
vol.Required(ATTR_BRIGHTNESS): VALID_BRIGHTNESS, vol.Required(ATTR_BRIGHTNESS): VALID_BRIGHTNESS,
} }