Skip to content

[ux] Rename Invert Water Logic to Tank Refill Mode + auto-configure switches#34

Open
bharvey88 wants to merge 3 commits intobetafrom
feat/tank-refill-mode-ux
Open

[ux] Rename Invert Water Logic to Tank Refill Mode + auto-configure switches#34
bharvey88 wants to merge 3 commits intobetafrom
feat/tank-refill-mode-ux

Conversation

@bharvey88
Copy link
Contributor

@bharvey88 bharvey88 commented Mar 11, 2026

Version: 26.3.2.1

What does this implement/fix?

Two UX improvements for the CPAP/refill use case:

1. Rename "Invert Water Logic" → "Tank Refill Mode"
Renames the switch name, id, and all 4 condition references throughout the file. "Tank Refill Mode" is immediately clear to end users; "Invert Water Logic" required understanding of the internal implementation.

2. Auto-configure related switches when Tank Refill Mode is toggled
Enabling/disabling the mode now automatically sets the other switches to the correct values for that mode, so users don't have to configure them manually:

Tank Refill Mode Stop Pump When Output Wet Stop Pump When Input Dry
Turns ON → ON → OFF
Turns OFF → OFF → ON

This ensures correct behavior out of the box without requiring users to understand which combination of switches is needed.

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

  • Refactor

    • Renamed the public switch from "Invert Water Logic" to "Tank Refill Mode".
  • New Features

    • Tank Refill Mode now synchronizes related pump switches when toggled.
    • Device evaluates Tank Refill Mode at boot to initialize pump-related switches.
    • All pump and refill control logic updated to use the new Tank Refill Mode while preserving existing behavior.

…switches

Renames the switch name, id, and all 4 condition references from
invert_water_logic to tank_refill_mode for clarity.

Adds on_turn_on/on_turn_off handlers to auto-configure related switches:
- Turn ON: Stop Pump When Output Wet → ON, Stop Pump When Input Dry → OFF
- Turn OFF: Stop Pump When Output Wet → OFF, Stop Pump When Input Dry → ON
@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e5eb2cb9-cc7d-495d-9032-5f71ed98c0e3

📥 Commits

Reviewing files that changed from the base of the PR and between 712e264 and 894a316.

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

Walkthrough

This change renames the ESPHome template switch invert_water_logic to tank_refill_mode, adds on_turn_on/on_turn_off side effects to toggle stop_pump_when_full, stop_pump_when_dry, and auto_refill switches, and introduces an on_boot handler to synchronize these switches at priority -20. All related references were updated accordingly across pump control, sensor, and safety logic.

Changes

Cohort / File(s) Summary
ESPHome Core switch & logic
Integrations/ESPHome/Core.yaml
Replaced the invert_water_logic switch with tank_refill_mode (updated name and id). Added on_turn_on and on_turn_off actions to control stop_pump_when_full, stop_pump_when_dry, and auto_refill switches. Added an on_boot event with priority -20 to synchronize these related switches. Updated all conditional checks and references to the new switch identifier, affecting pump control gating, auto-refill logic on fluid_input_sensor, pump safety, and destination-full logic.

Sequence Diagram(s)

sequenceDiagram
    participant Boot as ESPhome Boot
    participant Switch as `tank_refill_mode`
    participant Full as `stop_pump_when_full`
    participant Dry as `stop_pump_when_dry`
    participant AutoRefill as `auto_refill`
    participant Pump as Pump Control
    participant Sensor as fluid_input_sensor

    rect rgba(200,220,255,0.5)
    Boot->>Switch: evaluate state (on_boot, priority -20)
    Switch-->>Full: turn_on / turn_off (sync)
    Switch-->>Dry: turn_off / turn_on (sync)
    Switch-->>AutoRefill: turn_on / turn_off (sync)
    end

    rect rgba(220,255,200,0.5)
    Sensor->>Switch: check `tank_refill_mode` when auto-refill triggered
    Switch-->>Pump: gate pump_control (allow/deny)
    Pump->>Full: respect `stop_pump_when_full` condition
    Pump->>Dry: respect `stop_pump_when_dry` condition
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • TrevorSchirmer

