Migrate appropriate Ridwell sensors to use datetime state objects (#59944)

* Migrate appropriate Ridwell sensors to use datetime state objects

* Linting

* Whoops
This commit is contained in:
Aaron Bach
2021-11-18 22:24:12 -07:00
committed by GitHub
parent 347c4ea137
commit ff21453f58

View File

@@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Mapping from collections.abc import Mapping
from datetime import date, datetime
from typing import Any from typing import Any
from aioridwell.client import RidwellAccount, RidwellPickupEvent from aioridwell.client import RidwellAccount, RidwellPickupEvent
@@ -76,7 +77,7 @@ class RidwellSensor(CoordinatorEntity, SensorEntity):
return attrs return attrs
@property @property
def native_value(self) -> StateType: def native_value(self) -> StateType | date | datetime:
"""Return the value reported by the sensor.""" """Return the value reported by the sensor."""
event: RidwellPickupEvent = self.coordinator.data[self._account.account_id] event: RidwellPickupEvent = self.coordinator.data[self._account.account_id]
return event.pickup_date.isoformat() return event.pickup_date