Fix Wyoming satellite crash when TTS is not configured (#171513)

This commit is contained in:
Franck Nijhof
2026-05-20 14:30:20 +02:00
committed by GitHub
parent 6a20b99252
commit a144bbab2b
2 changed files with 52 additions and 1 deletions
@@ -193,7 +193,7 @@ class WyomingAssistSatellite(WyomingSatelliteEntity, AssistSatelliteEntity):
return
if event.type == assist_pipeline.PipelineEventType.RUN_START:
if event.data and (tts_output := event.data["tts_output"]):
if event.data and (tts_output := event.data.get("tts_output")):
# Get stream token early.
# If "tts_start_streaming" is True in INTENT_PROGRESS event, we
# can start streaming TTS before the TTS_END event.
@@ -817,6 +817,57 @@ async def test_on_pipeline_event_ignores_disconnected_client(
assert not mock_client.error_event.is_set()
async def test_run_start_without_tts(
hass: HomeAssistant,
) -> None:
"""Test RUN_START event without tts_output does not crash.
Regression test for https://github.com/home-assistant/core/issues/165734
"""
events: list[Event] = [
RunPipeline(
start_stage=PipelineStage.WAKE, end_stage=PipelineStage.TTS
).event(),
]
pipeline_event = asyncio.Event()
def _async_pipeline_from_audio_stream(*args: Any, **kwargs: Any) -> None:
pipeline_event.set()
with (
patch(
"homeassistant.components.wyoming.data.load_wyoming_info",
return_value=SATELLITE_INFO,
),
patch(
"homeassistant.components.wyoming.assist_satellite.AsyncTcpClient",
SatelliteAsyncTcpClient(events),
) as mock_client,
patch(
"homeassistant.components.assist_satellite.entity.async_pipeline_from_audio_stream",
wraps=_async_pipeline_from_audio_stream,
) as mock_run_pipeline,
):
await setup_config_entry(hass)
async with asyncio.timeout(1):
await pipeline_event.wait()
await mock_client.connect_event.wait()
await mock_client.run_satellite_event.wait()
event_callback = mock_run_pipeline.call_args.kwargs["event_callback"]
# Fire RUN_START without tts_output (TTS not configured)
# must not raise KeyError
event_callback(
assist_pipeline.PipelineEvent(
assist_pipeline.PipelineEventType.RUN_START,
{"pipeline": "test", "language": "en"},
)
)
async def test_announce_raises_when_client_disconnected(
hass: HomeAssistant,
) -> None: