8000 Fix API change with Notion batteries by bachya · Pull Request #43073 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix API change with Notion batteries #43073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions homeassistant/components/notion/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,24 @@ class NotionBinarySensor(NotionEntity, BinarySensorEntity):
@callback
def _async_update_from_latest_data(self) -> None:
"""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:
6E43 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
def is_on(self) -> bool:
"""Return whether the sensor is on or off."""
task = self.coordinator.data["tasks"][self._task_id]

if task["task_type"] == SENSOR_BATTERY:
return self._state != "battery_good"
return self._state != "critical"
if task["task_type"] in (
SENSOR_DOOR,
SENSOR_GARAGE_DOOR,
Expand Down
0