mirror of
https://github.com/home-assistant/core.git
synced 2025-06-20 21:17:06 +00:00
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
@ -110,6 +110,9 @@ class MobileAppSensor(MobileAppEntity, RestoreSensor):
|
|||||||
SensorDeviceClass.DATE,
|
SensorDeviceClass.DATE,
|
||||||
SensorDeviceClass.TIMESTAMP,
|
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
|
and (timestamp := dt_util.parse_datetime(state)) is not None
|
||||||
):
|
):
|
||||||
if self.device_class == SensorDeviceClass.DATE:
|
if self.device_class == SensorDeviceClass.DATE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user