Skip to content
Merged
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
13 changes: 11 additions & 2 deletions homeassistant/components/notion/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,24 @@ class NotionBinarySensor(NotionEntity, BinarySensorEntity):
@callback
def _async_update_from_latest_data(self) -> None:
"""Fetch new state data for the sensor."""
self._state = self.coordinator.data["tasks"][self._task_id]["status"]["value"]
task = self.coordinator.data["tasks"][self._task_id]

if task["task_type"] == SENSOR_BATTERY:
self._state = self.coordinator.data["tasks"][self._task_id]["status"][
"data"
]["to_state"]
else:
self._state = self.coordinator.data["tasks"][self._task_id]["status"][
"value"
]

@property
def is_on(self) -> bool:
"""Return whether the sensor is on or off."""
task = self.coordinator.data["tasks"][self._task_id]

if task["task_type"] == SENSOR_BATTERY:
return self._state != "battery_good"
return self._state != "critical"
if task["task_type"] in (
SENSOR_DOOR,
SENSOR_GARAGE_DOOR,
Expand Down