mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Add filters to cover/services.yaml (#95854)
This commit is contained in:
parent
b5678a12ec
commit
3d064b7d6b
@ -6,6 +6,8 @@ open_cover:
|
|||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
domain: cover
|
domain: cover
|
||||||
|
supported_features:
|
||||||
|
- cover.CoverEntityFeature.OPEN
|
||||||
|
|
||||||
close_cover:
|
close_cover:
|
||||||
name: Close
|
name: Close
|
||||||
@ -13,6 +15,8 @@ close_cover:
|
|||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
domain: cover
|
domain: cover
|
||||||
|
supported_features:
|
||||||
|
- cover.CoverEntityFeature.CLOSE
|
||||||
|
|
||||||
toggle:
|
toggle:
|
||||||
name: Toggle
|
name: Toggle
|
||||||
@ -20,6 +24,9 @@ toggle:
|
|||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
domain: cover
|
domain: cover
|
||||||
|
supported_features:
|
||||||
|
- - cover.CoverEntityFeature.CLOSE
|
||||||
|
- cover.CoverEntityFeature.OPEN
|
||||||
|
|
||||||
set_cover_position:
|
set_cover_position:
|
||||||
name: Set position
|
name: Set position
|
||||||
@ -27,6 +34,8 @@ set_cover_position:
|
|||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
domain: cover
|
domain: cover
|
||||||
|
supported_features:
|
||||||
|
- cover.CoverEntityFeature.SET_POSITION
|
||||||
fields:
|
fields:
|
||||||
position:
|
position:
|
||||||
name: Position
|
name: Position
|
||||||
@ -44,6 +53,8 @@ stop_cover:
|
|||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
domain: cover
|
domain: cover
|
||||||
|
supported_features:
|
||||||
|
- cover.CoverEntityFeature.STOP
|
||||||
|
|
||||||
open_cover_tilt:
|
open_cover_tilt:
|
||||||
name: Open tilt
|
name: Open tilt
|
||||||
@ -51,6 +62,8 @@ open_cover_tilt:
|
|||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
domain: cover
|
domain: cover
|
||||||
|
supported_features:
|
||||||
|
- cover.CoverEntityFeature.OPEN_TILT
|
||||||
|
|
||||||
close_cover_tilt:
|
close_cover_tilt:
|
||||||
name: Close tilt
|
name: Close tilt
|
||||||
@ -58,6 +71,8 @@ close_cover_tilt:
|
|||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
domain: cover
|
domain: cover
|
||||||
|
supported_features:
|
||||||
|
- cover.CoverEntityFeature.CLOSE_TILT
|
||||||
|
|
||||||
toggle_cover_tilt:
|
toggle_cover_tilt:
|
||||||
name: Toggle tilt
|
name: Toggle tilt
|
||||||
@ -65,6 +80,9 @@ toggle_cover_tilt:
|
|||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
domain: cover
|
domain: cover
|
||||||
|
supported_features:
|
||||||
|
- - cover.CoverEntityFeature.CLOSE_TILT
|
||||||
|
- cover.CoverEntityFeature.OPEN_TILT
|
||||||
|
|
||||||
set_cover_tilt_position:
|
set_cover_tilt_position:
|
||||||
name: Set tilt position
|
name: Set tilt position
|
||||||
@ -72,6 +90,8 @@ set_cover_tilt_position:
|
|||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
domain: cover
|
domain: cover
|
||||||
|
supported_features:
|
||||||
|
- cover.CoverEntityFeature.SET_TILT_POSITION
|
||||||
fields:
|
fields:
|
||||||
tilt_position:
|
tilt_position:
|
||||||
name: Tilt position
|
name: Tilt position
|
||||||
@ -89,3 +109,5 @@ stop_cover_tilt:
|
|||||||
target:
|
target:
|
||||||
entity:
|
entity:
|
||||||
domain: cover
|
domain: cover
|
||||||
|
supported_features:
|
||||||
|
- cover.CoverEntityFeature.STOP_TILT
|
||||||
|
@ -122,12 +122,9 @@ def _entity_features() -> dict[str, type[IntFlag]]:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _validate_supported_feature(supported_feature: int | str) -> int:
|
def _validate_supported_feature(supported_feature: str) -> int:
|
||||||
"""Validate a supported feature and resolve an enum string to its value."""
|
"""Validate a supported feature and resolve an enum string to its value."""
|
||||||
|
|
||||||
if isinstance(supported_feature, int):
|
|
||||||
return supported_feature
|
|
||||||
|
|
||||||
known_entity_features = _entity_features()
|
known_entity_features = _entity_features()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -144,6 +141,20 @@ def _validate_supported_feature(supported_feature: int | str) -> int:
|
|||||||
raise vol.Invalid(f"Unknown supported feature '{supported_feature}'") from exc
|
raise vol.Invalid(f"Unknown supported feature '{supported_feature}'") from exc
|
||||||
|
|
||||||
|
|
||||||
|
def _validate_supported_features(supported_features: int | list[str]) -> int:
|
||||||
|
"""Validate a supported feature and resolve an enum string to its value."""
|
||||||
|
|
||||||
|
if isinstance(supported_features, int):
|
||||||
|
return supported_features
|
||||||
|
|
||||||
|
feature_mask = 0
|
||||||
|
|
||||||
|
for supported_feature in supported_features:
|
||||||
|
feature_mask |= _validate_supported_feature(supported_feature)
|
||||||
|
|
||||||
|
return feature_mask
|
||||||
|
|
||||||
|
|
||||||
ENTITY_FILTER_SELECTOR_CONFIG_SCHEMA = vol.Schema(
|
ENTITY_FILTER_SELECTOR_CONFIG_SCHEMA = vol.Schema(
|
||||||
{
|
{
|
||||||
# Integration that provided the entity
|
# Integration that provided the entity
|
||||||
@ -153,7 +164,9 @@ ENTITY_FILTER_SELECTOR_CONFIG_SCHEMA = vol.Schema(
|
|||||||
# Device class of the entity
|
# Device class of the entity
|
||||||
vol.Optional("device_class"): vol.All(cv.ensure_list, [str]),
|
vol.Optional("device_class"): vol.All(cv.ensure_list, [str]),
|
||||||
# Features supported by the entity
|
# Features supported by the entity
|
||||||
vol.Optional("supported_features"): [vol.All(str, _validate_supported_feature)],
|
vol.Optional("supported_features"): [
|
||||||
|
vol.All(cv.ensure_list, [str], _validate_supported_features)
|
||||||
|
],
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -235,6 +235,22 @@ def test_device_selector_schema(schema, valid_selections, invalid_selections) ->
|
|||||||
("light.abc123", "blah.blah", FAKE_UUID),
|
("light.abc123", "blah.blah", FAKE_UUID),
|
||||||
(None,),
|
(None,),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
{
|
||||||
|
"filter": [
|
||||||
|
{
|
||||||
|
"supported_features": [
|
||||||
|
[
|
||||||
|
"light.LightEntityFeature.EFFECT",
|
||||||
|
"light.LightEntityFeature.TRANSITION",
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
("light.abc123", "blah.blah", FAKE_UUID),
|
||||||
|
(None,),
|
||||||
|
),
|
||||||
(
|
(
|
||||||
{
|
{
|
||||||
"filter": [
|
"filter": [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user