mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Fix incorrect Notion battery state calculation (#43108)
* Fix incorrect Notion battery state calculation * Both cases
This commit is contained in:
parent
7b7bb0a15f
commit
7921be1b5f
@ -79,14 +79,10 @@ class NotionBinarySensor(NotionEntity, BinarySensorEntity):
|
|||||||
"""Fetch new state data for the sensor."""
|
"""Fetch new state data for the sensor."""
|
||||||
task = self.coordinator.data["tasks"][self._task_id]
|
task = self.coordinator.data["tasks"][self._task_id]
|
||||||
|
|
||||||
if task["task_type"] == SENSOR_BATTERY:
|
if "value" in task["status"]:
|
||||||
self._state = self.coordinator.data["tasks"][self._task_id]["status"][
|
self._state = task["status"]["value"]
|
||||||
"data"
|
elif task["task_type"] == SENSOR_BATTERY:
|
||||||
]["to_state"]
|
self._state = task["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:
|
||||||
@ -94,7 +90,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 != "critical"
|
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