Wait for MQTT entry on snips integration startup (#81733)
Wait for MQTT integration to load
This commit is contained in:
parent
7801cd96de
commit
5c00b8b823
2 changed files with 25 additions and 0 deletions
|
@ -90,6 +90,14 @@ SERVICE_SCHEMA_FEEDBACK = vol.Schema(
|
|||
|
||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||
"""Activate Snips component."""
|
||||
# Make sure MQTT is available and the entry is loaded
|
||||
if not hass.config_entries.async_entries(
|
||||
mqtt.DOMAIN
|
||||
) or not await hass.config_entries.async_wait_component(
|
||||
hass.config_entries.async_entries(mqtt.DOMAIN)[0]
|
||||
):
|
||||
_LOGGER.error("MQTT integration is not available")
|
||||
return False
|
||||
|
||||
async def async_set_feedback(site_ids, state):
|
||||
"""Set Feedback sound state."""
|
||||
|
|
|
@ -28,6 +28,23 @@ async def test_snips_config(hass, mqtt_mock):
|
|||
assert result
|
||||
|
||||
|
||||
async def test_snips_no_mqtt(hass, caplog):
|
||||
"""Test Snips Config."""
|
||||
result = await async_setup_component(
|
||||
hass,
|
||||
"snips",
|
||||
{
|
||||
"snips": {
|
||||
"feedback_sounds": True,
|
||||
"probability_threshold": 0.5,
|
||||
"site_ids": ["default", "remote"],
|
||||
}
|
||||
},
|
||||
)
|
||||
assert not result
|
||||
assert "MQTT integration is not available" in caplog.text
|
||||
|
||||
|
||||
async def test_snips_bad_config(hass, mqtt_mock):
|
||||
"""Test Snips bad config."""
|
||||
result = await async_setup_component(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue