Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions homeassistant/components/notion/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
SENSOR_GARAGE_DOOR = "garage_door"
SENSOR_LEAK = "leak"
SENSOR_MISSING = "missing"
SENSOR_MOLD = "mold"
SENSOR_SAFE = "safe"
SENSOR_SLIDING = "sliding"
SENSOR_SMOKE_CO = "alarm"
Expand Down
20 changes: 13 additions & 7 deletions homeassistant/components/notion/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
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


Expand All @@ -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",
Expand Down Expand Up @@ -76,11 +82,11 @@ def native_unit_of_measurement(self) -> str | None:

@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