mirror of
https://github.com/home-assistant/core.git
synced 2025-07-26 22:57:17 +00:00
Use new enums in mobile_app (#61929)
This commit is contained in:
parent
5227019d3e
commit
029af94d28
@ -1,13 +1,11 @@
|
|||||||
"""Sensor platform for mobile_app."""
|
"""Sensor platform for mobile_app."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_UNIQUE_ID,
|
CONF_UNIQUE_ID,
|
||||||
CONF_WEBHOOK_ID,
|
CONF_WEBHOOK_ID,
|
||||||
DEVICE_CLASS_DATE,
|
|
||||||
DEVICE_CLASS_TIMESTAMP,
|
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
)
|
)
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
@ -95,12 +93,12 @@ class MobileAppSensor(MobileAppEntity, SensorEntity):
|
|||||||
if (
|
if (
|
||||||
self.device_class
|
self.device_class
|
||||||
in (
|
in (
|
||||||
DEVICE_CLASS_DATE,
|
SensorDeviceClass.DATE,
|
||||||
DEVICE_CLASS_TIMESTAMP,
|
SensorDeviceClass.TIMESTAMP,
|
||||||
)
|
)
|
||||||
and (timestamp := dt_util.parse_datetime(state)) is not None
|
and (timestamp := dt_util.parse_datetime(state)) is not None
|
||||||
):
|
):
|
||||||
if self.device_class == DEVICE_CLASS_DATE:
|
if self.device_class == SensorDeviceClass.DATE:
|
||||||
return timestamp.date()
|
return timestamp.date()
|
||||||
return timestamp
|
return timestamp
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user