Use native datetime value in Forecast Solar sensors (#59913)

This commit is contained in:
Franck Nijhof 2021-11-18 19:58:31 +01:00 committed by GitHub
parent 9ccee205ca
commit fc330f797d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -61,7 +61,7 @@ class ForecastSolarSensorEntity(CoordinatorEntity, SensorEntity):
)
@property
def native_value(self) -> StateType:
def native_value(self) -> datetime | StateType:
"""Return the state of the sensor."""
if self.entity_description.state is None:
state: StateType | datetime = getattr(
@ -70,6 +70,4 @@ class ForecastSolarSensorEntity(CoordinatorEntity, SensorEntity):
else:
state = self.entity_description.state(self.coordinator.data)
if isinstance(state, datetime):
return state.isoformat()
return state