mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Add preannounce boolean for announce/start conversation (#141930)
* Add preannounce boolean * Fix disabling preannounce in wizard * Fix casing * Fix type of preannounce_media_id * Adjust description of preannounce_media_id
This commit is contained in:
parent
ef989160af
commit
28dbf6e3dc
@ -60,7 +60,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
{
|
{
|
||||||
vol.Optional("message"): str,
|
vol.Optional("message"): str,
|
||||||
vol.Optional("media_id"): str,
|
vol.Optional("media_id"): str,
|
||||||
vol.Optional("preannounce_media_id"): vol.Any(str, None),
|
vol.Optional("preannounce"): bool,
|
||||||
|
vol.Optional("preannounce_media_id"): str,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
cv.has_at_least_one_key("message", "media_id"),
|
cv.has_at_least_one_key("message", "media_id"),
|
||||||
@ -75,7 +76,8 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
|||||||
{
|
{
|
||||||
vol.Optional("start_message"): str,
|
vol.Optional("start_message"): str,
|
||||||
vol.Optional("start_media_id"): str,
|
vol.Optional("start_media_id"): str,
|
||||||
vol.Optional("preannounce_media_id"): vol.Any(str, None),
|
vol.Optional("preannounce"): bool,
|
||||||
|
vol.Optional("preannounce_media_id"): str,
|
||||||
vol.Optional("extra_system_prompt"): str,
|
vol.Optional("extra_system_prompt"): str,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
@ -180,7 +180,8 @@ class AssistSatelliteEntity(entity.Entity):
|
|||||||
self,
|
self,
|
||||||
message: str | None = None,
|
message: str | None = None,
|
||||||
media_id: str | None = None,
|
media_id: str | None = None,
|
||||||
preannounce_media_id: str | None = PREANNOUNCE_URL,
|
preannounce: bool = True,
|
||||||
|
preannounce_media_id: str = PREANNOUNCE_URL,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Play and show an announcement on the satellite.
|
"""Play and show an announcement on the satellite.
|
||||||
|
|
||||||
@ -190,8 +191,8 @@ class AssistSatelliteEntity(entity.Entity):
|
|||||||
If media_id is provided, it is played directly. It is possible
|
If media_id is provided, it is played directly. It is possible
|
||||||
to omit the message and the satellite will not show any text.
|
to omit the message and the satellite will not show any text.
|
||||||
|
|
||||||
|
If preannounce is True, a sound is played before the announcement.
|
||||||
If preannounce_media_id is provided, it overrides the default sound.
|
If preannounce_media_id is provided, it overrides the default sound.
|
||||||
If preannounce_media_id is None, no sound is played.
|
|
||||||
|
|
||||||
Calls async_announce with message and media id.
|
Calls async_announce with message and media id.
|
||||||
"""
|
"""
|
||||||
@ -201,7 +202,9 @@ class AssistSatelliteEntity(entity.Entity):
|
|||||||
message = ""
|
message = ""
|
||||||
|
|
||||||
announcement = await self._resolve_announcement_media_id(
|
announcement = await self._resolve_announcement_media_id(
|
||||||
message, media_id, preannounce_media_id
|
message,
|
||||||
|
media_id,
|
||||||
|
preannounce_media_id=preannounce_media_id if preannounce else None,
|
||||||
)
|
)
|
||||||
|
|
||||||
if self._is_announcing:
|
if self._is_announcing:
|
||||||
@ -229,7 +232,8 @@ class AssistSatelliteEntity(entity.Entity):
|
|||||||
start_message: str | None = None,
|
start_message: str | None = None,
|
||||||
start_media_id: str | None = None,
|
start_media_id: str | None = None,
|
||||||
extra_system_prompt: str | None = None,
|
extra_system_prompt: str | None = None,
|
||||||
preannounce_media_id: str | None = PREANNOUNCE_URL,
|
preannounce: bool = True,
|
||||||
|
preannounce_media_id: str = PREANNOUNCE_URL,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Start a conversation from the satellite.
|
"""Start a conversation from the satellite.
|
||||||
|
|
||||||
@ -239,8 +243,8 @@ class AssistSatelliteEntity(entity.Entity):
|
|||||||
If start_media_id is provided, it is played directly. It is possible
|
If start_media_id is provided, it is played directly. It is possible
|
||||||
to omit the message and the satellite will not show any text.
|
to omit the message and the satellite will not show any text.
|
||||||
|
|
||||||
If preannounce_media_id is provided, it is played before the announcement.
|
If preannounce is True, a sound is played before the start message or media.
|
||||||
If preannounce_media_id is None, no sound is played.
|
If preannounce_media_id is provided, it overrides the default sound.
|
||||||
|
|
||||||
Calls async_start_conversation.
|
Calls async_start_conversation.
|
||||||
"""
|
"""
|
||||||
@ -257,7 +261,9 @@ class AssistSatelliteEntity(entity.Entity):
|
|||||||
start_message = ""
|
start_message = ""
|
||||||
|
|
||||||
announcement = await self._resolve_announcement_media_id(
|
announcement = await self._resolve_announcement_media_id(
|
||||||
start_message, start_media_id, preannounce_media_id
|
start_message,
|
||||||
|
start_media_id,
|
||||||
|
preannounce_media_id=preannounce_media_id if preannounce else None,
|
||||||
)
|
)
|
||||||
|
|
||||||
if self._is_announcing:
|
if self._is_announcing:
|
||||||
|
@ -15,6 +15,11 @@ announce:
|
|||||||
required: false
|
required: false
|
||||||
selector:
|
selector:
|
||||||
text:
|
text:
|
||||||
|
preannounce:
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
|
selector:
|
||||||
|
boolean:
|
||||||
preannounce_media_id:
|
preannounce_media_id:
|
||||||
required: false
|
required: false
|
||||||
selector:
|
selector:
|
||||||
@ -40,6 +45,11 @@ start_conversation:
|
|||||||
required: false
|
required: false
|
||||||
selector:
|
selector:
|
||||||
text:
|
text:
|
||||||
|
preannounce:
|
||||||
|
required: false
|
||||||
|
default: true
|
||||||
|
selector:
|
||||||
|
boolean:
|
||||||
preannounce_media_id:
|
preannounce_media_id:
|
||||||
required: false
|
required: false
|
||||||
selector:
|
selector:
|
||||||
|
@ -24,9 +24,13 @@
|
|||||||
"name": "Media ID",
|
"name": "Media ID",
|
||||||
"description": "The media ID to announce instead of using text-to-speech."
|
"description": "The media ID to announce instead of using text-to-speech."
|
||||||
},
|
},
|
||||||
|
"preannounce": {
|
||||||
|
"name": "Preannounce",
|
||||||
|
"description": "Play a sound before the announcement."
|
||||||
|
},
|
||||||
"preannounce_media_id": {
|
"preannounce_media_id": {
|
||||||
"name": "Preannounce Media ID",
|
"name": "Preannounce media ID",
|
||||||
"description": "The media ID to play before the announcement."
|
"description": "Custom media ID to play before the announcement."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -46,9 +50,13 @@
|
|||||||
"name": "Extra system prompt",
|
"name": "Extra system prompt",
|
||||||
"description": "Provide background information to the AI about the request."
|
"description": "Provide background information to the AI about the request."
|
||||||
},
|
},
|
||||||
|
"preannounce": {
|
||||||
|
"name": "Preannounce",
|
||||||
|
"description": "Play a sound before the start message or media."
|
||||||
|
},
|
||||||
"preannounce_media_id": {
|
"preannounce_media_id": {
|
||||||
"name": "Preannounce Media ID",
|
"name": "Preannounce media ID",
|
||||||
"description": "The media ID to play before the start message or media."
|
"description": "Custom media ID to play before the start message or media."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ async def websocket_test_connection(
|
|||||||
hass.async_create_background_task(
|
hass.async_create_background_task(
|
||||||
satellite.async_internal_announce(
|
satellite.async_internal_announce(
|
||||||
media_id=f"{CONNECTION_TEST_URL_BASE}/{connection_id}",
|
media_id=f"{CONNECTION_TEST_URL_BASE}/{connection_id}",
|
||||||
preannounce_media_id=None,
|
preannounce=False,
|
||||||
),
|
),
|
||||||
f"assist_satellite_connection_test_{msg['entity_id']}",
|
f"assist_satellite_connection_test_{msg['entity_id']}",
|
||||||
)
|
)
|
||||||
|
@ -186,7 +186,7 @@ async def test_new_pipeline_cancels_pipeline(
|
|||||||
("service_data", "expected_params"),
|
("service_data", "expected_params"),
|
||||||
[
|
[
|
||||||
(
|
(
|
||||||
{"message": "Hello", "preannounce_media_id": None},
|
{"message": "Hello", "preannounce": False},
|
||||||
AssistSatelliteAnnouncement(
|
AssistSatelliteAnnouncement(
|
||||||
message="Hello",
|
message="Hello",
|
||||||
media_id="http://10.10.10.10:8123/api/tts_proxy/test-token",
|
media_id="http://10.10.10.10:8123/api/tts_proxy/test-token",
|
||||||
@ -199,7 +199,7 @@ async def test_new_pipeline_cancels_pipeline(
|
|||||||
{
|
{
|
||||||
"message": "Hello",
|
"message": "Hello",
|
||||||
"media_id": "media-source://given",
|
"media_id": "media-source://given",
|
||||||
"preannounce_media_id": None,
|
"preannounce": False,
|
||||||
},
|
},
|
||||||
AssistSatelliteAnnouncement(
|
AssistSatelliteAnnouncement(
|
||||||
message="Hello",
|
message="Hello",
|
||||||
@ -210,7 +210,7 @@ async def test_new_pipeline_cancels_pipeline(
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
{"media_id": "http://example.com/bla.mp3", "preannounce_media_id": None},
|
{"media_id": "http://example.com/bla.mp3", "preannounce": False},
|
||||||
AssistSatelliteAnnouncement(
|
AssistSatelliteAnnouncement(
|
||||||
message="",
|
message="",
|
||||||
media_id="http://example.com/bla.mp3",
|
media_id="http://example.com/bla.mp3",
|
||||||
@ -541,7 +541,7 @@ async def test_vad_sensitivity_entity_not_found(
|
|||||||
{
|
{
|
||||||
"start_message": "Hello",
|
"start_message": "Hello",
|
||||||
"extra_system_prompt": "Better system prompt",
|
"extra_system_prompt": "Better system prompt",
|
||||||
"preannounce_media_id": None,
|
"preannounce": False,
|
||||||
},
|
},
|
||||||
(
|
(
|
||||||
"mock-conversation-id",
|
"mock-conversation-id",
|
||||||
@ -559,7 +559,7 @@ async def test_vad_sensitivity_entity_not_found(
|
|||||||
{
|
{
|
||||||
"start_message": "Hello",
|
"start_message": "Hello",
|
||||||
"start_media_id": "media-source://given",
|
"start_media_id": "media-source://given",
|
||||||
"preannounce_media_id": None,
|
"preannounce": False,
|
||||||
},
|
},
|
||||||
(
|
(
|
||||||
"mock-conversation-id",
|
"mock-conversation-id",
|
||||||
@ -576,7 +576,7 @@ async def test_vad_sensitivity_entity_not_found(
|
|||||||
(
|
(
|
||||||
{
|
{
|
||||||
"start_media_id": "http://example.com/given.mp3",
|
"start_media_id": "http://example.com/given.mp3",
|
||||||
"preannounce_media_id": None,
|
"preannounce": False,
|
||||||
},
|
},
|
||||||
(
|
(
|
||||||
"mock-conversation-id",
|
"mock-conversation-id",
|
||||||
|
@ -1221,7 +1221,7 @@ async def test_announce_message(
|
|||||||
{
|
{
|
||||||
"entity_id": satellite.entity_id,
|
"entity_id": satellite.entity_id,
|
||||||
"message": "test-text",
|
"message": "test-text",
|
||||||
"preannounce_media_id": None,
|
"preannounce": False,
|
||||||
},
|
},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
@ -1311,7 +1311,7 @@ async def test_announce_media_id(
|
|||||||
{
|
{
|
||||||
"entity_id": satellite.entity_id,
|
"entity_id": satellite.entity_id,
|
||||||
"media_id": "https://www.home-assistant.io/resolved.mp3",
|
"media_id": "https://www.home-assistant.io/resolved.mp3",
|
||||||
"preannounce_media_id": None,
|
"preannounce": False,
|
||||||
},
|
},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
@ -1522,7 +1522,7 @@ async def test_start_conversation_message(
|
|||||||
{
|
{
|
||||||
"entity_id": satellite.entity_id,
|
"entity_id": satellite.entity_id,
|
||||||
"start_message": "test-text",
|
"start_message": "test-text",
|
||||||
"preannounce_media_id": None,
|
"preannounce": False,
|
||||||
},
|
},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
@ -1631,7 +1631,7 @@ async def test_start_conversation_media_id(
|
|||||||
{
|
{
|
||||||
"entity_id": satellite.entity_id,
|
"entity_id": satellite.entity_id,
|
||||||
"start_media_id": "https://www.home-assistant.io/resolved.mp3",
|
"start_media_id": "https://www.home-assistant.io/resolved.mp3",
|
||||||
"preannounce_media_id": None,
|
"preannounce": False,
|
||||||
},
|
},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user