Skip to content

Relax Unique ID logic#493

Merged
Snuffy2 merged 1 commit intotravisghansen:mainfrom
Snuffy2:Unique-ID-Changing
Feb 7, 2026
Merged

Relax Unique ID logic#493
Snuffy2 merged 1 commit intotravisghansen:mainfrom
Snuffy2:Unique-ID-Changing

Conversation

@Snuffy2
Copy link
Collaborator

@Snuffy2 Snuffy2 commented Feb 7, 2026

This pull request enhances the handling and validation of device unique IDs throughout the OPNsense Home Assistant integration. The main improvement is the addition of an expected_id parameter to the get_device_unique_id method, allowing the system to prefer a specific device ID if present. This change is propagated across the core integration logic, configuration flow, coordinator, and test suite to ensure consistent device identification and smoother configuration updates.

Device Unique ID Handling and Validation:

  • custom_components/opnsense/pyopnsense/__init__.py: Updated get_device_unique_id to accept an expected_id parameter. If the expected ID is present among physical MAC addresses, it is returned; otherwise, the first MAC address is used.
  • custom_components/opnsense/__init__.py, custom_components/opnsense/config_flow.py, custom_components/opnsense/coordinator.py: Propagated the expected_id parameter through setup, validation, and coordinator logic to ensure the correct device ID is used during configuration and runtime. [1] [2] [3] [4] [5] [6] [7] [8]

Test Suite Updates:

  • tests/conftest.py, tests/test_integration.py: Updated test client mocks to support the new expected_id parameter in get_device_unique_id. [1] [2] [3] [4]
  • tests/test_pyopnsense.py: Added a new test to verify that get_device_unique_id returns the expected ID when present, and falls back to the default when not.

Code Quality Improvements:

Fixes #480

@Snuffy2 Snuffy2 added the enhancement Enhancing existing functionality label Feb 7, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  custom_components/opnsense
  __init__.py
  config_flow.py
  coordinator.py
  custom_components/opnsense/pyopnsense
  __init__.py 684
Project Total  

This report was generated by python-coverage-comment-action

@Snuffy2 Snuffy2 merged commit 0449025 into travisghansen:main Feb 7, 2026
5 checks passed
@Snuffy2 Snuffy2 deleted the Unique-ID-Changing branch February 7, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancing existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: after Firewall updates often error at connected integration

1 participant