Repository navigation
Add priority field to the To-do entity model #1349
Replies: 4 comments 4 replies
|
You beat me to it :) I'm the developer of the linked PR and was just about to start this discussion. What I prepared: There are some integrations providing to-do lists. Each of their providers (Todoist, MS Todo, Nextcloud, Habitica...) support different priority range (1-4, 1-9...), and some may even work the completely oposite way (1 in some integration can mean top prioriy while 1 in other integrarion can mean lowest priority). Because of that, HA should implement priority in a way that allows any integration to map to it - RFC 5545.
This provides standardized way of internal priority storage, while allowing integrations to use whatever scale they want. The RFC 5545 (values 1-9) acts as interface between all integrations. So it will then also be possible to have todo item saved by todoist, and shown by "habitica manner", because the underlying data have the same format/range for all integrations. |
|
I am supportive of this proposal. Rationale:
|
|
I've added this to the architecture meeting agenda. |
|
We've discussed this proposal today in the architecture meeting. The conclusion is that we want a clearer motivation for restricting the core API to 3 levels instead of the 9 levels in the RFC. We notice that doing so, will cause all mentioned supporting integrations to lose resolution. A question that was put was: Would it be possible to collapse the 1-9 levels only in the frontend with appropriate naming, and keep all RFC 1-9 levels in the backend? |
Uh oh!
There was an error while loading. Please reload this page.
Background
The
TodoItemdataclass currently has six fields:summary,uid,status,due,description, andcompleted. Priority is missing — despite being one of the most common fields in task management. Four of the six major todo apps (Todoist, Apple Reminders, TickTick, Microsoft To Do) implement priority levels, and RFC 5545 defines aPRIORITYproperty forVTODOcomponents.There is prior work in home-assistant/core#159912 that added priority with CalDAV support. That PR was closed as stale after @MartinHjelmare noted that changes to an entity model require an architecture discussion first. This discussion fulfills that requirement.
Proposal
Add a
priorityfield to theTodoItemdataclass and aSET_PRIORITY_ON_ITEMfeature flag toTodoListEntityFeature. This follows the existingTodoItemFieldDescriptionextension pattern already used fordue_date,due_datetime, anddescription— no new machinery required.Data structure
PR #159912 stored priority as a raw integer (1-9 per RFC 5545). During review, @tr4nt0r raised that "most clients implement user-friendly schemes like low/medium/high, internally mapped to 1-9." I agree. The proposed approach is a
StrEnumwith three levels:Priority is
Nonewhen unset (matching RFC 5545 value 0 = undefined).Rationale for a
StrEnumover raw integers:TodoItemStatusis already aStrEnum. Priority should follow the same pattern."high"/"medium"/"low"in service calls. No need to know that Todoist uses 1-4 or iCal uses 1-9.Integration impact
Mapping table for integrations that support priority in their backends:
Of the 13 integrations currently implementing
TodoListEntity, 5-6 have a meaningful concept of priority. Shopping and recipe list integrations (Bring, Mealie, OurGroceries, etc.) would simply not setSET_PRIORITY_ON_ITEMin their supported features — no changes needed on their side.Implementation scope
The change is small and follows a well-established pattern:
const.py: AddTodoItemPriorityStrEnum,SET_PRIORITY_ON_ITEM = 128feature flag,ATTR_PRIORITYconstant__init__.py: Addpriority: TodoItemPriority | None = NonetoTodoItem, add oneTodoItemFieldDescriptionentry toTODO_ITEM_FIELDSservices.yaml: Addpriorityfield toadd_itemandupdate_itemwith a select selector and feature filterstrings.json: Add translatable strings for the priority field and its optionsEstimated ~50-80 lines changed. No breaking changes — the new field is optional and gated behind a feature flag. A companion frontend PR will be needed for the todo card to display and edit priority.
This same pattern (new
TodoItemfield + feature flag +TodoItemFieldDescriptionentry) could be reused for future additions like labels or assignee, but those are out of scope for this discussion.Prior art
All reactions