diff --git a/homeassistant/components/twentemilieu/__init__.py b/homeassistant/components/twentemilieu/__init__.py index 576ab2068a7..cee6ffbf38e 100644 --- a/homeassistant/components/twentemilieu/__init__.py +++ b/homeassistant/components/twentemilieu/__init__.py @@ -34,7 +34,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: ) coordinator: DataUpdateCoordinator[ - dict[WasteType, date | None] + dict[WasteType, list[date]] ] = DataUpdateCoordinator( hass, LOGGER, diff --git a/homeassistant/components/twentemilieu/diagnostics.py b/homeassistant/components/twentemilieu/diagnostics.py index 0d63fdbcf2c..a158ead0909 100644 --- a/homeassistant/components/twentemilieu/diagnostics.py +++ b/homeassistant/components/twentemilieu/diagnostics.py @@ -17,6 +17,6 @@ async def async_get_config_entry_diagnostics( """Return diagnostics for a config entry.""" coordinator: DataUpdateCoordinator = hass.data[DOMAIN][entry.data[CONF_ID]] return { - waste_type: waste_date.isoformat() if waste_date else None - for waste_type, waste_date in coordinator.data.items() + waste_type: [waste_date.isoformat() for waste_date in waste_dates] + for waste_type, waste_dates in coordinator.data.items() } diff --git a/homeassistant/components/twentemilieu/manifest.json b/homeassistant/components/twentemilieu/manifest.json index d0b94efe289..e8e280dcd3d 100644 --- a/homeassistant/components/twentemilieu/manifest.json +++ b/homeassistant/components/twentemilieu/manifest.json @@ -3,7 +3,7 @@ "name": "Twente Milieu", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/twentemilieu", - "requirements": ["twentemilieu==0.5.0"], + "requirements": ["twentemilieu==0.6.0"], "codeowners": ["@frenck"], "quality_scale": "platinum", "iot_class": "cloud_polling", diff --git a/homeassistant/components/twentemilieu/sensor.py b/homeassistant/components/twentemilieu/sensor.py index f25b84ace15..a56523d53d0 100644 --- a/homeassistant/components/twentemilieu/sensor.py +++ b/homeassistant/components/twentemilieu/sensor.py @@ -90,11 +90,10 @@ async def async_setup_entry( ) -class TwenteMilieuSensor(CoordinatorEntity, SensorEntity): +class TwenteMilieuSensor(CoordinatorEntity[dict[WasteType, list[date]]], SensorEntity): """Defines a Twente Milieu sensor.""" entity_description: TwenteMilieuSensorDescription - coordinator: DataUpdateCoordinator[dict[WasteType, date | None]] def __init__( self, @@ -117,4 +116,6 @@ class TwenteMilieuSensor(CoordinatorEntity, SensorEntity): @property def native_value(self) -> date | None: """Return the state of the sensor.""" - return self.coordinator.data.get(self.entity_description.waste_type) + if not (dates := self.coordinator.data[self.entity_description.waste_type]): + return None + return dates[0] diff --git a/requirements_all.txt b/requirements_all.txt index fc930536b83..5b63119186d 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2315,7 +2315,7 @@ ttls==1.4.3 tuya-iot-py-sdk==0.6.6 # homeassistant.components.twentemilieu -twentemilieu==0.5.0 +twentemilieu==0.6.0 # homeassistant.components.twilio twilio==6.32.0 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 8f39d58d637..0a13b5c2686 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1468,7 +1468,7 @@ ttls==1.4.3 tuya-iot-py-sdk==0.6.6 # homeassistant.components.twentemilieu -twentemilieu==0.5.0 +twentemilieu==0.6.0 # homeassistant.components.twilio twilio==6.32.0 diff --git a/tests/components/twentemilieu/conftest.py b/tests/components/twentemilieu/conftest.py index 530e9723251..6e58ba2db48 100644 --- a/tests/components/twentemilieu/conftest.py +++ b/tests/components/twentemilieu/conftest.py @@ -65,11 +65,11 @@ def mock_twentemilieu() -> Generator[None, MagicMock, None]: twentemilieu = twentemilieu_mock.return_value twentemilieu.unique_id.return_value = 12345 twentemilieu.update.return_value = { - WasteType.NON_RECYCLABLE: date(2021, 11, 1), - WasteType.ORGANIC: date(2021, 11, 2), - WasteType.PACKAGES: date(2021, 11, 3), - WasteType.PAPER: None, - WasteType.TREE: date(2022, 1, 6), + WasteType.NON_RECYCLABLE: [date(2021, 11, 1), date(2021, 12, 1)], + WasteType.ORGANIC: [date(2021, 11, 2)], + WasteType.PACKAGES: [date(2021, 11, 3)], + WasteType.PAPER: [], + WasteType.TREE: [date(2022, 1, 6)], } yield twentemilieu diff --git a/tests/components/twentemilieu/test_diagnostics.py b/tests/components/twentemilieu/test_diagnostics.py index 2f5ffcd5eb9..efbe2fc3104 100644 --- a/tests/components/twentemilieu/test_diagnostics.py +++ b/tests/components/twentemilieu/test_diagnostics.py @@ -16,9 +16,9 @@ async def test_diagnostics( assert await get_diagnostics_for_config_entry( hass, hass_client, init_integration ) == { - "0": "2021-11-01", - "1": "2021-11-02", - "2": None, - "6": "2022-01-06", - "10": "2021-11-03", + "0": ["2021-11-01", "2021-12-01"], + "1": ["2021-11-02"], + "2": [], + "6": ["2022-01-06"], + "10": ["2021-11-03"], }