Skip to content

fix: restore On Count and Pump Count sensors with long-term statistics - #37

Merged
dalyem merged 1 commit into
masterfrom
fix/issue-2-restore-count-sensors
Jul 14, 2026
Merged

dalyem merged 1 commit into
masterfrom
fix/issue-2-restore-count-sensors

Conversation

@dalyem

@dalyem dalyem commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #2 — restores the raw On Count and Pump Count sensors that today's control reorganization (#33) replaced, and enables long-term statistics on them.

Plan / write-up: https://plan.dalem.dev/p/gpnehhje

Context: where issue #2 actually stands

  • The originally reported bug (counts imported once at setup, never updated) was fixed in March: the coordinator polls both device-list endpoints and merges them, and only the legacy v1 list carries runCount/airPumpCount. The reporter confirmed on 2026-03-28 that the counts update (~daily). Per docs/API.md, that daily-ish cadence is device-driven — the counters "only update when the device pushes data upstream on its own schedule — cannot be forced via API" — so it cannot be made faster from our side.
  • However, PR feature: Reorganize controls, add API docs #33 (merged today) removed On Count (→ Total Run Time) and repurposed Pump Count (→ Total Diffusion Time) under new unique_ids — on upgrade, the reporter's counter entities (473 activations / 92,705 diffusions at report time) would go dead.

Changes

  • Re-add AromaLinkOnCountSensor and AromaLinkPumpCountSensor alongside the derived time sensors (7 sensors per device), with the original unique_ids, names, units, and icons — existing entities, dashboards, automations, and recorded history resume seamlessly with identical values.
  • Both raw counters get state_class = TOTAL_INCREASING, so HA now records proper long-term statistics (the reporter's use case is tracking activity over days); device-side counter resets are handled gracefully by that state class.
  • Rename feature: Reorganize controls, add API docs #33's AromaLinkPumpCountSensor class → AromaLinkTotalDiffusionTimeSensor (it computes diffusion time now, not a pump count). Internal-only: unique_ids derive from the sensor-type string, so no entity impact.
  • README documents all sensors, including the semantics note from docs/API.md that the web API's runCount (surfaced by On Count) accumulates work seconds, not activations — the values have always been consistent; only the unit label is historical. Kept as-is deliberately: changing the unit would break statistics continuity for a cosmetic fix.

Verification

Stubbed sensor tests, all passing: unique_ids match the pre-2.x registry format ({user}_{device}_on_count / _pump_count); raw values pass through unscaled (1,569,411 / 8,531 from the docs' sample payload); derived sensors unchanged (435.95 h / 23.7 h); state_class present on the raw counters only; missing data returns None without crashing. All files compile; hassfest + HACS on this PR.

Hardware test for @dalyem: after upgrading, On Count / Pump Count keep their entity_ids and prior magnitudes, and tick up when the device next pushes its report (~daily). Total Run Time / Total Diffusion Time continue alongside.

Rollback

Single revertable commit, sensor platform + README only.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@dalyem, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 29 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 39a99179-cf03-452e-a5a2-f282049385ec

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae0cbd and 9ed6b04.

📒 Files selected for processing (2)
  • README.md
  • custom_components/aromalink_ha_integration/sensor.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-2-restore-count-sensors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The control reorganization (#33) replaced the raw On Count / Pump Count
sensors with derived Total Run Time / Total Diffusion Time sensors under
new unique_ids, which orphans the counter entities that issue #2's
reporter (and anyone tracking device activity) relies on.

Bring the raw counters back alongside the derived sensors with their
original unique_ids, names, and units so existing registry entries,
dashboards, and history resume seamlessly, and mark them
TOTAL_INCREASING so Home Assistant records long-term statistics. The
class that computes Total Diffusion Time is renamed to match what it
now measures (entity-neutral; unique_ids derive from the type string).

The underlying polling was already fixed in March (counts come from the
v1 device list, which the coordinator merges on every poll); the counters
move only when the device pushes data upstream, roughly daily.

Closes #2

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dalyem
dalyem force-pushed the fix/issue-2-restore-count-sensors branch from 21ce1d7 to 9ed6b04 Compare July 7, 2026 05:29
@dalyem
dalyem merged commit 8525aa0 into master Jul 14, 2026
6 checks passed
@dalyem
dalyem deleted the fix/issue-2-restore-count-sensors branch July 14, 2026 02:48
dalyem added a commit that referenced this pull request Jul 14, 2026
Covers the configurable SSL bypass (#32), the Power/Fan control split
and API reference (#33), schedule disarming after momentary runs (#35),
the stale-poll shield (#36), the restored count sensors with long-term
statistics (#37), and the MIT license adoption.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.

On Count / Pump Count not updating

1 participant