Use native datetime value in Jewish Calendar sensors (#59917)

pull/59924/head
Franck Nijhof 2021-11-18 20:03:16 +01:00 committed by GitHub
parent 3adb9e4143
commit 4e4f6ffa07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 5 deletions

View File

@ -170,10 +170,8 @@ class JewishCalendarSensor(SensorEntity):
self._holiday_attrs: dict[str, str] = {}
@property
def native_value(self) -> StateType:
def native_value(self) -> datetime | StateType:
"""Return the state of the sensor."""
if isinstance(self._state, datetime):
return self._state.isoformat()
return self._state
async def async_update(self) -> None:
@ -262,11 +260,11 @@ class JewishCalendarTimeSensor(JewishCalendarSensor):
_attr_device_class = DEVICE_CLASS_TIMESTAMP
@property
def native_value(self) -> StateType | None:
def native_value(self) -> datetime | None:
"""Return the state of the sensor."""
if self._state is None:
return None
return dt_util.as_utc(self._state).isoformat()
return dt_util.as_utc(self._state)
def get_state(
self, daytime_date: HDate, after_shkia_date: HDate, after_tzais_date: HDate