Skip to content

[cpap] Add logbook entry for auto refill trigger#32

Merged
bharvey88 merged 1 commit intobetafrom
cpap-refill-logbook
Mar 9, 2026
Merged

[cpap] Add logbook entry for auto refill trigger#32
bharvey88 merged 1 commit intobetafrom
cpap-refill-logbook

Conversation

@bharvey88
Copy link
Contributor

@bharvey88 bharvey88 commented Mar 9, 2026

Version: 26.3.2.1

What does this implement/fix?

Adds a Home Assistant logbook entry when the pump is automatically triggered by the Auto Refill + Invert Water Logic combination (CPAP auto-fill use case).

Previously, the pump would run silently in this mode with no logbook record in HA. Now, when on_release fires on the fluid input sensor and both switches are enabled, a logbook.log action is called before pumpUntilFull executes.

Types of changes

  • Bugfix (fixed change that fixes an issue)
  • New feature (thanks!)
  • Breaking change (repair/feature that breaks existing functionality)
  • Dependency Update - Does not publish
  • Other - Does not publish
  • Website of github readme file update - Does not publish
  • Github workflows - Does not publish

Checklist / Checklijst:

  • The code change has been tested and works locally
  • The code change has not yet been tested

If user-visible functionality or configuration variables are added/modified:

  • Added/updated documentation for the web page

Summary by CodeRabbit

  • New Features
    • Auto-refill actions now generate logbook entries in Home Assistant to track and document when automatic tank refills are triggered due to low water levels.

Adds a homeassistant.action logbook.log call in the fluid_input_sensor
on_release handler so that HA logbook records when the pump is triggered
automatically by the CPAP auto refill + invert water logic mode.
@github-actions github-actions bot added the new-feature New feature label Mar 9, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

Walkthrough

A logbook entry action is added to the Fluid Input binary_sensor on_release conditional in ESPHome Core.yaml. This action logs "Auto refill triggered - tank level low" to Home Assistant's logbook before executing the existing pumpUntilFull script when the tank level drops.

Changes

Cohort / File(s) Summary
Logbook Entry Action
Integrations/ESPHome/Core.yaml
Added homeassistant.action to emit a logbook entry with name "PUMP-1" and message "Auto refill triggered - tank level low" in the Fluid Input binary_sensor on_release conditional block before pumpUntilFull execution.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested labels

new-feature

Suggested reviewers

  • TrevorSchirmer

Poem

🐰 A pump that speaks up with a log so divine,
When the tank runs low, it sends out a sign,
"Auto refill triggered!" the message rings clear,
Through Home Assistant's logbook for all to hear! 📝

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely summarizes the main change: adding a logbook entry for the auto refill trigger in the CPAP module.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch cpap-refill-logbook

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
Integrations/ESPHome/Core.yaml (1)

248-253: LGTM - logbook integration correctly implemented.

The homeassistant.action syntax and logbook.log parameters are correct. The placement before pumpUntilFull ensures the event is logged when the auto refill is triggered.

Optional: Consider using the ${name} substitution for the logbook entry name to maintain consistency with the device name defined on line 2:

♻️ Suggested change
              - homeassistant.action:
                  action: logbook.log
                  data:
-                   name: "PUMP-1"
+                   name: "${name}"
                    message: "Auto refill triggered - tank level low"

,

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Integrations/ESPHome/Core.yaml` around lines 248 - 253, Replace the hardcoded
log name "PUMP-1" in the homeassistant.action logbook.log call with the device
name substitution to keep names consistent; update the logbook.log data name to
use the ${name} template variable so the log entry aligns with the device name
defined for the integration and keep the homeassistant.action and subsequent
script.execute: pumpUntilFull sequence intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@Integrations/ESPHome/Core.yaml`:
- Around line 248-253: Replace the hardcoded log name "PUMP-1" in the
homeassistant.action logbook.log call with the device name substitution to keep
names consistent; update the logbook.log data name to use the ${name} template
variable so the log entry aligns with the device name defined for the
integration and keep the homeassistant.action and subsequent script.execute:
pumpUntilFull sequence intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 13916c16-865e-40bc-a521-c75987401aec

📥 Commits

Reviewing files that changed from the base of the PR and between bb2c678 and 23a8b4c.

📒 Files selected for processing (1)
  • Integrations/ESPHome/Core.yaml

@bharvey88 bharvey88 merged commit bd58d14 into beta Mar 9, 2026
9 checks passed
@bharvey88 bharvey88 deleted the cpap-refill-logbook branch March 9, 2026 20:42
bharvey88 added a commit that referenced this pull request Mar 10, 2026
Replaces the homeassistant.action logbook.log approach from #32 with an
ESPHome event entity, which surfaces natively in the HA logbook without
requiring API actions to be enabled on the device.

Fires three event types:
- auto_refill_triggered: CPAP auto refill + invert water logic triggers pump
- pump_started: pump_control turns on and conditions are met
- pump_stopped: pump_control turns off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants