diff --git a/homeassistant/components/recollect_waste/manifest.json b/homeassistant/components/recollect_waste/manifest.json index dc8a85ce2aacd2..4e7568a3fff30a 100644 --- a/homeassistant/components/recollect_waste/manifest.json +++ b/homeassistant/components/recollect_waste/manifest.json @@ -4,7 +4,7 @@ "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/recollect_waste", "requirements": [ - "aiorecollect==1.0.1" + "aiorecollect==1.0.4" ], "codeowners": [ "@bachya" diff --git a/homeassistant/components/recollect_waste/sensor.py b/homeassistant/components/recollect_waste/sensor.py index 1c3dabc2c87ce1..b95f1d6e8fa212 100644 --- a/homeassistant/components/recollect_waste/sensor.py +++ b/homeassistant/components/recollect_waste/sensor.py @@ -8,13 +8,19 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry -from homeassistant.const import ATTR_ATTRIBUTION, CONF_FRIENDLY_NAME, CONF_NAME +from homeassistant.const import ( + ATTR_ATTRIBUTION, + CONF_FRIENDLY_NAME, + CONF_NAME, + DEVICE_CLASS_TIMESTAMP, +) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers import config_validation as cv from homeassistant.helpers.update_coordinator import ( CoordinatorEntity, DataUpdateCoordinator, ) +from homeassistant.util.dt import as_utc from .const import CONF_PLACE_ID, CONF_SERVICE_ID, DATA_COORDINATOR, DOMAIN, LOGGER @@ -25,7 +31,6 @@ DEFAULT_ATTRIBUTION = "Pickup data provided by ReCollect Waste" DEFAULT_NAME = "recollect_waste" -DEFAULT_ICON = "mdi:trash-can-outline" PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend( { @@ -87,16 +92,16 @@ def __init__(self, coordinator: DataUpdateCoordinator, entry: ConfigEntry) -> No self._entry = entry self._state = None + @property + def device_class(self) -> dict: + """Return the device class.""" + return DEVICE_CLASS_TIMESTAMP + @property def extra_state_attributes(self) -> dict: """Return the state attributes.""" return self._attributes - @property - def icon(self) -> str: - """Icon to use in the frontend.""" - return DEFAULT_ICON - @property def name(self) -> str: """Return the name of the sensor.""" @@ -128,9 +133,8 @@ def update_from_latest_data(self) -> None: """Update the state.""" pickup_event = self.coordinator.data[0] next_pickup_event = self.coordinator.data[1] - next_date = str(next_pickup_event.date) - self._state = pickup_event.date + self._state = as_utc(pickup_event.date).isoformat() self._attributes.update( { ATTR_PICKUP_TYPES: async_get_pickup_type_names( @@ -140,6 +144,6 @@ def update_from_latest_data(self) -> None: ATTR_NEXT_PICKUP_TYPES: async_get_pickup_type_names( self._entry, next_pickup_event.pickup_types ), - ATTR_NEXT_PICKUP_DATE: next_date, + ATTR_NEXT_PICKUP_DATE: as_utc(next_pickup_event.date).isoformat(), } ) diff --git a/requirements_all.txt b/requirements_all.txt index f1f5128a79038f..ab57d37ab8a03a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -221,7 +221,7 @@ aiopvpc==2.0.2 aiopylgtv==0.4.0 # homeassistant.components.recollect_waste -aiorecollect==1.0.1 +aiorecollect==1.0.4 # homeassistant.components.shelly aioshelly==0.6.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index cfbaa1fa0b5a59..7769a22f9810d0 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -140,7 +140,7 @@ aiopvpc==2.0.2 aiopylgtv==0.4.0 # homeassistant.components.recollect_waste -aiorecollect==1.0.1 +aiorecollect==1.0.4 # homeassistant.components.shelly aioshelly==0.6.2