mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +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,
|
DOMAIN,
|
||||||
AssistSatelliteEntityFeature,
|
AssistSatelliteEntityFeature,
|
||||||
)
|
)
|
||||||
|
from .entity import AssistSatelliteConfiguration
|
||||||
|
|
||||||
CONNECTION_TEST_TIMEOUT = 30
|
CONNECTION_TEST_TIMEOUT = 30
|
||||||
|
|
||||||
@ -91,7 +92,16 @@ def websocket_get_configuration(
|
|||||||
)
|
)
|
||||||
return
|
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["pipeline_entity_id"] = satellite.pipeline_entity_id
|
||||||
config_dict["vad_entity_id"] = satellite.vad_sensitivity_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(
|
async def test_set_wake_words(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
init_components: ConfigEntry,
|
init_components: ConfigEntry,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user