mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Prevent voice wizard from crashing for wyoming/voip (#138547)
* Prevent voice wizard from crashing for wyoming/voip * Use stub configuration in websocket API
This commit is contained in:
parent
28dd44504e
commit
e16343ed72
@ -19,6 +19,7 @@ from .const import (
|
||||
DOMAIN,
|
||||
AssistSatelliteEntityFeature,
|
||||
)
|
||||
from .entity import AssistSatelliteConfiguration
|
||||
|
||||
CONNECTION_TEST_TIMEOUT = 30
|
||||
|
||||
@ -91,7 +92,16 @@ def websocket_get_configuration(
|
||||
)
|
||||
return
|
||||
|
||||
config_dict = asdict(satellite.async_get_configuration())
|
||||
try:
|
||||
config_dict = asdict(satellite.async_get_configuration())
|
||||
except NotImplementedError:
|
||||
# Stub configuration
|
||||
config_dict = asdict(
|
||||
AssistSatelliteConfiguration(
|
||||
available_wake_words=[], active_wake_words=[], max_active_wake_words=1
|
||||
)
|
||||
)
|
||||
|
||||
config_dict["pipeline_entity_id"] = satellite.pipeline_entity_id
|
||||
config_dict["vad_entity_id"] = satellite.vad_sensitivity_entity_id
|
||||
|
||||
|
@ -313,6 +313,37 @@ async def test_get_configuration(
|
||||
}
|
||||
|
||||
|
||||
async def test_get_configuration_not_implemented(
|
||||
hass: HomeAssistant,
|
||||
init_components: ConfigEntry,
|
||||
entity: MockAssistSatellite,
|
||||
hass_ws_client: WebSocketGenerator,
|
||||
) -> None:
|
||||
"""Test getting stub satellite configuration when the entity doesn't implement the method."""
|
||||
ws_client = await hass_ws_client(hass)
|
||||
|
||||
with patch.object(
|
||||
entity, "async_get_configuration", side_effect=NotImplementedError()
|
||||
):
|
||||
await ws_client.send_json_auto_id(
|
||||
{
|
||||
"type": "assist_satellite/get_configuration",
|
||||
"entity_id": ENTITY_ID,
|
||||
}
|
||||
)
|
||||
msg = await ws_client.receive_json()
|
||||
assert msg["success"]
|
||||
|
||||
# Stub configuration
|
||||
assert msg["result"] == {
|
||||
"active_wake_words": [],
|
||||
"available_wake_words": [],
|
||||
"max_active_wake_words": 1,
|
||||
"pipeline_entity_id": None,
|
||||
"vad_entity_id": None,
|
||||
}
|
||||
|
||||
|
||||
async def test_set_wake_words(
|
||||
hass: HomeAssistant,
|
||||
init_components: ConfigEntry,
|
||||
|
Loading…
x
Reference in New Issue
Block a user