Skip to content

14 implement device unit synchonization#22

Open
lhuxohl wants to merge 15 commits intodevfrom
14-implement-device-unit-synchonization
Open

14 implement device unit synchonization#22
lhuxohl wants to merge 15 commits intodevfrom
14-implement-device-unit-synchonization

Conversation

@lhuxohl
Copy link
Copy Markdown
Collaborator

@lhuxohl lhuxohl commented Apr 1, 2026

📜 Description

  • Implement device sync strategy
    • Sync devices from hass to bco
    • Sync label synchronization from bco to hass, no other fields will be updated in this direction

🧪 Test Procedure

  • Start bco
  • Start hass device manager
  • Check if devices are created in bco
  • Change/Update Devices to see if synchronization is working as expected

@lhuxohl lhuxohl added ready to review preview Build and deploy a preview of this pr that is pushed to the official docker registry. labels Apr 1, 2026
Copilot AI review requested due to automatic review settings April 1, 2026 21:57
Copy link
Copy Markdown

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

Implements a new device/unit synchronization approach between Home Assistant (HA) and BCO, moving device/entity linking logic into dedicated UnitSyncStrategy implementations and extending the synchronizer to support custom unit queries.

Changes:

  • Added DeviceSyncStrategy (HA → BCO device creation/update) and EntitySyncStrategy (link HA entities to auto-created DAL units).
  • Extended UnitSyncStrategy/UnitSynchronizer with queryUnitConfigs(...) to support strategies that span multiple unit types or require custom selection.
  • Updated HA device update payload handling (name_by_user etc.) and hardened label best-match resolution.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/test/kotlin/org/openbase/bco/gateway/homeassistant/sync/UnitSynchronizerTest.kt Updates test mocks to cover the new queryUnitConfigs(...) path.
src/main/kotlin/org/openbase/bco/gateway/homeassistant/util/LabelExtensions.kt Makes label best-match retrieval exception-safe.
src/main/kotlin/org/openbase/bco/gateway/homeassistant/sync/UnitSynchronizer.kt Uses strategy-provided unit queries and skips invalid configs returned by strategies.
src/main/kotlin/org/openbase/bco/gateway/homeassistant/sync/strategy/UnitSyncStrategy.kt Adds default queryUnitConfigs(...) hook for custom unit selection.
src/main/kotlin/org/openbase/bco/gateway/homeassistant/sync/strategy/EntitySyncStrategy.kt New entity↔DAL linking strategy (HA entities mapped onto BCO DAL units).
src/main/kotlin/org/openbase/bco/gateway/homeassistant/sync/strategy/DeviceSyncStrategy.kt New device synchronization strategy with device-class matching.
src/main/kotlin/org/openbase/bco/gateway/homeassistant/manager/HassDeviceManager.kt Integrates the new synchronizers and switches state filtering to use the entity cache.
src/main/kotlin/org/openbase/bco/gateway/homeassistant/manager/dto/HassEntityInputDto.kt Adds HA entity input DTO type.
src/main/kotlin/org/openbase/bco/gateway/homeassistant/manager/dto/HassEntityDto.kt Makes entity DTO compatible with synchronizer generics (merge/input provider) and relaxes nullable fields.
src/main/kotlin/org/openbase/bco/gateway/homeassistant/manager/dto/HassDeviceInputDto.kt Adds name_by_user support for HA device updates.
src/main/kotlin/org/openbase/bco/gateway/homeassistant/manager/dto/HassDeviceDto.kt Adds nameByUser field and merge/input mapping.
src/main/kotlin/org/openbase/bco/gateway/homeassistant/communication/HassCommunicator.kt Fixes HA device update payload to use device_id + accepted fields only.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Member

@DivineThreepwood DivineThreepwood left a comment

Choose a reason for hiding this comment

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

minor changes

@lhuxohl lhuxohl requested a review from DivineThreepwood April 9, 2026 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code approved preview Build and deploy a preview of this pr that is pushed to the official docker registry. ready to test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants