Fix Notion binary sensor bug due to API changes (#45616)
This commit is contained in:
parent
6aadf14bdd
commit
b420c1ceb7
2 changed files with 7 additions and 2 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue