Skip to content

Commit

Permalink
Update services.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Aug 30, 2024
1 parent eef9ca4 commit c720aab
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 14 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/assist_satellite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
vol.All(
cv.make_entity_service_schema(
{
vol.Optional("text"): str,
vol.Optional("message"): str,
vol.Optional("media_id"): str,
}
),
cv.has_at_least_one_key("text", "media_id"),
cv.has_at_least_one_key("message", "media_id"),
),
"async_internal_announce",
[AssistSatelliteEntityFeature.ANNOUNCE],
Expand Down
14 changes: 7 additions & 7 deletions homeassistant/components/assist_satellite/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ def vad_sensitivity_entity_id(self) -> str | None:

async def async_internal_announce(
self,
text: str | None = None,
message: str | None = None,
media_id: str | None = None,
) -> None:
"""Play an announcement on the satellite.
If media_id is not provided, text is synthesized to
If media_id is not provided, message is synthesized to
audio with the selected pipeline.
Calls async_announce with media id.
"""
if text is None:
text = ""
if message is None:
message = ""

if not media_id:
# Synthesize audio and get URL
Expand All @@ -87,7 +87,7 @@ async def async_internal_announce(

media_id = tts_generate_media_source_id(
self.hass,
text,
message,
engine=pipeline.tts_engine,
language=pipeline.tts_language,
options=tts_options,
Expand All @@ -111,11 +111,11 @@ async def async_internal_announce(

try:
# Block until announcement is finished
await self.async_announce(text, media_id)
await self.async_announce(message, media_id)
finally:
self._is_announcing = False

async def async_announce(self, text: str, media_id: str) -> None:
async def async_announce(self, message: str, media_id: str) -> None:
"""Announce media on the satellite.
Should block until the announcement is done playing.
Expand Down
9 changes: 8 additions & 1 deletion homeassistant/components/assist_satellite/icons.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"entity_component": {
"_": {
"default": "mdi:account-voice"
}
},
"services": {
"announce": "mdi:bullhorn"
"announce": {
"service": "mdi:bullhorn"
}
}
}
4 changes: 2 additions & 2 deletions homeassistant/components/assist_satellite/services.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
play_media:
announce:
target:
entity:
domain: assist_satellite
supported_features:
- assist_satellite.AssistSatelliteEntityFeature.ANNOUNCE
fields:
text:
message:
required: false
example: "Time to wake up!"
selector:
Expand Down
17 changes: 17 additions & 0 deletions homeassistant/components/assist_satellite/strings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"title": "Assist satellite",
"entity_component": {
"_": {
"name": "Assist satellite",
Expand All @@ -9,5 +10,21 @@
"processing": "Processing"
}
}
},
"services": {
"announce": {
"name": "Announce",
"description": "Let the satellite announce a message.",
"fields": {
"message": {
"name": "Message",
"description": "The message to announce."
},
"media_id": {
"name": "Media ID",
"description": "The media ID to announce instead of using text-to-speech."
}
}
}
}
}
4 changes: 2 additions & 2 deletions tests/components/assist_satellite/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ async def test_entity_state(
("service_data", "expected_params"),
[
(
{"text": "Hello"},
{"message": "Hello"},
("Hello", "https://www.home-assistant.io/resolved.mp3"),
),
(
{
"text": "Hello",
"message": "Hello",
"media_id": "http://example.com/bla.mp3",
},
("Hello", "http://example.com/bla.mp3"),
Expand Down

0 comments on commit c720aab

Please sign in to comment.