Skip to content

Victron GX: bug fixes#168461

Draft
tomer-w wants to merge 2 commits intohome-assistant:devfrom
tomer-w:victron_gx_bugfixes
Draft

Victron GX: bug fixes#168461
tomer-w wants to merge 2 commits intohome-assistant:devfrom
tomer-w:victron_gx_bugfixes

Conversation

@tomer-w
Copy link
Copy Markdown
Contributor

@tomer-w tomer-w commented Apr 17, 2026

Proposed change

Fixing a bug I introduced while fixing CR comments. Main entities still need translation key so in the case of selects or enum sensor they will still have the list of options.
Also, one line change to move to the new relationship between devices instead of hardcoding the SYSTEM_0 device as root.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Victron GX entity translation behavior for main_topic metrics (so state/option translations keep working) and updates device relationships to use the upstream parent/child device model.

Changes:

  • Ensure translation_key/placeholders are always set on Victron entities, including main_topic metrics, while still letting HA use the device name for the entity name.
  • Update device registry via_device mapping to use device.parent_device instead of hardcoding system_0.
  • Adjust/add tests to cover the corrected translation key behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
homeassistant/components/victron_gx/entity.py Always set translation_key/placeholders; keep main_topic entities device-named by forcing _attr_name=None.
homeassistant/components/victron_gx/hub.py Set via_device using the parent_device relationship.
tests/components/victron_gx/test_sensor.py Update regression assertion for main_topic sensor translation key behavior.
tests/components/victron_gx/test_select.py Add regression test ensuring main_topic selects still set translation_key.

Comment on lines +140 to +141
# name should be None (uses device name via has_entity_name)
assert entity.name is None
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the entity registry entry’s original_name (or assert state.attributes["friendly_name"]) instead of entity.name to validate that the integration didn’t set an entity name; entity.name here only reflects a user override and won’t catch regressions in the entity’s computed name.

Suggested change
# name should be None (uses device name via has_entity_name)
assert entity.name is None
# original_name should be None (uses device name via has_entity_name)
assert entity.original_name is None

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants