Update notion to use CoordinatorEntity (#39460)

This commit is contained in:
J. Nick Koston 2020-08-30 13:02:56 -05:00 committed by GitHub
parent 773860ca5c
commit 692ed8c639
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 23 deletions

View file

@ -73,12 +73,12 @@ 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"]
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]
task = self.coordinator.data["tasks"][self._task_id]
if task["task_type"] == SENSOR_BATTERY:
return self._state != "battery_good"