dbushelper: centralize Victron settings bus name; clarify get_bus#433
Open
cgoudie wants to merge 5 commits intomr-manuel:masterfrom
Open
dbushelper: centralize Victron settings bus name; clarify get_bus#433cgoudie wants to merge 5 commits intomr-manuel:masterfrom
cgoudie wants to merge 5 commits intomr-manuel:masterfrom
Conversation
added 3 commits
April 7, 2026 18:20
- Add VICTRON_SETTINGS_DBUS_NAME as single source for the Victron settings well-known name, used both as get_bus() cache key and as the service argument to settings helpers (DRY, typo-resistant). - Annotate get_bus(dbus_name: str) and clarify that dbus_name is the _bus_instances key and typically the peer well-known name. - Fix comment typo (preare -> prepare). Refs: mr-manuel#410 Related: mr-manuel#402 Made-with: Cursor
…son) Made-with: Cursor
…, batteries not) Made-with: Cursor
This was referenced Apr 7, 2026
added 2 commits
April 7, 2026 18:29
…el#402) - Stub BusConnection.get_is_connected in conftest so get_bus() works under tests. - Assert same key reuses connection, distinct battery names differ, settings share VICTRON_SETTINGS_DBUS_NAME cache entry separate from battery names. Made-with: Cursor
…uel#402) Patch SystemBus/SessionBus and count constructors: many calls with the same cache key must yield one allocation; N keys → N allocations. Covers reconnect when get_is_connected is false. Made-with: Cursor
Contributor
Author
|
Merge / dependency reminder: The `get_bus(dbus_name)` keyed cache (per battery `_dbusname` + shared settings name) is required for issue #410 alongside the leak fix in PR #402. This PR documents and tests that design but does not introduce it — ensure `master` already has (or merges together with) the per-name behaviour, not a single global bus for all `VeDbusService` instances. |
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.
Summary
Follow-up after per-service
get_bus(dbus_name)(issue #410, PR #402):VICTRON_SETTINGS_DBUS_NAMEsocom.victronenergy.settingsis not repeated across everyget_bus/ settings helper call (same string is both the connection cache key and the D-Bus service name Victron’s settings daemon uses).get_bus(dbus_name: str)and expand the docstring: D-Bus spec well-known name, when the settings name is intentionally shared across all helpers vs when each battery needs a distinct_dbusname/ connection.preare→prepare).No runtime behaviour change.
Does not address issue #417 (stale SOC / duplicate device entries); that is PR #429.
Coordination with PR #429
PR #429 also edits
dbus-serialbattery/dbushelper.py(save_current_battery_state, save cadence, duplicateUniqueIdentifierhandling). Merge order only needs a small mechanical follow-up:masterand replace any new"com.victronenergy.settings"literals withVICTRON_SETTINGS_DBUS_NAME/get_bus(VICTRON_SETTINGS_DBUS_NAME)in the Bugfix/older devices history entry mismatch for duplicate entries #429 changes.masterand the same substitution applied in the touched regions (no logic change).Optional: I can push a commit to the #429 branch with only those substitutions if that helps.
@mr-manuel @lex2k0
Cross-links
Pointers to this PR were added in: #410 (comment), #417 (comment), #429 (comment), #402 (comment).