Repository navigation
fix(givtcp): keep the apps.yaml battery_scaling and default an All-in-One to 13.5 kWh usable (#6520) - #6526
Conversation
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>
…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
left a comment
There was a problem hiding this comment.
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.
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>
|
Automated reply (Claude Code session). The review-body finding on Quality gate on the pushed head: |
Fixes #6520.
Problem
Since v9.12.0 (#6514), GivTCP discovery binds
soc_maxto GivTCP'sBattery_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:Battery_Capacity/Battery_Design_Capacitythatbattery_soh()reads. The discovery record then binds nobattery_scaling, and the coordinator resolves an unbound binding setting at a discovered slot toNone, which deleted the apps.yaml value. Predbat fell back to 1.0 and planned with the gross capacity.battery_scalingwas bound with overwrite tobattery_dod_soh(SoH xgivtcp_battery_dod, default 1.0), replacing the user's value.Change
battery_scalingjoinsGIVTCP_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.GivTCPRest.is_all_in_one()identifies a direct AIO fromraw.invertor.device_type_code(80xx). Every GivTCP version publishes that code, unlikeInvertor_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_sohare now published, andbattery_scalingclaimed, when either SoH or a model DoD is known. An unknown SoH counts as 1.0 in the product, and nobattery_sohsensor is published for it.docs/apps-yaml.md):givtcp_battery_doddescribes the AIO default and that an apps.yamlbattery_scalingwins; the AIO tip says GivTCP REST users can leavebattery_scalingout.Trade-off: a user with a hand-set
battery_scalingno longer gets the reported state of health folded in. That matchesexport_limitand 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.85and[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 returnsNone, 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_scalingbound, no SoH sensor,givtcp_battery_dodoverride.The first two fail against the unfixed
givtcp.py.givtcp_component,givtcp_rest,discovery_automatic,bindings,coordinator,discovery_contractanddebug_casespass, 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