Skip to content

Commit

Permalink
Handle StopIteration error in select_source
Browse files Browse the repository at this point in the history
  • Loading branch information
hchris1 committed Dec 17, 2023
1 parent e9f98de commit 5dfabaf
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions custom_components/eversolo/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,14 @@ async def async_select_source(self, source):
if sources is None:
return

index, tag = next(
(index, key) for index, key in enumerate(sources) if sources[key] == source
)
try:
index, tag = next(
(index, key)
for index, key in enumerate(sources)
if sources[key] == source or key == source
)
except StopIteration:
raise ValueError(f"Source {source} not found")

await self.coordinator.client.async_set_input(index, tag)

Expand Down

0 comments on commit 5dfabaf

Please sign in to comment.