diff --git a/homeassistant/components/duco/coordinator.py b/homeassistant/components/duco/coordinator.py index 94a6bc60025c..899ad0e5a2f9 100644 --- a/homeassistant/components/duco/coordinator.py +++ b/homeassistant/components/duco/coordinator.py @@ -51,7 +51,6 @@ class DucoCoordinator(DataUpdateCoordinator[DucoData]): config_entry: DucoConfigEntry board_info: BoardInfo - _supports_time_filter_remain: bool _configured_node_names: dict[int, str] def __init__( @@ -70,7 +69,6 @@ class DucoCoordinator(DataUpdateCoordinator[DucoData]): ) self.client = client self._configured_node_names = {} - self._supports_time_filter_remain = True async def _async_load_node_names(self) -> None: """Load configured Duco node names during setup.""" @@ -178,12 +176,11 @@ class DucoCoordinator(DataUpdateCoordinator[DucoData]): # Heat recovery info only backs the optional filter timer sensor, so # failures on this supplemental endpoint should not make the primary - # node entities unavailable. + # node entities unavailable. A None result leaves the sensor absent + # but keeps the helper pollable so data can appear on a later refresh. time_filter_remain = None - if self._supports_time_filter_remain: - with suppress(DucoError): - time_filter_remain = await self.client.async_get_time_filter_remaining() - self._supports_time_filter_remain = time_filter_remain is not None + with suppress(DucoError): + time_filter_remain = await self.client.async_get_time_filter_remaining() ventilation_temperatures = ( self.data.ventilation_temperatures if self.data else None diff --git a/tests/components/duco/test_sensor.py b/tests/components/duco/test_sensor.py index 0ab867c271d8..9cf809fc9878 100644 --- a/tests/components/duco/test_sensor.py +++ b/tests/components/duco/test_sensor.py @@ -251,14 +251,14 @@ async def test_lan_info_failures_keep_node_entities_available( assert state.state == "-60" -async def test_time_filter_remaining_missing_skips_sensor_creation( +async def test_time_filter_remaining_missing_is_retried( hass: HomeAssistant, mock_config_entry: MockConfigEntry, mock_duco_client: AsyncMock, mock_sensor_nodes: list[Node], freezer: FrozenDateTimeFactory, ) -> None: - """Test the filter timer sensor is not created when unsupported.""" + """Test a missing filter timer does not create the sensor but is retried.""" mock_duco_client.async_get_nodes.return_value = mock_sensor_nodes mock_duco_client.async_get_time_filter_remaining = AsyncMock( @@ -273,7 +273,10 @@ async def test_time_filter_remaining_missing_skips_sensor_creation( async_fire_time_changed(hass) await hass.async_block_till_done(wait_background_tasks=True) - assert hass.states.get(FILTER_REMAINING_ENTITY_ID) is None + assert mock_duco_client.async_get_time_filter_remaining.await_count == 2 + state = hass.states.get(FILTER_REMAINING_ENTITY_ID) + assert state is not None + assert state.state == "180" async def test_empty_ventilation_temperatures_are_retried(