mirror of
https://github.com/home-assistant/core.git
synced 2025-07-28 07:37:34 +00:00
Adds support for hide_states options in state selector (#148959)
This commit is contained in:
parent
bc0162cf85
commit
875219ccb5
@ -1338,7 +1338,8 @@ class TargetSelectorConfig(BaseSelectorConfig, total=False):
|
|||||||
class StateSelectorConfig(BaseSelectorConfig, total=False):
|
class StateSelectorConfig(BaseSelectorConfig, total=False):
|
||||||
"""Class to represent an state selector config."""
|
"""Class to represent an state selector config."""
|
||||||
|
|
||||||
entity_id: Required[str]
|
entity_id: str
|
||||||
|
hide_states: list[str]
|
||||||
|
|
||||||
|
|
||||||
@SELECTORS.register("state")
|
@SELECTORS.register("state")
|
||||||
@ -1349,7 +1350,8 @@ class StateSelector(Selector[StateSelectorConfig]):
|
|||||||
|
|
||||||
CONFIG_SCHEMA = BASE_SELECTOR_CONFIG_SCHEMA.extend(
|
CONFIG_SCHEMA = BASE_SELECTOR_CONFIG_SCHEMA.extend(
|
||||||
{
|
{
|
||||||
vol.Required("entity_id"): cv.entity_id,
|
vol.Optional("entity_id"): cv.entity_id,
|
||||||
|
vol.Optional("hide_states"): [str],
|
||||||
# The attribute to filter on, is currently deliberately not
|
# The attribute to filter on, is currently deliberately not
|
||||||
# configurable/exposed. We are considering separating state
|
# configurable/exposed. We are considering separating state
|
||||||
# selectors into two types: one for state and one for attribute.
|
# selectors into two types: one for state and one for attribute.
|
||||||
|
@ -565,6 +565,11 @@ def test_time_selector_schema(schema, valid_selections, invalid_selections) -> N
|
|||||||
("on", "armed"),
|
("on", "armed"),
|
||||||
(None, True, 1),
|
(None, True, 1),
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
{"hide_states": ["unknown", "unavailable"]},
|
||||||
|
(),
|
||||||
|
(),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
def test_state_selector_schema(schema, valid_selections, invalid_selections) -> None:
|
def test_state_selector_schema(schema, valid_selections, invalid_selections) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user