[ux] Rename Invert Water Logic to Tank Refill Mode + auto-configure switches#34
[ux] Rename Invert Water Logic to Tank Refill Mode + auto-configure switches#34
Conversation
…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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis change renames the ESPHome template switch Changes
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
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)
📝 Coding Plan
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 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. |
There was a problem hiding this comment.
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
📒 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.
There was a problem hiding this comment.
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 | 🟡 MinorRename 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
📒 Files selected for processing (1)
Integrations/ESPHome/Core.yaml
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:
This ensures correct behavior out of the box without requiring users to understand which combination of switches is needed.
Types of changes
Checklist / Checklijst:
If user-visible functionality or configuration variables are added/modified:
Summary by CodeRabbit
Refactor
New Features