mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add mold risk sensor to Notion (#95643)
Add mold detection sensor to Notion
This commit is contained in:
parent
2807b6cabc
commit
c1b8e4a3e5
@ -9,6 +9,7 @@ SENSOR_DOOR = "door"
|
|||||||
SENSOR_GARAGE_DOOR = "garage_door"
|
SENSOR_GARAGE_DOOR = "garage_door"
|
||||||
SENSOR_LEAK = "leak"
|
SENSOR_LEAK = "leak"
|
||||||
SENSOR_MISSING = "missing"
|
SENSOR_MISSING = "missing"
|
||||||
|
SENSOR_MOLD = "mold"
|
||||||
SENSOR_SAFE = "safe"
|
SENSOR_SAFE = "safe"
|
||||||
SENSOR_SLIDING = "sliding"
|
SENSOR_SLIDING = "sliding"
|
||||||
SENSOR_SMOKE_CO = "alarm"
|
SENSOR_SMOKE_CO = "alarm"
|
||||||
|
@ -15,7 +15,7 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import NotionEntity
|
from . import NotionEntity
|
||||||
from .const import DOMAIN, SENSOR_TEMPERATURE
|
from .const import DOMAIN, SENSOR_MOLD, SENSOR_TEMPERATURE
|
||||||
from .model import NotionEntityDescriptionMixin
|
from .model import NotionEntityDescriptionMixin
|
||||||
|
|
||||||
|
|
||||||
@ -25,6 +25,12 @@ class NotionSensorDescription(SensorEntityDescription, NotionEntityDescriptionMi
|
|||||||
|
|
||||||
|
|
||||||
SENSOR_DESCRIPTIONS = (
|
SENSOR_DESCRIPTIONS = (
|
||||||
|
NotionSensorDescription(
|
||||||
|
key=SENSOR_MOLD,
|
||||||
|
name="Mold risk",
|
||||||
|
icon="mdi:liquid-spot",
|
||||||
|
listener_kind=ListenerKind.MOLD,
|
||||||
|
),
|
||||||
NotionSensorDescription(
|
NotionSensorDescription(
|
||||||
key=SENSOR_TEMPERATURE,
|
key=SENSOR_TEMPERATURE,
|
||||||
name="Temperature",
|
name="Temperature",
|
||||||
@ -76,11 +82,11 @@ class NotionSensor(NotionEntity, SensorEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self) -> str | None:
|
def native_value(self) -> str | None:
|
||||||
"""Return the value reported by the sensor.
|
"""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:
|
|
||||||
"""
|
|
||||||
if not self.listener.status_localized:
|
if not self.listener.status_localized:
|
||||||
return None
|
return None
|
||||||
return self.listener.status_localized.state[:-1]
|
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…
x
Reference in New Issue
Block a user