Skip to content

Hold charging: freeze_charge with a target below the SoC discharges down to it - #50

Merged
piomar123 merged 2 commits into
mainfrom
hold-charge-target-soc
Oct 23, 2026
Merged

piomar123 merged 2 commits into
mainfrom
hold-charge-target-soc

Conversation

@piomar123

@piomar123 piomar123 commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Why

Predbat's "Hold charging" with a limit below the current SoC means "discharge down to the limit, then hold". It sends freeze_charge with the limit as target_soc and raises the reserve to limit+1. The executor ignored target_soc for freeze_charge and froze at the current SoC at once. On 2026-10-11 a battery at 90% that was planned to fall to 86% stayed at 90% (depth 90 was written at 12:01).

What

  • control.py: freeze_charge now keeps target_soc.
    • While the SoC is above the target, the executor stays in auto (reason holding above target_soc).
    • Once the SoC has been at the target for TARGET_DEBOUNCE, it freezes there and stays frozen (latched).
    • With no target, or a target at or above the SoC (Predbat's FrzChrg, car or iBoost holds), it still freezes at the current SoC at once.
  • MQTT_TOPICS.md: the control/set table documents target_soc for freeze_charge. The HA script and apps.yaml changes that pass it are in Docs: HA + Predbat setup as deployed, Python 3.12, systemd service #51 (that PR works with or without this one; without it the target is ignored as before).

Deployed

Running on my Pi since 2026-10-11, as part of hold-charge-below-soc: the same commit, on top of #49. This branch is that commit rebased onto main on its own.

Test plan

  • pytest -q tests: 596 passed. tests/test_control.py has new cases for a hold above the target, the debounce, the latch, and a target at or above the SoC.

🤖 Generated with Claude Code

piomar123 and others added 2 commits October 11, 2026 20:07
…own to it

Predbat's "Hold charging" (limit below the SoC) sends freeze_charge with the
limit as target_soc and raises the reserve to limit+1, meaning "discharge down
to the reserve, then hold". The executor froze at the current SoC at once and
ignored both, so a 90% battery planned to fall to 86% stayed at 90%
(2026-10-11, depth 90 written at 12:01).

freeze_charge now keeps target_soc. While the whole SoC is above it the
executor stays in AUTO; after TARGET_DEBOUNCE at the target it freezes there
and stays frozen. No target, or a target at or above the whole SoC (FrzChrg,
car/iBoost hold), still freezes at the current SoC at once.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@piomar123
piomar123 merged commit 2d558db into main Oct 23, 2026
1 check passed
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