mirror of
https://github.com/home-assistant/core.git
synced 2025-07-13 16:27:08 +00:00
Fix Notion binary sensor bug due to API changes (#45616)
This commit is contained in:
parent
6aadf14bdd
commit
b420c1ceb7
@ -171,6 +171,7 @@ class NotionEntity(CoordinatorEntity):
|
|||||||
return (
|
return (
|
||||||
self.coordinator.last_update_success
|
self.coordinator.last_update_success
|
||||||
and self.task_id in self.coordinator.data["tasks"]
|
and self.task_id in self.coordinator.data["tasks"]
|
||||||
|
and self._state
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -16,6 +16,7 @@ from . import NotionEntity
|
|||||||
from .const import (
|
from .const import (
|
||||||
DATA_COORDINATOR,
|
DATA_COORDINATOR,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
LOGGER,
|
||||||
SENSOR_BATTERY,
|
SENSOR_BATTERY,
|
||||||
SENSOR_DOOR,
|
SENSOR_DOOR,
|
||||||
SENSOR_GARAGE_DOOR,
|
SENSOR_GARAGE_DOOR,
|
||||||
@ -81,8 +82,11 @@ class NotionBinarySensor(NotionEntity, BinarySensorEntity):
|
|||||||
|
|
||||||
if "value" in task["status"]:
|
if "value" in task["status"]:
|
||||||
self._state = task["status"]["value"]
|
self._state = task["status"]["value"]
|
||||||
elif task["task_type"] == SENSOR_BATTERY:
|
elif task["status"].get("insights", {}).get("primary"):
|
||||||
self._state = task["status"]["data"]["to_state"]
|
self._state = task["status"]["insights"]["primary"]["to_state"]
|
||||||
|
else:
|
||||||
|
LOGGER.warning("Unknown data payload: %s", task["status"])
|
||||||
|
self._state = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user