Conversation
The gateway's SoC estimate for chargers that do not report SoC read car_charging_battery_size with an int default and no index. The arg is a per-car list (entries: num_cars), so: - a list, e.g. [10.5] or a list of entity ids, failed int coercion, logged "Return bad int value" every telemetry update, set had_errors, and fell back to 100 kWh; - a fractional size such as 10.5 kWh was truncated to 10. Read slot 0, where gateway auto-config places the charger, with a float default. A scalar value still resolves as before. The new test drives the gateway through the real get_arg rather than a stub, for a per-car number list, a per-car entity-pointer list, a single entity pointer and a single fractional number; it fails against the previous line. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a gateway EV charger doesn't report SoC, the gateway estimates it from the session energy and
car_charging_battery_size. It reads that arg with an int default and no index:car_charging_battery_sizeis a per-car arg (entries: num_cars), so this fails two ways:[10.5]or[sensor.my_car_battery_size]fails int coercion.get_argthen logsReturn bad int value [...]and setshad_errorson every telemetry update, so the warning sticks in the status. It falls back to 100 kWh, and the SoC estimate is off by the ratio of the real battery to 100.The planner already reads this arg with
100.0, index=car_n(fetch.py), so the gateway was the only unindexed reader.Fix
Gateway EV auto-config places the charger in car slot 0, so read that slot with a float default. A scalar value still resolves as before, because index 0 on a non-list is a no-op.
Tests
The existing
TestEvTelemetrytests replaceget_argwith a lambda, so they can't see how the value is resolved. The newtest_ev_soc_battery_size_through_get_argruns_inject_ev_entitiesagainst the realPredBat.get_argfor four forms of the arg:Each must give 50% for 5.25 kWh delivered into a 10.5 kWh battery, without setting
had_errors. It runs fromrun_gateway_testswhen aPredBatis passed, and restores the args, entity and status it touches../run_all --test gateway: passes, including the new test.expected SoC 50.0 from a 10.5 kWh battery, got 5.2.🤖 Generated with Claude Code