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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user