diff --git a/homeassistant/components/snips/__init__.py b/homeassistant/components/snips/__init__.py index 01471b13bc7..d4619fa3b3a 100644 --- a/homeassistant/components/snips/__init__.py +++ b/homeassistant/components/snips/__init__.py @@ -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.""" diff --git a/tests/components/snips/test_init.py b/tests/components/snips/test_init.py index 14e58d54ebe..9582c83b267 100644 --- a/tests/components/snips/test_init.py +++ b/tests/components/snips/test_init.py @@ -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(