From 35bfe632aec69f531cc84dc222f4168075a6c561 Mon Sep 17 00:00:00 2001 From: Philipp Neumann <3daquawolf@gmail.com> Date: Sat, 2 Mar 2024 08:46:05 +0100 Subject: [PATCH] complete to-do items by correcting type for uid field --- .../hacs_vikunja_integration/todo.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/custom_components/hacs_vikunja_integration/todo.py b/custom_components/hacs_vikunja_integration/todo.py index e8b4069..e753d22 100644 --- a/custom_components/hacs_vikunja_integration/todo.py +++ b/custom_components/hacs_vikunja_integration/todo.py @@ -23,7 +23,7 @@ SCAN_INTERVAL = timedelta(minutes=15) TODO_STATUS_MAP = { - "needsAction": TodoItemStatus.NEEDS_ACTION, # probably not_started + "needsAction": TodoItemStatus.NEEDS_ACTION, # probably not_started "completed": TodoItemStatus.COMPLETED, } TODO_STATUS_MAP_INV = {v: k for k, v in TODO_STATUS_MAP.items()} @@ -53,7 +53,7 @@ def _convert_api_item(item: dict[str, str]) -> TodoItem: due = datetime.fromisoformat(due_str).date() return TodoItem( summary=item["title"], - uid=item["id"], + uid=str(item["id"]), status=TODO_STATUS_MAP.get( item.get("status", ""), TodoItemStatus.NEEDS_ACTION, @@ -62,6 +62,7 @@ def _convert_api_item(item: dict[str, str]) -> TodoItem: description=item.get("notes"), ) + async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: @@ -81,6 +82,7 @@ async def async_setup_entry( True, ) + class VikunjaTaskTodoListEntity( CoordinatorEntity[VikunjaDataUpdateCoordinator], TodoListEntity ): @@ -88,12 +90,12 @@ class VikunjaTaskTodoListEntity( _attr_has_entity_name = True _attr_supported_features = ( -# TodoListEntityFeature.CREATE_TODO_ITEM - TodoListEntityFeature.UPDATE_TODO_ITEM -# | TodoListEntityFeature.DELETE_TODO_ITEM -# | TodoListEntityFeature.MOVE_TODO_ITEM -# | TodoListEntityFeature.SET_DUE_DATE_ON_ITEM -# | TodoListEntityFeature.SET_DESCRIPTION_ON_ITEM + # TodoListEntityFeature.CREATE_TODO_ITEM + TodoListEntityFeature.UPDATE_TODO_ITEM + # | TodoListEntityFeature.DELETE_TODO_ITEM + # | TodoListEntityFeature.MOVE_TODO_ITEM + # | TodoListEntityFeature.SET_DUE_DATE_ON_ITEM + # | TodoListEntityFeature.SET_DESCRIPTION_ON_ITEM ) def __init__( @@ -120,7 +122,6 @@ async def async_update_todo_item(self, item: TodoItem) -> None: """Update a To-do item.""" uid: str = cast(str, item.uid) await self.coordinator.client.update_task( - self._project_id, uid, item.status == TodoItemStatus.COMPLETED, ) @@ -146,6 +147,7 @@ async def async_update_todo_item(self, item: TodoItem) -> None: # await self.coordinator.api.move(self._task_list_id, uid, previous=previous_uid) # await self.coordinator.async_refresh() + # def _order_tasks(tasks: list[dict[str, Any]]) -> list[dict[str, Any]]: # """Order the task items response.