Skip to content

fix: disarm schedule slot after momentary runs and settings saves - #35

Merged
dalyem merged 1 commit into
masterfrom
fix/issue-31-schedule-cleanup
Jul 14, 2026
Merged

dalyem merged 1 commit into
masterfrom
fix/issue-31-schedule-cleanup

Conversation

@dalyem

@dalyem dalyem commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #31 — pressing the momentary action (Run Once) flipped Schedule mode ON in the Aroma-Link app, leaving the device permanently "diffusing" with power re-enabling itself; schedules deleted in the app reappeared on the next press.

Plan / root-cause write-up: https://plan.dalem.dev/p/s3egdgad

Root cause

set_scheduler always wrote schedule slot 0 as enabled: 1, 00:00–23:59, all 7 days, and no code path ever disabled it. Per docs/API.md: "All slots must be disabled (enabled=0) to stop scheduled operation — otherwise the device will auto-toggle power based on time windows." Both Run Once and Save Settings wrote that always-on slot and left it armed.

For reference, the original Memberapple/ha_aromalink does the same thing — its momentary run just felt schedule-free because it hardcoded a 5s run and a 900s pause, so the leftover schedule only pumped every 15 minutes. This fix goes beyond both repos by actually cleaning the slot up.

Changes

  • set_scheduler(..., enabled=True) — slot 0 is written with the requested enabled state; work/pause durations are persisted to the device either way.
  • run_diffuser — when the timed run ends, the slot is disarmed before the off command (so the device can't re-activate itself in between); if turn-on fails mid-sequence the slot is disarmed immediately.
  • Save Settings button — persists durations with enabled=0 instead of silently enabling 24/7 scheduled operation.
  • set_scheduler service — unchanged default (enabled: true), new optional enabled: false to save durations with scheduling off, which is also a first-class way to clear a stuck schedule (the manual app workaround from the issue).

Behavior change to be aware of

Anyone who used Save Settings as an implicit "run 24/7" toggle must now use the Power switch (manual onOff=1 uses the saved durations per docs/API.md) or the set_scheduler service.

Verification

  • Orchestration validated with a stubbed-coordinator script: happy path issues workSet(enabled=1) → onOff=1 → workSet(enabled=0) → onOff=0; turn-on failure disarms the slot; invalid durations still short-circuit before any API call.
  • All files compile; hassfest + HACS validation on this PR.
  • Hardware test for @dalyem: press Run Once → single diffusion → app shows Schedule OFF, no recreated entries → device stays off past the old pause window (>2 min) → durations retained. Save Settings → durations update in app, Schedule stays OFF.

Rollback

Single revertable commit; no config/entity migrations involved.

🤖 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: 30 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: 0d35b2c4-cb10-4176-a84d-74dacca7d193

📥 Commits

Reviewing files that changed from the base of the PR and between 8ae0cbd and 877f0b1.

📒 Files selected for processing (6)
  • README.md
  • custom_components/aromalink_ha_integration/AromaLinkDeviceCoordinator.py
  • custom_components/aromalink_ha_integration/__init__.py
  • custom_components/aromalink_ha_integration/button.py
  • custom_components/aromalink_ha_integration/const.py
  • custom_components/aromalink_ha_integration/services.yaml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-31-schedule-cleanup

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.

set_scheduler always wrote slot 0 as an enabled 00:00-23:59 schedule for
all seven days and nothing ever disabled it, so any Run Once press or
Save Settings press switched the device into permanent scheduled
operation: the app shows Schedule ON, status sticks on diffusing, and
power re-enables itself (issue #31). Deleting schedules in the app only
helped until the next press.

- set_scheduler gains an enabled flag; durations are persisted either way
- run_diffuser disarms the slot when the run ends (or when turn-on fails)
  before sending the off command, so the device cannot re-activate itself
- Save Settings persists durations with enabled=0 instead of silently
  enabling 24/7 operation
- the set_scheduler service keeps enabled=true by default and now accepts
  enabled: false to clear a stuck schedule

Fixes #31

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dalyem
dalyem force-pushed the fix/issue-31-schedule-cleanup branch from b2d8018 to 877f0b1 Compare July 7, 2026 05:29
@dalyem
dalyem merged commit 1ab0317 into master Jul 14, 2026
6 checks passed
@dalyem
dalyem deleted the fix/issue-31-schedule-cleanup 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.

Momentary action triggers "Schedule" to be switched on

1 participant