Skip to content

Commit

Permalink
Fix issue with matching on none mass players (#3236)
Browse files Browse the repository at this point in the history
  • Loading branch information
jozefKruszynski authored Nov 27, 2024
1 parent 1900922 commit 669d261
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions custom_components/mass/intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

from . import DOMAIN
from .const import (
ATTR_MASS_PLAYER_TYPE,
CONF_OPENAI_AGENT_ID,
ATTR_MEDIA_ID,
ATTR_MEDIA_TYPE,
Expand Down Expand Up @@ -145,16 +146,19 @@ async def _get_media_items(
async def _get_matched_state(
self, intent_obj: intent.Intent, match_constraints: MatchTargetsConstraints
) -> State:
match_result = intent.async_match_targets(
intent_obj.hass,
match_constraints,
)
match_result = intent.async_match_targets(intent_obj.hass, match_constraints)
if not match_result.is_match:
raise MatchFailedError(
result=match_result,
constraints=match_constraints,
)
return match_result.states[0]
raise MatchFailedError(result=match_result, constraints=match_constraints)

potential_states = [
state
for state in match_result.states
if state.attributes.get(ATTR_MASS_PLAYER_TYPE)
]

if not potential_states:
raise MatchFailedError(result=match_result, constraints=match_constraints)
return potential_states[0]

slot_schema = {
vol.Optional(NAME_SLOT): cv.string,
Expand Down

0 comments on commit 669d261

Please sign in to comment.