1
mirror of https://github.com/home-assistant/core synced 2024-07-30 21:18:57 +02:00

Add mold risk sensor to Notion (#95643)

Add mold detection sensor to Notion
This commit is contained in:
Aaron Bach 2023-07-02 12:13:18 -06:00 committed by GitHub
parent 2807b6cabc
commit c1b8e4a3e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View File

@ -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"

View File

@ -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
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