Skip to content

feat: add count-based task triggers - #115

Open
Seidlm wants to merge 3 commits into
TJPoorman:mainfrom
Seidlm:feature/count-based-tasks
Open

feat: add count-based task triggers#115
Seidlm wants to merge 3 commits into
TJPoorman:mainfrom
Seidlm:feature/count-based-tasks

Conversation

@Seidlm

@Seidlm Seidlm commented Feb 28, 2026

Copy link
Copy Markdown

Count-Based Task Triggers

Closes #109

What

Adds support for count-based maintenance tasks alongside existing time-based tasks.

Example: After a washing machine has been turned on 30 times, a maintenance task (e.g., "Clean Tubes") becomes due. When marked complete, the counter resets to 0.

Changes

Backend (Python):

  • New trigger_type field: time (default, backward-compatible) or count
  • count_entity_id - HA entity to track (e.g., switch.washing_machine)
  • count_threshold - number of state changes before task is due
  • current_count - tracks current count, resets on complete
  • State change listener: increments counter when tracked entity transitions to "on"
  • New services: increment_count and reset_count
  • Storage migration: old tasks default to trigger_type="time"

Frontend (TypeScript + Panel):

  • Dynamic form: switches between time and count fields based on trigger_type
  • Task table shows count progress (e.g., "12 / 30") for count-based tasks
  • Edit dialog supports switching trigger type

Services:

  • home_maintenance.increment_count - manually increment a task's counter
  • home_maintenance.reset_count - reset counter without completing the task

Backward Compatibility

  • Existing time-based tasks work unchanged
  • Storage version bumped (minor: 1 ? 2) with safe defaults for new fields
  • No breaking changes to existing services or WebSocket API

Testing

  • Tested on Home Assistant (Hyper-V VM, HAOS) via HACS custom repository
  • Verified: count increments on entity state change, task becomes due at threshold, counter resets on complete
  • Existing time-based tasks unaffected

Michael Seidl and others added 3 commits February 28, 2026 09:31
Adds support for count-based maintenance tasks (e.g., after 30 washing
machine cycles, trigger a cleaning task).

New features:
- trigger_type field: 'time' (existing) or 'count' (new)
- Track HA entity state changes to increment counter
- Counter resets to 0 when task is completed
- New services: increment_count, reset_count
- Frontend: dynamic form for time vs count tasks
- Full backward compatibility with existing tasks

Closes TJPoorman#109
- New trigger_type 'runtime' monitors numeric sensor values (e.g., blade hours)
- Task becomes due when sensor delta exceeds configured threshold
- Auto-detects sensor resets (value drops below baseline)
- Baseline auto-set from current sensor value on task creation
- Baseline updates to current value on task completion
- Full frontend support: create, edit, display runtime tasks
- Backward compatible with existing time and count tasks
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.

have a Count be the enabler of a Task

1 participant