Skip to content

Add per-task total_increasing completion counter sensor - #69

Draft
gensyn with Copilot wants to merge 4 commits into
mainfrom
copilot/add-number-of-times-completed-sensor
Draft

Add per-task total_increasing completion counter sensor#69
gensyn with Copilot wants to merge 4 commits into
mainfrom
copilot/add-number-of-times-completed-sensor

Conversation

Copilot AI commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

This adds a new sensor per task that tracks how many times the task has been completed, enabling trend/statistics use-cases. The counter increments only on actual “mark as done” actions (button/service), and does not change when setting last_done directly.

  • Completion counter model

    • Added times_completed to TaskTrackerCoordinator.
    • Increment happens in async_mark_as_done(...) after a successful state transition path.
    • async_set_last_done_date(...) remains non-incrementing.
  • New sensor entity

    • Added TaskTrackerTimesCompletedSensor for each task device.
    • Sensor uses state_class: total_increasing.
    • Stable entity naming/unique ID pattern:
      • sensor.task_tracker_<task_name>_times_completed
      • <entry_id>_times_completed
    • Startup restore logic keeps the highest known counter value to avoid regressions on reload.
  • Coverage updates

    • Added focused integration assertions for:
      • sensor creation + state_class
      • increment via task_tracker.mark_as_done
      • increment via task button press
      • no increment via task_tracker.set_last_done_date
# coordinator.py
async def async_mark_as_done(self, today: date) -> None:
    ...
    self.times_completed += 1
    self._async_notify_listeners()

Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com>
Copilot AI changed the title [WIP] Add sensor to track number of times completed for tasks Add per-task total_increasing completion counter sensor Aug 9, 2026
Copilot AI requested a review from gensyn August 9, 2026 20:46
Copilot AI and others added 2 commits August 9, 2026 20:53
Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com>
Co-authored-by: gensyn <36128035+gensyn@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: a 'number of times completed' sensor

2 participants