[cpap] Add logbook entry for auto refill trigger#32
Conversation
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.
WalkthroughA 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
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
Integrations/ESPHome/Core.yaml (1)
248-253: LGTM - logbook integration correctly implemented.The
homeassistant.actionsyntax andlogbook.logparameters are correct. The placement beforepumpUntilFullensures 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
📒 Files selected for processing (1)
Integrations/ESPHome/Core.yaml
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
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_releasefires on the fluid input sensor and both switches are enabled, alogbook.logaction is called beforepumpUntilFullexecutes.Types of changes
Checklist / Checklijst:
If user-visible functionality or configuration variables are added/modified:
Summary by CodeRabbit