mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Do not wait for mqtt at startup mqtt_statestream (#91721)
This commit is contained in:
parent
da26b0a930
commit
0552ec834d
@ -41,15 +41,6 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the MQTT state feed."""
|
"""Set up the MQTT state feed."""
|
||||||
# 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
|
|
||||||
|
|
||||||
conf: ConfigType = config[DOMAIN]
|
conf: ConfigType = config[DOMAIN]
|
||||||
publish_filter = convert_include_exclude_filter(conf)
|
publish_filter = convert_include_exclude_filter(conf)
|
||||||
base_topic: str = conf[CONF_BASE_TOPIC]
|
base_topic: str = conf[CONF_BASE_TOPIC]
|
||||||
|
@ -96,12 +96,19 @@ async def test_setup_and_stop_waits_for_ha(
|
|||||||
mqtt_mock.async_publish.assert_not_called()
|
mqtt_mock.async_publish.assert_not_called()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.xfail()
|
||||||
async def test_startup_no_mqtt(
|
async def test_startup_no_mqtt(
|
||||||
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
hass: HomeAssistant, caplog: pytest.LogCaptureFixture
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test startup without MQTT support."""
|
"""Test startup without MQTT support."""
|
||||||
assert not await add_statestream(hass, base_topic="pub")
|
e_id = "fake.entity"
|
||||||
assert "MQTT integration is not available" in caplog.text
|
|
||||||
|
assert await add_statestream(hass, base_topic="pub")
|
||||||
|
# Set a state of an entity
|
||||||
|
mock_state_change_event(hass, State(e_id, "on"))
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
assert "MQTT is not enabled" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_setup_succeeds_with_attributes(
|
async def test_setup_succeeds_with_attributes(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user