mirror of
https://github.com/home-assistant/core.git
synced 2026-12-03 04:08:19 -04:00
Fix dwd stays unavailable (#193697)
This commit is contained in:
@@ -6,7 +6,13 @@ from dwdwfsapi import DwdWeatherWarningsAPI
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
|
||||
from homeassistant.exceptions import ConfigEntryError, ConfigEntryNotReady
|
||||
from homeassistant.helpers.location import Coordinates
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
DataUpdateCoordinator,
|
||||
UpdateFailed,
|
||||
UpdateFailedUnreachable,
|
||||
)
|
||||
from homeassistant.util import location as location_util
|
||||
|
||||
from .const import (
|
||||
@@ -40,8 +46,8 @@ class DwdWeatherWarningsCoordinator(DataUpdateCoordinator[None]):
|
||||
update_interval=DEFAULT_SCAN_INTERVAL,
|
||||
)
|
||||
|
||||
self._device_tracker = None
|
||||
self._previous_position = None
|
||||
self._device_tracker: str | None = None
|
||||
self._previous_position: Coordinates | None = None
|
||||
|
||||
@override
|
||||
async def _async_setup(self) -> None:
|
||||
@@ -50,9 +56,30 @@ class DwdWeatherWarningsCoordinator(DataUpdateCoordinator[None]):
|
||||
self.api = await self.hass.async_add_executor_job(
|
||||
DwdWeatherWarningsAPI, region_identifier
|
||||
)
|
||||
elif device_tracker := self.config_entry.data.get(CONF_REGION_DEVICE_TRACKER):
|
||||
self._device_tracker = device_tracker
|
||||
try:
|
||||
position = get_position_data(self.hass, device_tracker)
|
||||
except (EntityNotFoundError, CoordinatesNotFoundError) as err:
|
||||
raise ConfigEntryNotReady(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="position_error",
|
||||
translation_placeholders={"entity_id": device_tracker},
|
||||
) from err
|
||||
self.api = await self.hass.async_add_executor_job(
|
||||
DwdWeatherWarningsAPI, position
|
||||
)
|
||||
self._previous_position = position
|
||||
else:
|
||||
self._device_tracker = self.config_entry.data.get(
|
||||
CONF_REGION_DEVICE_TRACKER
|
||||
raise ConfigEntryError(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="invalid_config",
|
||||
)
|
||||
|
||||
if not self.api.data_valid:
|
||||
raise ConfigEntryNotReady(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="cannot_connect",
|
||||
)
|
||||
|
||||
@override
|
||||
@@ -92,3 +119,9 @@ class DwdWeatherWarningsCoordinator(DataUpdateCoordinator[None]):
|
||||
self._previous_position = position
|
||||
else:
|
||||
await self.hass.async_add_executor_job(self.api.update)
|
||||
|
||||
if not self.api.data_valid:
|
||||
raise UpdateFailedUnreachable(
|
||||
translation_domain=DOMAIN,
|
||||
translation_key="cannot_connect",
|
||||
)
|
||||
|
||||
@@ -60,6 +60,12 @@
|
||||
}
|
||||
},
|
||||
"exceptions": {
|
||||
"cannot_connect": {
|
||||
"message": "An error occurred while fetching data from DWD servers. Check whether the DWD servers are up and whether your region identifier or device tracker is valid."
|
||||
},
|
||||
"invalid_config": {
|
||||
"message": "The configuration is invalid. Either a region identifier or a device tracker is required."
|
||||
},
|
||||
"position_error": {
|
||||
"message": "An error occurred while fetching the position of {entity_id}"
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ from homeassistant.components.dwd_weather_warnings.const import (
|
||||
from homeassistant.const import CONF_MONITORED_CONDITIONS, CONF_NAME
|
||||
|
||||
MOCK_NAME = "Unit Test"
|
||||
MOCK_UNIQUE_ID = "mock_unique_id"
|
||||
MOCK_REGION_IDENTIFIER = "807111000"
|
||||
MOCK_REGION_DEVICE_TRACKER = "device_tracker.test_gps"
|
||||
MOCK_CONDITIONS = [CURRENT_WARNING_SENSOR, ADVANCE_WARNING_SENSOR]
|
||||
@@ -36,6 +37,7 @@ def mock_identifier_entry() -> MockConfigEntry:
|
||||
"""Return a mocked config entry with a region identifier."""
|
||||
return MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id=MOCK_UNIQUE_ID,
|
||||
data={
|
||||
CONF_NAME: MOCK_NAME,
|
||||
CONF_REGION_IDENTIFIER: MOCK_REGION_IDENTIFIER,
|
||||
@@ -49,6 +51,7 @@ def mock_tracker_entry() -> MockConfigEntry:
|
||||
"""Return a mocked config entry with a region identifier."""
|
||||
return MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
unique_id=MOCK_UNIQUE_ID,
|
||||
data={
|
||||
CONF_NAME: MOCK_NAME,
|
||||
CONF_REGION_DEVICE_TRACKER: MOCK_REGION_DEVICE_TRACKER,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
'api': dict({
|
||||
'current_warning_level': None,
|
||||
'current_warnings': None,
|
||||
'data_valid': False,
|
||||
'data_valid': True,
|
||||
'expected_warning_level': None,
|
||||
'expected_warnings': None,
|
||||
'last_update': None,
|
||||
|
||||
@@ -71,6 +71,7 @@ async def test_diagnostics_device_tracker(
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test diagnostics redact the device tracker of a tracker based entry."""
|
||||
mock_dwdwfsapi.data_valid = True
|
||||
mock_tracker_entry.add_to_hass(hass)
|
||||
entity_registry.async_get_or_create(
|
||||
"device_tracker",
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
"""Tests for Deutscher Wetterdienst (DWD) Weather Warnings integration."""
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from pytest_homeassistant.common import MockConfigEntry
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from pytest_homeassistant.common import MockConfigEntry, async_fire_time_changed
|
||||
|
||||
from homeassistant.components.dwd_weather_warnings.const import (
|
||||
ADVANCE_WARNING_SENSOR,
|
||||
API_ATTR_WARNING_COLOR,
|
||||
API_ATTR_WARNING_DESCRIPTION,
|
||||
API_ATTR_WARNING_END,
|
||||
@@ -20,16 +22,26 @@ from homeassistant.components.dwd_weather_warnings.const import (
|
||||
CONF_REGION_DEVICE_TRACKER,
|
||||
CONF_REGION_IDENTIFIER,
|
||||
CURRENT_WARNING_SENSOR,
|
||||
DEFAULT_SCAN_INTERVAL,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.components.dwd_weather_warnings.coordinator import (
|
||||
DwdWeatherWarningsCoordinator,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.const import ATTR_LATITUDE, ATTR_LONGITUDE, STATE_HOME
|
||||
from homeassistant.const import (
|
||||
ATTR_LATITUDE,
|
||||
ATTR_LONGITUDE,
|
||||
STATE_HOME,
|
||||
STATE_UNAVAILABLE,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType
|
||||
from homeassistant.helpers.update_coordinator import (
|
||||
UpdateFailed,
|
||||
UpdateFailedUnreachable,
|
||||
)
|
||||
from homeassistant.util import dt as dt_util
|
||||
|
||||
from . import init_integration
|
||||
@@ -57,6 +69,7 @@ async def test_load_unload_entry(
|
||||
mock_dwdwfsapi: MagicMock,
|
||||
) -> None:
|
||||
"""Test loading and unloading the integration with a region identifier entry."""
|
||||
mock_dwdwfsapi.data_valid = True
|
||||
entry = await init_integration(hass, mock_identifier_entry)
|
||||
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
@@ -103,6 +116,129 @@ async def test_removing_old_device(
|
||||
)
|
||||
|
||||
|
||||
async def test_load_entry_without_region_or_tracker(hass: HomeAssistant) -> None:
|
||||
"""Test setup failure when neither a region nor a tracker is configured."""
|
||||
entry = await init_integration(hass, MockConfigEntry(domain=DOMAIN, data={}))
|
||||
|
||||
assert entry.state is ConfigEntryState.SETUP_ERROR
|
||||
|
||||
|
||||
async def test_load_entry_with_invalid_api_data(
|
||||
hass: HomeAssistant,
|
||||
mock_identifier_entry: MockConfigEntry,
|
||||
mock_dwdwfsapi: MagicMock,
|
||||
) -> None:
|
||||
"""Test setup retry when the API returns invalid data."""
|
||||
mock_dwdwfsapi.data_valid = False
|
||||
entry = await init_integration(hass, mock_identifier_entry)
|
||||
|
||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
|
||||
async def _assert_setup_retry_recovers(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
entry: MockConfigEntry,
|
||||
mock_dwdwfsapi: MagicMock,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Assert a failed setup recovers when the API becomes valid."""
|
||||
mock_dwdwfsapi.data_valid = False
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert entry.state is ConfigEntryState.SETUP_RETRY
|
||||
|
||||
mock_dwdwfsapi.data_valid = True
|
||||
freezer.tick(timedelta(seconds=6))
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
assert entry.state is ConfigEntryState.LOADED
|
||||
for sensor in (CURRENT_WARNING_SENSOR, ADVANCE_WARNING_SENSOR):
|
||||
entity_id = entity_registry.async_get_entity_id(
|
||||
"sensor", DOMAIN, f"{entry.unique_id}-{sensor}"
|
||||
)
|
||||
assert entity_id is not None
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state != STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_load_entry_recovers_from_invalid_api_data(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_identifier_entry: MockConfigEntry,
|
||||
mock_dwdwfsapi: MagicMock,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test setup recovery with a warncell identifier."""
|
||||
mock_identifier_entry.add_to_hass(hass)
|
||||
await _assert_setup_retry_recovers(
|
||||
hass, entity_registry, mock_identifier_entry, mock_dwdwfsapi, freezer
|
||||
)
|
||||
|
||||
|
||||
async def test_load_device_tracker_recovers_from_invalid_api_data(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_tracker_entry: MockConfigEntry,
|
||||
mock_dwdwfsapi: MagicMock,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test setup recovery with a device tracker."""
|
||||
mock_tracker_entry.add_to_hass(hass)
|
||||
entity_registry.async_get_or_create(
|
||||
"device_tracker",
|
||||
mock_tracker_entry.domain,
|
||||
"uuid",
|
||||
suggested_object_id="test_gps",
|
||||
config_entry=mock_tracker_entry,
|
||||
)
|
||||
hass.states.async_set(
|
||||
mock_tracker_entry.data[CONF_REGION_DEVICE_TRACKER],
|
||||
STATE_HOME,
|
||||
{ATTR_LATITUDE: 50.180454, ATTR_LONGITUDE: 7.610263},
|
||||
)
|
||||
|
||||
await _assert_setup_retry_recovers(
|
||||
hass, entity_registry, mock_tracker_entry, mock_dwdwfsapi, freezer
|
||||
)
|
||||
|
||||
|
||||
async def test_load_device_tracker_with_invalid_api_data(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_tracker_entry: MockConfigEntry,
|
||||
mock_dwdwfsapi: MagicMock,
|
||||
) -> None:
|
||||
"""Test setup retry when position-based API data is invalid."""
|
||||
mock_dwdwfsapi.data_valid = False
|
||||
mock_tracker_entry.add_to_hass(hass)
|
||||
entity_registry.async_get_or_create(
|
||||
"device_tracker",
|
||||
mock_tracker_entry.domain,
|
||||
"uuid",
|
||||
suggested_object_id="test_gps",
|
||||
config_entry=mock_tracker_entry,
|
||||
)
|
||||
hass.states.async_set(
|
||||
mock_tracker_entry.data[CONF_REGION_DEVICE_TRACKER],
|
||||
STATE_HOME,
|
||||
{ATTR_LATITUDE: 50.180454, ATTR_LONGITUDE: 7.610263},
|
||||
)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.dwd_weather_warnings.coordinator.DwdWeatherWarningsAPI",
|
||||
return_value=mock_dwdwfsapi,
|
||||
) as mock_api:
|
||||
await hass.config_entries.async_setup(mock_tracker_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_tracker_entry.state is ConfigEntryState.SETUP_RETRY
|
||||
mock_api.assert_called_once_with((50.180454, 7.610263))
|
||||
|
||||
|
||||
async def test_load_invalid_registry_entry(
|
||||
hass: HomeAssistant, mock_tracker_entry: MockConfigEntry
|
||||
) -> None:
|
||||
@@ -147,6 +283,7 @@ async def test_load_valid_device_tracker(
|
||||
mock_dwdwfsapi: MagicMock,
|
||||
) -> None:
|
||||
"""Test loading the integration with a valid device tracker based entry."""
|
||||
mock_dwdwfsapi.data_valid = True
|
||||
mock_tracker_entry.add_to_hass(hass)
|
||||
entity_registry.async_get_or_create(
|
||||
"device_tracker",
|
||||
@@ -169,13 +306,140 @@ async def test_load_valid_device_tracker(
|
||||
assert isinstance(mock_tracker_entry.runtime_data, DwdWeatherWarningsCoordinator)
|
||||
|
||||
|
||||
async def test_failed_device_tracker_update(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_tracker_entry: MockConfigEntry,
|
||||
mock_dwdwfsapi: MagicMock,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test an API update failure for a device tracker entry."""
|
||||
mock_dwdwfsapi.data_valid = True
|
||||
mock_tracker_entry.add_to_hass(hass)
|
||||
entity_registry.async_get_or_create(
|
||||
"device_tracker",
|
||||
mock_tracker_entry.domain,
|
||||
"uuid",
|
||||
suggested_object_id="test_gps",
|
||||
config_entry=mock_tracker_entry,
|
||||
)
|
||||
hass.states.async_set(
|
||||
mock_tracker_entry.data[CONF_REGION_DEVICE_TRACKER],
|
||||
STATE_HOME,
|
||||
{ATTR_LATITUDE: 50.180454, ATTR_LONGITUDE: 7.610263},
|
||||
)
|
||||
|
||||
await hass.config_entries.async_setup(mock_tracker_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
def invalidate_api_data() -> None:
|
||||
mock_dwdwfsapi.data_valid = False
|
||||
|
||||
mock_dwdwfsapi.update.reset_mock()
|
||||
mock_dwdwfsapi.update.side_effect = invalidate_api_data
|
||||
coordinator = mock_tracker_entry.runtime_data
|
||||
freezer.tick(DEFAULT_SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
mock_dwdwfsapi.update.assert_called_once()
|
||||
assert isinstance(coordinator.last_exception, UpdateFailedUnreachable)
|
||||
assert coordinator.last_exception.translation_key == "cannot_connect"
|
||||
|
||||
|
||||
async def test_device_tracker_missing_during_update(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_tracker_entry: MockConfigEntry,
|
||||
mock_dwdwfsapi: MagicMock,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test an update failure when the tracker state disappears."""
|
||||
mock_dwdwfsapi.data_valid = True
|
||||
mock_tracker_entry.add_to_hass(hass)
|
||||
entity_registry.async_get_or_create(
|
||||
"device_tracker",
|
||||
mock_tracker_entry.domain,
|
||||
"uuid",
|
||||
suggested_object_id="test_gps",
|
||||
config_entry=mock_tracker_entry,
|
||||
)
|
||||
hass.states.async_set(
|
||||
mock_tracker_entry.data[CONF_REGION_DEVICE_TRACKER],
|
||||
STATE_HOME,
|
||||
{ATTR_LATITUDE: 50.180454, ATTR_LONGITUDE: 7.610263},
|
||||
)
|
||||
|
||||
await hass.config_entries.async_setup(mock_tracker_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
hass.states.async_remove(mock_tracker_entry.data[CONF_REGION_DEVICE_TRACKER])
|
||||
|
||||
coordinator = mock_tracker_entry.runtime_data
|
||||
freezer.tick(DEFAULT_SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
assert isinstance(coordinator.last_exception, UpdateFailed)
|
||||
assert coordinator.last_exception.translation_key == "position_error"
|
||||
|
||||
|
||||
async def test_device_tracker_moved(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_tracker_entry: MockConfigEntry,
|
||||
mock_dwdwfsapi: MagicMock,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Test recreating the API when the device tracker moves."""
|
||||
mock_dwdwfsapi.data_valid = True
|
||||
mock_tracker_entry.add_to_hass(hass)
|
||||
entity_registry.async_get_or_create(
|
||||
"device_tracker",
|
||||
mock_tracker_entry.domain,
|
||||
"uuid",
|
||||
suggested_object_id="test_gps",
|
||||
config_entry=mock_tracker_entry,
|
||||
)
|
||||
tracker_id = mock_tracker_entry.data[CONF_REGION_DEVICE_TRACKER]
|
||||
hass.states.async_set(
|
||||
tracker_id,
|
||||
STATE_HOME,
|
||||
{ATTR_LATITUDE: 50.180454, ATTR_LONGITUDE: 7.610263},
|
||||
)
|
||||
|
||||
await hass.config_entries.async_setup(mock_tracker_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
hass.states.async_set(
|
||||
tracker_id,
|
||||
STATE_HOME,
|
||||
{ATTR_LATITUDE: 50.19, ATTR_LONGITUDE: 7.610263},
|
||||
)
|
||||
new_api = MagicMock()
|
||||
new_api.data_valid = True
|
||||
with patch(
|
||||
"homeassistant.components.dwd_weather_warnings.coordinator.DwdWeatherWarningsAPI",
|
||||
return_value=new_api,
|
||||
) as mock_api:
|
||||
coordinator = mock_tracker_entry.runtime_data
|
||||
freezer.tick(DEFAULT_SCAN_INTERVAL)
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done(wait_background_tasks=True)
|
||||
|
||||
mock_api.assert_called_once()
|
||||
assert coordinator.api is new_api
|
||||
|
||||
|
||||
async def test_filter_expired_warnings(
|
||||
hass: HomeAssistant, entity_registry: er.EntityRegistry, mock_dwdwfsapi: MagicMock
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_dwdwfsapi: MagicMock,
|
||||
mock_identifier_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test expired-warning filtering."""
|
||||
now = dt_util.utcnow()
|
||||
mock_dwdwfsapi.data_valid = True
|
||||
mock_dwdwfsapi.warncell_id = "803000000"
|
||||
mock_dwdwfsapi.warncell_id = mock_identifier_entry.data[CONF_REGION_IDENTIFIER]
|
||||
mock_dwdwfsapi.warncell_name = "Test region"
|
||||
mock_dwdwfsapi.current_warnings = [
|
||||
_warning(4, now - timedelta(minutes=30)),
|
||||
@@ -183,15 +447,12 @@ async def test_filter_expired_warnings(
|
||||
]
|
||||
mock_dwdwfsapi.expected_warnings = []
|
||||
|
||||
entry = MockConfigEntry(
|
||||
domain=DOMAIN,
|
||||
data={CONF_REGION_IDENTIFIER: "803000000"},
|
||||
unique_id="803000000",
|
||||
)
|
||||
await init_integration(hass, entry)
|
||||
await init_integration(hass, mock_identifier_entry)
|
||||
|
||||
entity_id = entity_registry.async_get_entity_id(
|
||||
"sensor", DOMAIN, f"{entry.unique_id}-{CURRENT_WARNING_SENSOR}"
|
||||
"sensor",
|
||||
DOMAIN,
|
||||
f"{mock_identifier_entry.unique_id}-{CURRENT_WARNING_SENSOR}",
|
||||
)
|
||||
assert entity_id is not None
|
||||
|
||||
@@ -200,3 +461,29 @@ async def test_filter_expired_warnings(
|
||||
assert state.state == "2"
|
||||
assert state.attributes[ATTR_WARNING_COUNT] == 1
|
||||
assert "warning_2" not in state.attributes
|
||||
|
||||
|
||||
async def test_no_warnings(
|
||||
hass: HomeAssistant,
|
||||
entity_registry: er.EntityRegistry,
|
||||
mock_dwdwfsapi: MagicMock,
|
||||
mock_identifier_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test sensors when the API returns no warning data."""
|
||||
mock_dwdwfsapi.data_valid = True
|
||||
mock_dwdwfsapi.current_warnings = None
|
||||
mock_dwdwfsapi.expected_warnings = None
|
||||
|
||||
await init_integration(hass, mock_identifier_entry)
|
||||
|
||||
entity_id = entity_registry.async_get_entity_id(
|
||||
"sensor",
|
||||
DOMAIN,
|
||||
f"{mock_identifier_entry.unique_id}-{CURRENT_WARNING_SENSOR}",
|
||||
)
|
||||
assert entity_id is not None
|
||||
|
||||
state = hass.states.get(entity_id)
|
||||
assert state is not None
|
||||
assert state.state == "0"
|
||||
assert state.attributes[ATTR_WARNING_COUNT] == 0
|
||||
|
||||
Reference in New Issue
Block a user