Repository navigation
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
… (1.1.1) The driver negated system/0/Dc/Battery/Power, so a charging battery showed as discharging. Victron's D-Bus docs give battery power as "positive when charged, negative when discharged", and dbus-systemcalc-py copies the battery service's /Dc/0/Power into that topic. victron.lua reads the same value at Modbus 842 and passes it through. This driver now does the same. A harness test feeds +1500 W and -900 W and checks the sign. Not measured on a real GX. Refs #255 Signed-off-by: Fredrik Ahlgren <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
What was wrong
victron_mqtt1.1.0 emitted battery power asW = -bat_w, with thecomment "Victron: positive power = discharging". Victron's own sources say
the opposite, so a charging battery most likely showed as discharging and
the reverse. The driver is read-only, so this affected telemetry, planning
input and the site balance, not commands.
Evidence
manifest's
upstream_docs): oncom.victronenergy.battery,/Dc/0/Poweris "W positive when charged, negative when discharged", and
/Dc/0/Currentthe same.
/Dc/0/Powerintosystem/0/Dc/Battery/Power, the topic this driverreads. Its own comment says "battery: Positive: charging battery", and it
sets the state to charging above +30 W and discharging below -30 W.
victron.luareads the same D-Bus value through Modbusregister 842 and does not negate it.
Change
drivers/lua/victron_mqtt.lua: passDc/Battery/Powerthroughunchanged. Version 1.1.1. Battery current was already passed through.
drivers/tests/test_victron_mqtt_battery_sign.py: feeds +1500 W and-900 W and checks the emitted sign. Both tests fail on
mainand passhere.
test_victron_mqtt_battery_limits.luaasserted the oldnegated value; they now expect Victron's sign.
Tests
make test-driver ID=victron_mqtt: 62 passed, 5 skipped.make check: 5227 passed, 929 skipped.Not verified on hardware
Nobody has measured this on a real GX. An owner can check it: while the
battery charges and its SoC rises, the battery
Win FTW should bepositive; while it discharges and the SoC falls, negative. On the GX itself,
N/<portal id>/system/0/Dc/Battery/Powershould have the same sign as FTWshows.
A keep-alive for this driver (#256) is a separate PR
stacked on this one.
Refs #255
🤖 Generated with Claude Code