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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3fa6fd050f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if at_ms == nil or at_ms < last_full_publish_ms - REPUBLISH_SLACK_MS then | ||
| return nil |
There was a problem hiding this comment.
Track republish membership instead of completion-relative age
If a full republish spans more than five seconds across polls, values received near its beginning are incorrectly treated as absent when full_publish_completed arrives. Reproducing this with the Lua harness—receiving SoC at 2 s and completion plus battery power at 8 s—drops the freshly republished SoC from battery telemetry. An unchanged SoC or temperature can then remain missing until the next full republish, normally 120 seconds later. Track whether each value arrived during the republish, rather than assuming every included value arrived within five seconds of completion.
Useful? React with 👍 / 👎.
Venus OS publishes MQTT values only while some client sends a read request to R/<portal ID>/keepalive (dbus-flashmq README). The driver sent none, so on a GX with no other client its values stopped after 60 s. The driver learns the portal ID from the retained N/<portal ID>/system/0/Serial, sends a keep-alive every 30 s with suppress-republish, and an empty payload (a full republish) at first, when the GX speaks again after a silent link, and every 120 s. A system SoC, voltage, current or temperature that the last completed full republish did not resend is left out. When the host refuses to publish, as FTW does for a read-only driver from the signed channel, the driver logs once, keeps reading and tries again every 30 s. Harness tests cover the topic, payloads, timing, refusal and the republish rule. Not checked on a real GX. Refs #256 Signed-off-by: Fredrik Ahlgren <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The republish rule assumed a poll about every second: a value that came one poll before full_publish_completed on a host polling every 5 s or slower was dropped as if the GX no longer had it. Each poll now has a stamp, its clock and its number, and a value counts as resent when it arrived within two polls or 5 s of the completion. When N/<portal ID>/system/0/Serial names another portal ID, the driver now follows the new GX, forgets the old one's values and asks the new one for a full republish. Harness tests: a republish straddling a 5.5 s poll, and a changed portal ID. Both fail on the previous commit. Refs #256 Signed-off-by: Fredrik Ahlgren <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Builds on #266 (victron_mqtt 1.1.1, the battery sign), now on
main.What was wrong
Venus OS publishes MQTT values only while some client sends a read request
to
R/<portal ID>/keepalive.victron_mqttsent none, so on a GX with noother MQTT client its values stopped arriving 60 s after the last
keep-alive from anyone, and the driver went stale.
Sources
upstream_docs): the topicR/<portal ID>/keepalive; a 60 s timeout; anempty payload asks for a full republish, which ends with
N/<portal ID>/full_publish_completed; the option{"keepalive-options": ["suppress-republish"]}keeps the GX awake withoutone. Victron suggests that option on a timer and an empty payload "when
the state of the program requires it". Its example sends one every 30 s.
Item::should_be_retainedpublishesN/<portal ID>/system/0/Serialretained, the one topic a client getsbefore any keep-alive.
State::handle_keepalivekeeps the GX awake for60 s per keep-alive.
origin/master,go/internal/drivers/lua.goandhost.go:host.mqtt_publish(topic, payload)returns nothing when it sends and anerror text when it refuses.
mqtt_publishis in the linux-edge profilein
spec/host-api-profile.json, so Blixt has it too.Change (victron_mqtt 1.2.0)
N/+/system/0/SerialandN/+/full_publish_completed, andtakes the portal ID from the topics it receives. When
system/0/Serialnames another portal ID, it follows the new GX, forgets the old one's
values and asks the new one for a full republish.
R/<portal ID>/keepaliveevery 30 s, also on polls that bring nomessages. The payload is
suppress-republish, except at first, when theGX speaks again after 60 s of silence, and every 120 s. Then it is empty,
which asks for a full republish.
battery temperature now have a bound, as the driver's comment asked for.
A full republish resends every value the GX has, so a value that arrived
well before the latest
full_publish_completedwas not in it and is leftout. Each poll has a stamp (its clock and its number); a value counts as
resent when it arrived within two polls or 5 s of the completion, so a
republish that straddles a poll on a host polling every 5 s or slower is
not misread. Before any full republish has completed, they behave as
before.
The BMS limits keep their own 60 s rule.
reading and tries again every 30 s, never faster.
Minor version, since the driver now publishes to the GX.
Tests
drivers/tests/test_victron_mqtt_keepalive.pyruns 13 harness scenarios:subscriptions, no keep-alive before a portal ID, the first one full, the
30 s and 120 s timing on idle polls, a full republish when the GX speaks
after a silent link, refusal (one warning, retry after 30 s, recovery), no
bound without a completed republish, a value a republish left out, a value
every republish resends, a republish straddling a 5.5 s poll, a changed
portal ID, and no telemetry from an idle poll. The harness
replaces the mock's
mqtt_publishwith FTW's return convention. Seven ofthe first eleven fail on #266's driver; the four that pass there check
behaviour that must not change. The 5.5 s poll and portal ID scenarios fail
on this PR's first commit and pass now.
make checkonmainc9ac63d: 5243 passed, 928 skipped.FTW refuses this publish for a channel install
FTW's
allowWriterefuses everymqtt.publishfrom a driver that runsunder a runtime policy, and FTW binds one to each
control: falsedriverinstalled from the signed channel ("read-only driver cannot write"). The
bundled copy runs without a policy and can send it. So once this version
reaches a site through the channel, FTW will refuse the keep-alive and the
GX keeps publishing only while another client keeps it awake, as today.
The driver handles that, but the fix only fully works on FTW after a Core
change, for example letting a read-only MQTT driver send a read request
(
R/...) the way a read-only cloud driver may send its sign-in POST.That is a decision for Core, not made here.
Not verified on hardware
Not run against a real GX. To check on one with no other MQTT client
(no Node-RED, Home Assistant or VRM window open): watch FTW's Victron
values for several minutes. Before this change they stop after about a
minute; with it they keep coming. If FTW's log shows "refused the
keep-alive", the host blocked it as described above.
Refs #256
🤖 Generated with Claude Code