Skip to content

Fix supported features in Assist Satellite #148561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions homeassistant/components/assist_satellite/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ ask_question:
required: true
selector:
entity:
domain: assist_satellite
supported_features:
- assist_satellite.AssistSatelliteEntityFeature.START_CONVERSATION
filter:
- domain: assist_satellite
supported_features:
- 2 # assist_satellite.AssistSatelliteEntityFeature.START_CONVERSATION
question:
required: false
example: "What kind of music would you like to play?"
Expand Down
7 changes: 2 additions & 5 deletions homeassistant/helpers/selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,9 @@ def _validate_supported_feature(supported_feature: str) -> int:
raise vol.Invalid(f"Unknown supported feature '{supported_feature}'") from exc


def _validate_supported_features(supported_features: int | list[str]) -> int:
def _validate_supported_features(supported_features: 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:
Expand Down Expand Up @@ -154,7 +151,7 @@ class BaseSelectorConfig(TypedDict, total=False):
vol.Optional("device_class"): vol.All(cv.ensure_list, [str]),
# Features supported by the entity
vol.Optional("supported_features"): [
vol.All(cv.ensure_list, [str], _validate_supported_features)
vol.Any(int, vol.All(cv.ensure_list, [str], _validate_supported_features))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we accept integers and not rely on _validate_supported_features resolving it?

Copy link
Contributor Author

@arturpragacz arturpragacz Jul 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is run in two different contexts:

  • It is run fully offline by hassfest.
  • It is run in a much more limited fashion during runtime.

So as a result this check (and therefore translation of feature names) is run and does work for a target selector, but it is not run for other fields, in particular for any entity selectors.

Entity selectors are quite rare though, the only ones with supported features and therefore affected by this bug are this one and ai_task.generate_data. So the idea of this fix is to allow manually putting ints and use them for those two services.

An alternative fix would be to run the check fully for all fields for all services also during runtime. Yet another alternative would be to switch those two affected services to use a target selector.

],
}
)
Expand Down
2 changes: 0 additions & 2 deletions tests/helpers/test_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,6 @@ def test_entity_selector_schema(schema, valid_selections, invalid_selections) ->
@pytest.mark.parametrize(
"schema",
[
# Feature should be string specifying an enum member, not an int
{"filter": [{"supported_features": [1]}]},
# Invalid feature
{"filter": [{"supported_features": ["blah"]}]},
# Unknown feature enum
Expand Down
Loading