Adds support for hide_states options in state selector (#148959)

This commit is contained in:
Paul Bottein 2025-07-21 14:02:04 +02:00 committed by GitHub
parent bc0162cf85
commit 875219ccb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -1338,7 +1338,8 @@ class TargetSelectorConfig(BaseSelectorConfig, total=False):
class StateSelectorConfig(BaseSelectorConfig, total=False):
"""Class to represent an state selector config."""
entity_id: Required[str]
entity_id: str
hide_states: list[str]
@SELECTORS.register("state")
@ -1349,7 +1350,8 @@ class StateSelector(Selector[StateSelectorConfig]):
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
# configurable/exposed. We are considering separating state
# selectors into two types: one for state and one for attribute.

View File

@ -565,6 +565,11 @@ def test_time_selector_schema(schema, valid_selections, invalid_selections) -> N
("on", "armed"),
(None, True, 1),
),
(
{"hide_states": ["unknown", "unavailable"]},
(),
(),
),
],
)
def test_state_selector_schema(schema, valid_selections, invalid_selections) -> None: