Gracefully disconnect MQTT entry if entry is reloaded (#119753)

This commit is contained in:
Jan Bouwhuis
2024-06-18 09:29:22 +02:00
committed by GitHub
parent 67223b2a2d
commit 6eb9d1e01d
3 changed files with 17 additions and 6 deletions

View File

@ -4087,6 +4087,7 @@ async def test_link_config_entry(
async def test_reload_config_entry(
hass: HomeAssistant,
mqtt_mock_entry: MqttMockHAClientGenerator,
caplog: pytest.LogCaptureFixture,
) -> None:
"""Test manual entities reloaded and set up correctly."""
await mqtt_mock_entry()
@ -4153,6 +4154,9 @@ async def test_reload_config_entry(
assert await hass.config_entries.async_reload(entry.entry_id)
assert entry.state is ConfigEntryState.LOADED
await hass.async_block_till_done()
# Assert the MQTT client was connected gracefully
with caplog.at_level(logging.INFO):
assert "Disconnected from MQTT server mock-broker:1883" in caplog.text
assert (state := hass.states.get("sensor.test_manual1")) is not None
assert state.attributes["friendly_name"] == "test_manual1_updated"