Skip to content

fix(givtcp): keep the apps.yaml battery_scaling and default an All-in-One to 13.5 kWh usable (#6520) - #6526

Merged
springfall2008 merged 4 commits into
mainfrom
fix/givtcp-battery-scaling-user-wins
Dec 4, 2026
Merged

springfall2008 merged 4 commits into
mainfrom
fix/givtcp-battery-scaling-user-wins

Conversation

@springfall2008

@springfall2008 springfall2008 commented Dec 4, 2026 •

Copy link
Copy Markdown
Owner

Fixes #6520.

Problem

Since v9.12.0 (#6514), GivTCP discovery binds soc_max to GivTCP's Battery_Capacity_kWh. For a directly connected All-in-One that figure is gross: GivTCP's register library computes HR55 Ah x the pack voltage (307 V in GivTCP 3.6+, 317 V in 3.0-3.2), giving about 15.9-16.8 kWh for 13.5 kWh usable. GivTCP itself uses 13.5 kWh per AIO behind a Gateway, but not for a direct one.

The documented correction, a hand-set battery_scaling, was then lost in one of two ways:

  • No state of health reported (the AIO case). GivTCP reports an AIO's battery as HV BCU stacks, without the per-module Battery_Capacity / Battery_Design_Capacity that battery_soh() reads. The discovery record then binds no battery_scaling, and the coordinator resolves an unbound binding setting at a discovered slot to None, which deleted the apps.yaml value. Predbat fell back to 1.0 and planned with the gross capacity.
  • State of health reported. battery_scaling was bound with overwrite to battery_dod_soh (SoH x givtcp_battery_dod, default 1.0), replacing the user's value.

Change

  1. The user's value wins. battery_scaling joins GIVTCP_AUTO_CONFIG_USER_WINS_KEYS, so the coordinator keeps a scalar or per-inverter apps.yaml value in both cases above. Discovery fills the key only when apps.yaml is silent.
  2. An All-in-One defaults to its usable size. GivTCPRest.is_all_in_one() identifies a direct AIO from raw.invertor.device_type_code (80xx). Every GivTCP version publishes that code, unlike Invertor_Type, whose wording changes between versions ("Gen 1 All in One" / "Na All_in_one" / "All_in_one"). 81xx (HV Gen 3), 82xx (AIO hybrid), 83xx (Gen 4) and 70xx (Gateway) are excluded. model_depth_of_discharge() gives 13.5 / reported capacity (0.8036 at 16.8, 0.8491 at 15.9), or None when the capacity is missing or already 13.5 or below.
    • givtcp_battery_dod, when set, overrides the model figure.
    • battery_dod / battery_dod_soh are now published, and battery_scaling claimed, when either SoH or a model DoD is known. An unknown SoH counts as 1.0 in the product, and no battery_soh sensor is published for it.
  3. Docs (docs/apps-yaml.md): givtcp_battery_dod describes the AIO default and that an apps.yaml battery_scaling wins; the AIO tip says GivTCP REST users can leave battery_scaling out.

Trade-off: a user with a hand-set battery_scaling no longer gets the reported state of health folded in. That matches export_limit and the behaviour before v9.12.0.

Not done here: Stack_SOH, which GivTCP reports for HV stacks, could feed SoH for an AIO. GivTCP could also report 13.5 kWh for a direct AIO itself, as it already does behind a Gateway.

Tests

  • test_battery_scaling_apps_yaml_value_wins: SoH reported; 0.85 and [0.85] kept; bound to the combined sensor when apps.yaml is silent.
  • test_battery_scaling_kept_when_no_health_is_reported: the AIO shape (no per-module capacities). On main this returns None, the reported bug.
  • test_all_in_one_is_identified_from_the_device_type_code: the DTC families and the implied DoD values.
  • test_all_in_one_scaling_defaults_to_the_usable_capacity: real coordinator; DoD 0.8036, battery_scaling bound, no SoH sensor, givtcp_battery_dod override.

The first two fail against the unfixed givtcp.py. givtcp_component, givtcp_rest, discovery_automatic, bindings, coordinator, discovery_contract and debug_cases pass, and pre-commit passes on the changed files. Full suite not run locally.

The AIO identification comes from reading GivTCP (2.4.3, 3.0.1, 3.2, 3.6, 3.7.0) and givenergy-modbus source; no capture from a real direct AIO is in the repo yet.

🤖 Generated with Claude Code

GivTCP discovery (#6514) claimed battery_scaling with overwrite, pointing it at
the SoH x DoD sensor. GivTCP reports the gross capacity for some batteries (an
All-in-One gives ~16.8 kWh for 13.5 kWh usable) and no depth of discharge, so
DoD defaulted to 1.0 and the hand-set battery_scaling the docs recommend was
silently replaced: Predbat planned with the gross size.

battery_scaling joins GIVTCP_AUTO_CONFIG_USER_WINS_KEYS, so the coordinator
keeps a scalar or per-inverter apps.yaml value and discovery fills the key only
when apps.yaml is silent. Docs for givtcp_battery_dod and the AIO tip updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the BOT_REVIEW Trigger an autotriage label Dec 4, 2026
…e 13.5 kWh (#6520)

GivTCP reports a directly connected All-in-One's gross capacity: its register
library multiplies HR55 Ah by the pack voltage (307 V in 3.6+, 317 V in
3.0-3.2), giving about 15.9-16.8 kWh for 13.5 kWh usable. GivTCP itself uses
13.5 per AIO behind a Gateway, but not for a direct one.

The AIO is identified from raw.invertor.device_type_code (80xx), which every
GivTCP version publishes, rather than Invertor_Type, whose wording changes
between versions. Its implied DoD is 13.5 / reported capacity; givtcp_battery_dod
still overrides it. GivTCP reports an AIO's battery as HV stacks with no
per-module capacities, so there is no SoH: battery_dod/battery_dod_soh are now
published and battery_scaling claimed when either SoH or a model DoD is known,
with an unknown SoH counting as 1.0.

Also adds a regression test for the reported path: on main, with no SoH the
record binds no battery_scaling and the coordinator resolved the unbound
setting to None, deleting the user's apps.yaml value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@springfall2008 springfall2008 changed the title fix(givtcp): keep the apps.yaml battery_scaling over discovery (#6520) fix(givtcp): keep the apps.yaml battery_scaling and default an All-in-One to 13.5 kWh usable (#6520) Dec 4, 2026

@springfall2008 springfall2008 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated comment from the triage bot.

Verdict: 🔴 Red - Needs a closer look

The user-wins rule does not do what the PR describes on a stock install: the shipped default apps.yaml and the GivTCP template both pin battery_scaling: [1.0], a per-slot apps.yaml entry counts as the user's value, so discovery stops binding the SoH x DoD sensor at all - the AIO default never applies and the SoH derate main binds today is lost.

Reviewed head b92a4d791745d4a0088127c47a6bd3117d51641e: 2 findings inline (apps/predbat/givtcp.py:301, docs/apps-yaml.md:2904) and 1 in this body (apps/predbat/givtcp.py:1375).

apps/predbat/givtcp.py:1375

build_discovery()'s docstring still says reports_soh is "battery state of health reported, which battery_scaling needs". After this change battery_scaling is bound when either SoH or a model DoD is known, so an AIO record binds it while carrying no reports_soh flag. Reword to describe both probes (or to say which battery_soh needs). It is only an informational flag for GivTCP, so nothing behaves wrongly - but the sentence now contradicts _record_entities() and the new AIO path.

Comment thread apps/predbat/givtcp.py Resolved
Comment thread docs/apps-yaml.md Resolved
@springfall2008 springfall2008 removed the BOT_REVIEW Trigger an autotriage label Dec 4, 2026
CI and others added 2 commits December 4, 2026 20:50
Review of #6526: the shipped apps.yaml and GivTCP template pin
battery_scaling: [1.0], which as a user-wins key kept 1.0 on every install
made from them - losing the SoH derate main binds and never applying the
All-in-One default. battery_scaling is now the user's only when apps.yaml gives
it more than the neutral 1.0 (givtcp_user_wins_keys(), used by the coordinator
opt-in, the legacy plan and the checker alike). The neutral line is dropped
from both shipped files, the docs say 1.0 counts as not set, and the
build_discovery() docstring no longer ties battery_scaling to reports_soh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@springfall2008

Copy link
Copy Markdown
Owner Author

Automated reply (Claude Code session).

The review-body finding on apps/predbat/givtcp.py:1375 is fixed in 0472324. The build_discovery() docstring now says reports_soh is one of the two factors battery_dod_soh combines, and that battery_scaling is bound when it or a model depth of discharge is known, so an All-in-One binds it without the flag.

Quality gate on the pushed head: ./run_pre_commit passes, including the quick suite (486 tests). debug_cases passes too.

@springfall2008
springfall2008 enabled auto-merge (squash) December 4, 2026 21:02
@springfall2008
springfall2008 merged commit d814432 into main Dec 4, 2026
7 checks passed
@springfall2008
springfall2008 deleted the fix/givtcp-battery-scaling-user-wins branch December 4, 2026 21:02
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.

GivEnergy AIO incorrect battery capacity in v9.12.0

1 participant