mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
VoIP block non-TTS announcements (#139658)
* VoIP block non-TTS announcements * Migrate VoIP to use pipeline token
This commit is contained in:
parent
d5ba55d2fc
commit
8a97c2bfca
@ -28,6 +28,7 @@ from homeassistant.components.assist_satellite import (
|
|||||||
from homeassistant.components.network import async_get_source_ip
|
from homeassistant.components.network import async_get_source_ip
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.core import Context, HomeAssistant, callback
|
from homeassistant.core import Context, HomeAssistant, callback
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -193,6 +194,12 @@ class VoipAssistSatellite(VoIPEntity, AssistSatelliteEntity, RtpDatagramProtocol
|
|||||||
|
|
||||||
Optionally run a voice pipeline after the announcement has finished.
|
Optionally run a voice pipeline after the announcement has finished.
|
||||||
"""
|
"""
|
||||||
|
if announcement.media_id_source != "tts":
|
||||||
|
raise HomeAssistantError(
|
||||||
|
translation_domain=DOMAIN,
|
||||||
|
translation_key="non_tts_announcement",
|
||||||
|
)
|
||||||
|
|
||||||
self._announcement_future = asyncio.Future()
|
self._announcement_future = asyncio.Future()
|
||||||
self._run_pipeline_after_announce = run_pipeline_after
|
self._run_pipeline_after_announce = run_pipeline_after
|
||||||
|
|
||||||
|
@ -58,5 +58,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"exceptions": {
|
||||||
|
"non_tts_announcement": {
|
||||||
|
"message": "VoIP does not currently support non-TTS announcements"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ from homeassistant.components.voip.devices import VoIPDevice, VoIPDevices
|
|||||||
from homeassistant.components.voip.voip import PreRecordMessageProtocol, make_protocol
|
from homeassistant.components.voip.voip import PreRecordMessageProtocol, make_protocol
|
||||||
from homeassistant.const import STATE_OFF, STATE_ON, Platform
|
from homeassistant.const import STATE_OFF, STATE_ON, Platform
|
||||||
from homeassistant.core import Context, HomeAssistant
|
from homeassistant.core import Context, HomeAssistant
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
from homeassistant.helpers.entity_component import EntityComponent
|
from homeassistant.helpers.entity_component import EntityComponent
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
@ -862,6 +863,19 @@ async def test_announce(
|
|||||||
& assist_satellite.AssistSatelliteEntityFeature.ANNOUNCE
|
& assist_satellite.AssistSatelliteEntityFeature.ANNOUNCE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
with pytest.raises(HomeAssistantError) as err:
|
||||||
|
await hass.services.async_call(
|
||||||
|
"assist_satellite",
|
||||||
|
"announce",
|
||||||
|
service_data={"media_id": "http://example.com"},
|
||||||
|
blocking=True,
|
||||||
|
target={
|
||||||
|
"entity_id": satellite.entity_id,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
assert err.value.translation_domain == "voip"
|
||||||
|
assert err.value.translation_key == "non_tts_announcement"
|
||||||
|
|
||||||
announcement = assist_satellite.AssistSatelliteAnnouncement(
|
announcement = assist_satellite.AssistSatelliteAnnouncement(
|
||||||
message="test announcement",
|
message="test announcement",
|
||||||
media_id=_MEDIA_ID,
|
media_id=_MEDIA_ID,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user