@@ -1776,6 +1776,78 @@ async def test_get_set_configuration(
17761776 assert satellite .async_get_configuration () == updated_config
17771777
17781778
1779+ async def test_intent_progress_optimization (
1780+ hass : HomeAssistant ,
1781+ mock_client : APIClient ,
1782+ mock_esphome_device : MockESPHomeDeviceType ,
1783+ ) -> None :
1784+ """Test that intent progress events are only sent when early TTS streaming is available."""
1785+ mock_device = await mock_esphome_device (
1786+ mock_client = mock_client ,
1787+ device_info = {
1788+ "voice_assistant_feature_flags" : VoiceAssistantFeature .VOICE_ASSISTANT
1789+ },
1790+ )
1791+ await hass .async_block_till_done ()
1792+
1793+ satellite = get_satellite_entity (hass , mock_device .device_info .mac_address )
1794+ assert satellite is not None
1795+
1796+ # Test that intent progress without tts_start_streaming is not sent
1797+ mock_client .send_voice_assistant_event .reset_mock ()
1798+ satellite .on_pipeline_event (
1799+ PipelineEvent (
1800+ type = PipelineEventType .INTENT_PROGRESS ,
1801+ data = {"some_other_key" : "value" },
1802+ )
1803+ )
1804+ mock_client .send_voice_assistant_event .assert_not_called ()
1805+
1806+ # Test that intent progress with tts_start_streaming=False is not sent
1807+ satellite .on_pipeline_event (
1808+ PipelineEvent (
1809+ type = PipelineEventType .INTENT_PROGRESS ,
1810+ data = {"tts_start_streaming" : False },
1811+ )
1812+ )
1813+ mock_client .send_voice_assistant_event .assert_not_called ()
1814+
1815+ # Test that intent progress with tts_start_streaming=True is sent
1816+ satellite .on_pipeline_event (
1817+ PipelineEvent (
1818+ type = PipelineEventType .INTENT_PROGRESS ,
1819+ data = {"tts_start_streaming" : True },
1820+ )
1821+ )
1822+ assert mock_client .send_voice_assistant_event .call_args_list [- 1 ].args == (
1823+ VoiceAssistantEventType .VOICE_ASSISTANT_INTENT_PROGRESS ,
1824+ {"tts_start_streaming" : "1" },
1825+ )
1826+
1827+ # Test that intent progress with tts_start_streaming as string "1" is sent
1828+ mock_client .send_voice_assistant_event .reset_mock ()
1829+ satellite .on_pipeline_event (
1830+ PipelineEvent (
1831+ type = PipelineEventType .INTENT_PROGRESS ,
1832+ data = {"tts_start_streaming" : "1" },
1833+ )
1834+ )
1835+ assert mock_client .send_voice_assistant_event .call_args_list [- 1 ].args == (
1836+ VoiceAssistantEventType .VOICE_ASSISTANT_INTENT_PROGRESS ,
1837+ {"tts_start_streaming" : "1" },
1838+ )
1839+
1840+ # Test that intent progress with no data is *not* sent
1841+ mock_client .send_voice_assistant_event .reset_mock ()
1842+ satellite .on_pipeline_event (
1843+ PipelineEvent (
1844+ type = PipelineEventType .INTENT_PROGRESS ,
1845+ data = None ,
1846+ )
1847+ )
1848+ mock_client .send_voice_assistant_event .assert_not_called ()
1849+
1850+
17791851async def test_wake_word_select (
17801852 hass : HomeAssistant ,
17811853 mock_client : APIClient ,
0 commit comments