mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 17:27:10 +00:00
Set responding state in assist satellite announcements (#125632)
Set responding state in announcements
This commit is contained in:
parent
06e83340e8
commit
bd5892f2a6
@ -169,12 +169,14 @@ class AssistSatelliteEntity(entity.Entity):
|
|||||||
raise SatelliteBusyError
|
raise SatelliteBusyError
|
||||||
|
|
||||||
self._is_announcing = True
|
self._is_announcing = True
|
||||||
|
self._set_state(AssistSatelliteState.RESPONDING)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Block until announcement is finished
|
# Block until announcement is finished
|
||||||
await self.async_announce(message, media_id)
|
await self.async_announce(message, media_id)
|
||||||
finally:
|
finally:
|
||||||
self._is_announcing = False
|
self._is_announcing = False
|
||||||
|
self.tts_response_finished()
|
||||||
|
|
||||||
async def async_announce(self, message: str, media_id: str) -> None:
|
async def async_announce(self, message: str, media_id: str) -> None:
|
||||||
"""Announce media on the satellite.
|
"""Announce media on the satellite.
|
||||||
|
@ -129,10 +129,33 @@ async def test_announce(
|
|||||||
tts_voice="test-voice",
|
tts_voice="test-voice",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
entity._attr_tts_options = {"test-option": "test-value"}
|
||||||
|
|
||||||
|
original_announce = entity.async_announce
|
||||||
|
announce_started = asyncio.Event()
|
||||||
|
|
||||||
|
async def async_announce(message, media_id):
|
||||||
|
# Verify state change
|
||||||
|
assert entity.state == AssistSatelliteState.RESPONDING
|
||||||
|
await original_announce(message, media_id)
|
||||||
|
announce_started.set()
|
||||||
|
|
||||||
|
def tts_generate_media_source_id(
|
||||||
|
hass: HomeAssistant,
|
||||||
|
message: str,
|
||||||
|
engine: str | None = None,
|
||||||
|
language: str | None = None,
|
||||||
|
options: dict | None = None,
|
||||||
|
cache: bool | None = None,
|
||||||
|
):
|
||||||
|
# Check that TTS options are passed here
|
||||||
|
assert options == {"test-option": "test-value", "voice": "test-voice"}
|
||||||
|
return "media-source://bla"
|
||||||
|
|
||||||
with (
|
with (
|
||||||
patch(
|
patch(
|
||||||
"homeassistant.components.assist_satellite.entity.tts_generate_media_source_id",
|
"homeassistant.components.assist_satellite.entity.tts_generate_media_source_id",
|
||||||
return_value="media-source://bla",
|
new=tts_generate_media_source_id,
|
||||||
),
|
),
|
||||||
patch(
|
patch(
|
||||||
"homeassistant.components.media_source.async_resolve_media",
|
"homeassistant.components.media_source.async_resolve_media",
|
||||||
@ -141,6 +164,7 @@ async def test_announce(
|
|||||||
mime_type="audio/mp3",
|
mime_type="audio/mp3",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
patch.object(entity, "async_announce", new=async_announce),
|
||||||
):
|
):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
"assist_satellite",
|
"assist_satellite",
|
||||||
@ -149,6 +173,7 @@ async def test_announce(
|
|||||||
target={"entity_id": "assist_satellite.test_entity"},
|
target={"entity_id": "assist_satellite.test_entity"},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
assert entity.state == AssistSatelliteState.LISTENING_WAKE_WORD
|
||||||
|
|
||||||
assert entity.announcements[0] == expected_params
|
assert entity.announcements[0] == expected_params
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user