1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Set state for MQTT entities to 'unavailable' when no connection to broker (#36479)

* Report 'unavailable' state when not connected

to MQTT broker

* Fix tests

* Rewrite to remove the polling

* Add tests

* Add some fixes
This commit is contained in:
definitio
2020-06-07 11:21:16 +04:00
committed by GitHub
parent 3bf389639b
commit ad5101c5c0
17 changed files with 147 additions and 1 deletions

View File

@@ -30,6 +30,7 @@ from homeassistant.const import (
from homeassistant.setup import async_setup_component
from .test_common import (
help_test_availability_when_connection_lost,
help_test_availability_without_topic,
help_test_custom_availability_payload,
help_test_default_availability_payload,
@@ -1735,6 +1736,13 @@ async def test_find_in_range_altered_inverted(hass, mqtt_mock):
assert mqtt_cover.find_in_range_from_percent(60, "cover") == 120
async def test_availability_when_connection_lost(hass, mqtt_mock):
"""Test availability after MQTT disconnection."""
await help_test_availability_when_connection_lost(
hass, mqtt_mock, cover.DOMAIN, DEFAULT_CONFIG
)
async def test_availability_without_topic(hass, mqtt_mock):
"""Test availability without defined availability topic."""
await help_test_availability_without_topic(