parent
2807b6cabc
commit
c1b8e4a3e5
|
@ -9,6 +9,7 @@ SENSOR_DOOR = "door"
|
|||
SENSOR_GARAGE_DOOR = "garage_door"
|
||||
SENSOR_LEAK = "leak"
|
||||
SENSOR_MISSING = "missing"
|
||||
SENSOR_MOLD = "mold"
|
||||
SENSOR_SAFE = "safe"
|
||||
SENSOR_SLIDING = "sliding"
|
||||
SENSOR_SMOKE_CO = "alarm"
|
||||
|
|
|
@ -15,7 +15,7 @@ from homeassistant.core import HomeAssistant
|
|||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from . import NotionEntity
|
||||
from .const import DOMAIN, SENSOR_TEMPERATURE
|
||||
from .const import DOMAIN, SENSOR_MOLD, SENSOR_TEMPERATURE
|
||||
from .model import NotionEntityDescriptionMixin
|
||||
|
||||
|
||||
|
@ -25,6 +25,12 @@ class NotionSensorDescription(SensorEntityDescription, NotionEntityDescriptionMi
|
|||
|
||||
|
||||
SENSOR_DESCRIPTIONS = (
|
||||
NotionSensorDescription(
|
||||
key=SENSOR_MOLD,
|
||||
name="Mold risk",
|
||||
icon="mdi:liquid-spot",
|
||||
listener_kind=ListenerKind.MOLD,
|
||||
),
|
||||
NotionSensorDescription(
|
||||
key=SENSOR_TEMPERATURE,
|
||||
name="Temperature",
|
||||
|
@ -76,11 +82,11 @@ class NotionSensor(NotionEntity, SensorEntity):
|
|||
|
||||
@property
|
||||
def native_value(self) -> str | None:
|
||||
"""Return the value reported by the sensor.
|
||||
|
||||
The Notion API only returns a localized string for temperature (e.g. "70°"); we
|
||||
simply remove the degree symbol:
|
||||
"""
|
||||
"""Return the value reported by the sensor."""
|
||||
if not self.listener.status_localized:
|
||||
return None
|
||||
if self.listener.listener_kind == ListenerKind.TEMPERATURE:
|
||||
# The Notion API only returns a localized string for temperature (e.g.
|
||||
# "70°"); we simply remove the degree symbol:
|
||||
return self.listener.status_localized.state[:-1]
|
||||
return self.listener.status_localized.state
|
||||
|
|
Loading…
Reference in New Issue