mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 08:47:57 +00:00
Add target to services.yaml (#46410)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
20d93b4b29
commit
6986fa4eb6
@ -2,13 +2,19 @@
|
||||
|
||||
turn_on:
|
||||
description: Turn a light on.
|
||||
target:
|
||||
fields:
|
||||
entity_id:
|
||||
description: Name(s) of entities to turn on
|
||||
example: "light.kitchen"
|
||||
transition:
|
||||
name: Transition
|
||||
description: Duration in seconds it takes to get to next state
|
||||
example: 60
|
||||
selector:
|
||||
number:
|
||||
min: 0
|
||||
max: 300
|
||||
step: 1
|
||||
unit_of_measurement: seconds
|
||||
mode: slider
|
||||
rgb_color:
|
||||
description: Color for the light in RGB-format.
|
||||
example: "[255, 100, 100]"
|
||||
@ -34,8 +40,16 @@ turn_on:
|
||||
description: Number between 0..255 indicating brightness, where 0 turns the light off, 1 is the minimum brightness and 255 is the maximum brightness supported by the light.
|
||||
example: 120
|
||||
brightness_pct:
|
||||
name: Brightness
|
||||
description: Number between 0..100 indicating percentage of full brightness, where 0 turns the light off, 1 is the minimum brightness and 100 is the maximum brightness supported by the light.
|
||||
example: 47
|
||||
selector:
|
||||
number:
|
||||
min: 0
|
||||
max: 100
|
||||
step: 1
|
||||
unit_of_measurement: "%"
|
||||
mode: slider
|
||||
brightness_step:
|
||||
description: Change brightness by an amount. Should be between -255..255.
|
||||
example: -25.5
|
||||
|
@ -4,6 +4,10 @@ join:
|
||||
master:
|
||||
description: Entity ID of the player that should become the coordinator of the group.
|
||||
example: "media_player.living_room_sonos"
|
||||
selector:
|
||||
entity:
|
||||
integration: sonos
|
||||
domain: media_player
|
||||
entity_id:
|
||||
description: Name(s) of entities that will join the master.
|
||||
example: "media_player.living_room_sonos"
|
||||
@ -64,7 +68,13 @@ set_sleep_timer:
|
||||
sleep_time:
|
||||
description: Number of seconds to set the timer.
|
||||
example: "900"
|
||||
|
||||
selector:
|
||||
number:
|
||||
min: 0
|
||||
max: 3600
|
||||
step: 1
|
||||
unit_of_measurement: seconds
|
||||
mode: slider
|
||||
clear_sleep_timer:
|
||||
description: Clear a Sonos timer.
|
||||
fields:
|
||||
@ -89,12 +99,18 @@ set_option:
|
||||
night_sound:
|
||||
description: Enable Night Sound mode
|
||||
example: "true"
|
||||
selector:
|
||||
boolean:
|
||||
speech_enhance:
|
||||
description: Enable Speech Enhancement mode
|
||||
example: "true"
|
||||
selector:
|
||||
boolean:
|
||||
status_light:
|
||||
description: Enable Status (LED) Light
|
||||
example: "true"
|
||||
selector:
|
||||
boolean:
|
||||
|
||||
play_queue:
|
||||
description: Starts playing the queue from the first item.
|
||||
@ -109,6 +125,11 @@ play_queue:
|
||||
queue_position:
|
||||
description: Position of the song in the queue to start playing from.
|
||||
example: "0"
|
||||
selector:
|
||||
number:
|
||||
min: 0
|
||||
max: 100000000
|
||||
mode: box
|
||||
|
||||
remove_from_queue:
|
||||
description: Removes an item from the queue.
|
||||
@ -123,6 +144,11 @@ remove_from_queue:
|
||||
queue_position:
|
||||
description: Position in the queue to remove.
|
||||
example: "0"
|
||||
selector:
|
||||
number:
|
||||
min: 0
|
||||
max: 100000000
|
||||
mode: box
|
||||
|
||||
update_alarm:
|
||||
description: Updates an alarm with new time and volume settings.
|
||||
|
@ -448,12 +448,16 @@ async def async_get_all_descriptions(
|
||||
# Don't warn for missing services, because it triggers false
|
||||
# positives for things like scripts, that register as a service
|
||||
|
||||
description = descriptions_cache[cache_key] = {
|
||||
description = {
|
||||
"description": yaml_description.get("description", ""),
|
||||
"target": yaml_description.get("target"),
|
||||
"fields": yaml_description.get("fields", {}),
|
||||
}
|
||||
|
||||
if "target" in yaml_description:
|
||||
description["target"] = yaml_description["target"]
|
||||
|
||||
descriptions_cache[cache_key] = description
|
||||
|
||||
descriptions[domain][service] = description
|
||||
|
||||
return descriptions
|
||||
|
@ -24,6 +24,7 @@ def exists(value):
|
||||
FIELD_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required("description"): str,
|
||||
vol.Optional("name"): str,
|
||||
vol.Optional("example"): exists,
|
||||
vol.Optional("default"): exists,
|
||||
vol.Optional("values"): exists,
|
||||
@ -35,6 +36,9 @@ FIELD_SCHEMA = vol.Schema(
|
||||
SERVICE_SCHEMA = vol.Schema(
|
||||
{
|
||||
vol.Required("description"): str,
|
||||
vol.Optional("target"): vol.Any(
|
||||
selector.TargetSelector.CONFIG_SCHEMA, None # pylint: disable=no-member
|
||||
),
|
||||
vol.Optional("fields"): vol.Schema({str: FIELD_SCHEMA}),
|
||||
}
|
||||
)
|
||||
@ -60,7 +64,9 @@ def validate_services(integration: Integration):
|
||||
"""Validate services."""
|
||||
# Find if integration uses services
|
||||
has_services = grep_dir(
|
||||
integration.path, "**/*.py", r"hass\.services\.(register|async_register)"
|
||||
integration.path,
|
||||
"**/*.py",
|
||||
r"(hass\.services\.(register|async_register))|async_register_entity_service",
|
||||
)
|
||||
|
||||
if not has_services:
|
||||
|
Loading…
x
Reference in New Issue
Block a user