Fix incorrect Notion battery state calculation (#43108)
* Fix incorrect Notion battery state calculation * Both cases
This commit is contained in:
parent
7b7bb0a15f
commit
7921be1b5f
1 changed files with 5 additions and 9 deletions
|
@ -79,14 +79,10 @@ class NotionBinarySensor(NotionEntity, BinarySensorEntity):
|
|||
"""Fetch new state data for the sensor."""
|
||||
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"
|
||||
]
|
||||
if "value" in task["status"]:
|
||||
self._state = task["status"]["value"]
|
||||
elif task["task_type"] == SENSOR_BATTERY:
|
||||
self._state = task["status"]["data"]["to_state"]
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
|
@ -94,7 +90,7 @@ class NotionBinarySensor(NotionEntity, BinarySensorEntity):
|
|||
task = self.coordinator.data["tasks"][self._task_id]
|
||||
|
||||
if task["task_type"] == SENSOR_BATTERY:
|
||||
return self._state != "critical"
|
||||
return self._state == "critical"
|
||||
if task["task_type"] in (
|
||||
SENSOR_DOOR,
|
||||
SENSOR_GARAGE_DOOR,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue