Fix issue caused by restoring datetime value from mobile app (#77462)
* Only pass strings to dt_util.parse_datetime() * Update homeassistant/components/mobile_app/sensor.py * Update sensor.py Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
parent
8c41d0d3d7
commit
01c200e11d
1 changed files with 3 additions and 0 deletions
|
@ -110,6 +110,9 @@ class MobileAppSensor(MobileAppEntity, RestoreSensor):
|
|||
SensorDeviceClass.DATE,
|
||||
SensorDeviceClass.TIMESTAMP,
|
||||
)
|
||||
# Only parse strings: if the sensor's state is restored, the state is a
|
||||
# native date or datetime, not str
|
||||
and isinstance(state, str)
|
||||
and (timestamp := dt_util.parse_datetime(state)) is not None
|
||||
):
|
||||
if self.device_class == SensorDeviceClass.DATE:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue