mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix API change with Notion batteries (#43073)
This commit is contained in:
parent
4b9ba79584
commit
9b58b24b17
@ -77,7 +77,16 @@ class NotionBinarySensor(NotionEntity, BinarySensorEntity):
|
|||||||
@callback
|
@callback
|
||||||
def _async_update_from_latest_data(self) -> None:
|
def _async_update_from_latest_data(self) -> None:
|
||||||
"""Fetch new state data for the sensor."""
|
"""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
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
@ -85,7 +94,7 @@ class NotionBinarySensor(NotionEntity, BinarySensorEntity):
|
|||||||
task = self.coordinator.data["tasks"][self._task_id]
|
task = self.coordinator.data["tasks"][self._task_id]
|
||||||
|
|
||||||
if task["task_type"] == SENSOR_BATTERY:
|
if task["task_type"] == SENSOR_BATTERY:
|
||||||
return self._state != "battery_good"
|
return self._state != "critical"
|
||||||
if task["task_type"] in (
|
if task["task_type"] in (
|
||||||
SENSOR_DOOR,
|
SENSOR_DOOR,
|
||||||
SENSOR_GARAGE_DOOR,
|
SENSOR_GARAGE_DOOR,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user