diff --git a/homeassistant/components/notion/__init__.py b/homeassistant/components/notion/__init__.py index e29ab171a6b..c2cbdb85289 100644 --- a/homeassistant/components/notion/__init__.py +++ b/homeassistant/components/notion/__init__.py @@ -171,6 +171,7 @@ class NotionEntity(CoordinatorEntity): return ( self.coordinator.last_update_success and self.task_id in self.coordinator.data["tasks"] + and self._state ) @property diff --git a/homeassistant/components/notion/binary_sensor.py b/homeassistant/components/notion/binary_sensor.py index a198903b99a..74ad724c50b 100644 --- a/homeassistant/components/notion/binary_sensor.py +++ b/homeassistant/components/notion/binary_sensor.py @@ -16,6 +16,7 @@ from . import NotionEntity from .const import ( DATA_COORDINATOR, DOMAIN, + LOGGER, SENSOR_BATTERY, SENSOR_DOOR, SENSOR_GARAGE_DOOR, @@ -81,8 +82,11 @@ class NotionBinarySensor(NotionEntity, BinarySensorEntity): if "value" in task["status"]: self._state = task["status"]["value"] - elif task["task_type"] == SENSOR_BATTERY: - self._state = task["status"]["data"]["to_state"] + elif task["status"].get("insights", {}).get("primary"): + self._state = task["status"]["insights"]["primary"]["to_state"] + else: + LOGGER.warning("Unknown data payload: %s", task["status"]) + self._state = None @property def is_on(self) -> bool: