Skip to content

Fix: avoid unnecessary pump restart when switching between two active programs - #20

Open
julianhansen wants to merge 1 commit into
SPD13:mainfrom
julianhansen:fix/avoid-restart-on-program-switch
Open

Fix: avoid unnecessary pump restart when switching between two active programs#20
julianhansen wants to merge 1 commit into
SPD13:mainfrom
julianhansen:fix/avoid-restart-on-program-switch

Conversation

@julianhansen

Copy link
Copy Markdown

PR title

Fix: avoid unnecessary pump restart when switching between two active programs

Description

start_program() currently always calls stop_program() on the previously
active program before enabling the new one:

if device.active_program is not None:  # Stop previous program
    self.stop_program(deviceId, device.active_program)

This sends an explicit "disable" API PUT for the old program before the
"enable" PUT for the new one. In testing on an IntelliFlo/Pro3 VSF, this
causes the physical pump to fully stop for ~30 seconds and go through a
restart/ramp-up cycle every time you switch between two programs via a
switch.turn_on call in Home Assistant.

The official Pentair Home app does not do this - switching between two
already-running programs on the same device is a smooth, in-place profile
swap with no interruption to filtration. Confirmed by direct physical
observation (watched the pump while switching via the app vs. via this
integration - only this integration's stop-then-start sequence caused the
hard restart).

Fix

Skip the explicit stop_program() API call when swapping between two
programs on the same device. The old program's local running flag is
still set to False (so HA's switch entities report correct state), but
no "stop" command is sent over the wire - start_program()'s own "enable
new program" PUT is sufficient, and the pump handles the transition itself.

if device.active_program is not None:
    # Live-swap: mark the old program stopped LOCALLY only, without
    # sending an explicit stop_program() API call. The pump's own
    # firmware handles the transition as a smooth in-place profile
    # swap when a new program is enabled directly (confirmed by
    # physical observation: the official Pentair app does not stop
    # /restart the pump when switching between two running
    # programs - only this integration's prior stop-then-start
    # sequence forced a hard ~30s restart).
    for old_program in device.programs:
        if old_program.id == device.active_program:
            old_program.running = False

Note: stop_program() itself is untouched and still used correctly when
actually turning a program off with nothing replacing it (i.e. real
stop, not a swap) - this only changes the swap-between-two-programs path.

Testing

Applied and running live on an IntelliFlo/Pro3 VSF with the Relay Control
Board (5A/16A dual relay, one relay wired to an acid dosing pump gated by
"Speed/Flow Dependent"). Switching between two 14-minute programs (with a
different relay assignment on each) now keeps the pump running
continuously with no stop/restart - confirmed both via HA logbook (no gap
in speed/flow telemetry across the switch) and direct physical observation.

Possible follow-up (not in this PR, flagging for discussion)

The per-program switch entities can be a little confusing since HA's
switch domain is strictly on/off - toggle and turn_on are
functionally identical for these entities (both just call
start_program()), which isn't obvious from the entity type. Since these
programs are really a single mutually-exclusive choice (only one can be
"active" at a time), a select entity (one dropdown listing all
configured programs, "set to X" instead of N separate switches) might be
a more accurate fit for what's actually being modeled. Happy to take a
stab at that as a separate PR if there's interest - didn't want to bundle
an architecture change in with this bugfix.

… programs

start_program() unconditionally called stop_program() on the previously
active program before enabling the new one, sending an explicit "disable"
API PUT before the "enable" PUT. On an IntelliFlo/Pro3 VSF this causes the
physical pump to fully stop for ~30s and ramp back up on every program
switch via HA's switch.turn_on.

The official Pentair Home app does not do this - switching between two
already-running programs is a smooth in-place profile swap with no
interruption to filtration, confirmed by direct physical observation
(watched the pump switching via the app vs. via this integration - only
this integration's stop-then-start sequence caused the hard restart).

This skips the explicit stop_program() call when swapping between two
programs on the same device. The old program's local running flag is
still set to False so HA's switch entities report correct state, but no
stop command is sent over the wire.

Tested live on an IntelliFlo/Pro3 VSF with the Relay Control Board -
switching between two 14-minute programs now keeps the pump running
continuously, confirmed via HA logbook (no gap in speed/flow telemetry)
and direct physical observation.
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.

1 participant