From 8fda70537736db9a73c0a863800d6bb4df67f5fc Mon Sep 17 00:00:00 2001 From: Philip Rosenberg-Watt Date: Sat, 6 Oct 2018 17:38:25 -0600 Subject: [PATCH] Fix Todoist custom project update (#17115) * Fix Todoist custom project update Custom projects were not refreshing the API state and were using local/stored state. This resulted in invalid tasks being retained upon update. This change resets the local Todoist API state, syncs it, and then continues normal update operation(s) on the Todoist project data object. * Remove blank line after docstring * Update logging call * Simplify logging --- homeassistant/components/calendar/todoist.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/homeassistant/components/calendar/todoist.py b/homeassistant/components/calendar/todoist.py index b5eaed4e6c9..a0a3457667f 100644 --- a/homeassistant/components/calendar/todoist.py +++ b/homeassistant/components/calendar/todoist.py @@ -518,6 +518,8 @@ class TodoistProjectData: def update(self): """Get the latest data.""" if self._id is None: + self._api.reset_state() + self._api.sync() project_task_data = [ task for task in self._api.state[TASKS] if not self._project_id_whitelist or @@ -527,6 +529,7 @@ class TodoistProjectData: # If we have no data, we can just return right away. if not project_task_data: + _LOGGER.debug("No data for %s", self._name) self.event = None return True @@ -541,6 +544,8 @@ class TodoistProjectData: if not project_tasks: # We had no valid tasks + _LOGGER.debug("No valid tasks for %s", self._name) + self.event = None return True # Make sure the task collection is reset to prevent an