Poem

🐰
A switch hopped names in morning's glow,
From Invert Logic to Refill Mode,
It nudges pumps to stop or flow,
Syncs at boot so circuits know,
Happy tank, and hop—let's go! 💧

🚥 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 title accurately summarizes the main changes: renaming a switch component and adding auto-configuration functionality for related switches.
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
  • Commit unit tests in branch feat/tank-refill-mode-ux
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can use Trivy to scan for security misconfigurations and secrets in Infrastructure as Code files.

Add a .trivyignore file to your project to customize which findings Trivy reports.

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Integrations/ESPHome/Core.yaml`:
- Around line 131-144: The Tank Refill Mode switch (id: tank_refill_mode) only
runs its on_turn_on/on_turn_off actions when explicitly toggled, leaving
dependent switches (stop_pump_when_full, stop_pump_when_dry) out of sync after a
cold boot; add a startup handler that reads the current state of
tank_refill_mode on boot and programmatically runs the same actions
(turn_on/turn_off of stop_pump_when_full and stop_pump_when_dry) so their states
match the restored/default state; implement this by adding an on_boot or
lambda-in-on_boot sequence that checks tank_refill_mode and invokes
switch.turn_on: stop_pump_when_full / switch.turn_off: stop_pump_when_dry when
mode is ON (and the reverse when OFF).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4ec21a63-f603-4591-96ca-9c2684fb0321

📥 Commits

Reviewing files that changed from the base of the PR and between 0cabc9c and 0ec11e9.

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

…de state

on_turn_on/on_turn_off only fire when explicitly toggled, not on boot
restore. Adds a priority -20 on_boot handler that reads tank_refill_mode
and sets stop_pump_when_full and stop_pump_when_dry accordingly so all
three switches are in sync after every reboot.
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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Integrations/ESPHome/Core.yaml (1)

457-461: ⚠️ Potential issue | 🟡 Minor

Rename the last remaining “inverted mode” string.

This log message still uses the retired term, so device logs will not match the new UI wording during support/debugging.

Suggested cleanup
-                  - logger.log: "Pump stopping - destination full (inverted mode)"
+                  - logger.log: "Pump stopping - destination full (tank refill mode)"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Integrations/ESPHome/Core.yaml` around lines 457 - 461, Update the logger
message in the then block that currently reads "Pump stopping - destination full
(inverted mode)" to use the new UI wording instead of the retired term; locate
the sequence of triggers (switch.is_on: tank_refill_mode, switch.is_off:
stop_pump_when_full, binary_sensor.is_on: fluid_input_sensor) and change the
logger.log string to the approved phrase (e.g., "Pump stopping - destination
full (reverse mode)").
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Integrations/ESPHome/Core.yaml`:
- Around line 142-145: The renamed switch (tank_refill_mode) will lose persisted
state from the old invert_water_logic entity because restore is by entity ID;
update the on_boot handler to perform state migration: in on_boot, read the
NVS/key used by invert_water_logic (or query the ESPHome persisted state for the
old entity id), and if the old value exists and is ON, programmatically set
tank_refill_mode to ON (and adjust dependent switches) before normal restore
runs; alternatively, if you prefer not to migrate in code, add a clear
breaking-change note to the integration docs notifying users to manually
re-enable tank_refill_mode after OTA upgrades.

---

Outside diff comments:
In `@Integrations/ESPHome/Core.yaml`:
- Around line 457-461: Update the logger message in the then block that
currently reads "Pump stopping - destination full (inverted mode)" to use the
new UI wording instead of the retired term; locate the sequence of triggers
(switch.is_on: tank_refill_mode, switch.is_off: stop_pump_when_full,
binary_sensor.is_on: fluid_input_sensor) and change the logger.log string to the
approved phrase (e.g., "Pump stopping - destination full (reverse mode)").

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6058d2dd-7cef-4b67-9713-300475b20344

📥 Commits

Reviewing files that changed from the base of the PR and between 0ec11e9 and 712e264.

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

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