Fix bug related to possibly missing task ID in Notion API data (#43330)

* Fix bug related to possibly missing task ID in Notion API data

* Calculate unique ID once

* Code review

* Simplify

* Code review
This commit is contained in:
Aaron Bach 2020-11-22 20:15:38 -07:00 committed by GitHub
parent 492ef81069
commit a4f7b7d784
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 9 deletions

View file

@ -76,7 +76,7 @@ class NotionSensor(NotionEntity):
@callback
def _async_update_from_latest_data(self) -> None:
"""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_TEMPERATURE:
self._state = round(float(task["status"]["value"]), 1)