Skip to content

[dirigera] Add device set support - #20691

Merged
lsiepel merged 7 commits into
openhab:mainfrom
weymann:dirigera-device-set-support
May 13, 2026
Merged

[dirigera] Add device set support#20691
lsiepel merged 7 commits into
openhab:mainfrom
weymann:dirigera-device-set-support

Conversation

@weymann

@weymann weymann commented May 9, 2026

Copy link
Copy Markdown
Member

DIRIGERA gateway allows to organize light bulbs / LED strips in a Set. This native support allows to change light settings immediately to a set of lights without delay.
Sets are defined in IKEA Home smart app and they are now supported via discovery. Managing these (add / delete / modify) stays in the app, no openHAB support.

Fixes #20101

weymann added 4 commits May 7, 2026 19:24
Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>

add unit test & bugfixing

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds native support to the DIRIGERA binding for IKEA “deviceSet” light groups (“Light Sets”), enabling group-level commands to be sent via the dedicated /devices/set/{id} endpoint and discovering these sets as their own Things.

Changes:

  • Add a new light-set Thing type (XML + i18n + README) and handler (LightSetHandler) to control grouped lights as one unit.
  • Extend the model to discover light-set IDs embedded in member devices and expose member device IDs for set initialization/status.
  • Add REST API support for patching device sets and introduce tests validating endpoint routing and basic channel behavior.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
bundles/org.openhab.binding.dirigera/src/test/java/org/openhab/binding/dirigera/internal/model/TestModel.java Updates discovery count expectations to include discovered light sets.
bundles/org.openhab.binding.dirigera/src/test/java/org/openhab/binding/dirigera/internal/mock/DirigeraAPISimu.java Adds simulated /devices/set/{id} patch handling and a non-blocking patch peek helper for tests.
bundles/org.openhab.binding.dirigera/src/test/java/org/openhab/binding/dirigera/internal/handler/lights/TestLightSet.java New tests for light-set handler creation, refresh/state behavior, and correct endpoint routing.
bundles/org.openhab.binding.dirigera/src/main/resources/OH-INF/thing/light-set.xml Introduces the light-set thing type and channels.
bundles/org.openhab.binding.dirigera/src/main/resources/OH-INF/i18n/dirigera.properties Adds i18n keys for the new light-set thing type and channels.
bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/network/DirigeraAPIImpl.java Implements sendSetAttributes to PATCH device sets via /devices/set/{id}.
bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/model/DirigeraModel.java Discovers light-set IDs from deviceSet arrays and provides set metadata/member lookup.
bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/interfaces/ThingStatusListener.java Adds a placeholder interface for future status-listener expansion.
bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/interfaces/Model.java Adds constants and a getMemberDeviceIds(setId) API for light sets.
bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/interfaces/DirigeraAPI.java Extends the API interface with sendSetAttributes.
bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/handler/light/LightSetHandler.java New handler implementing light-set status aggregation and routing commands to set endpoint.
bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/handler/light/BaseLight.java Switches to polymorphic sendAttributes() to allow light-set override to work.
bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/handler/BaseHandler.java Adds a sendSetAttributes wrapper for the new API call.
bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/DirigeraHandlerFactory.java Registers LightSetHandler for the new thing type.
bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/Constants.java Adds new thing type UID, endpoint URL constant, and attribute-to-channel mapping for light sets.
bundles/org.openhab.binding.dirigera/README.md Documents the new light-set Thing, channels, and behavior caveats.

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

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
@weymann
weymann force-pushed the dirigera-device-set-support branch from 15b93b3 to f338617 Compare May 10, 2026 22:42
Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>

fix unit test

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>

fix unit test

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>

fix unit test

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
@weymann
weymann force-pushed the dirigera-device-set-support branch from f338617 to 70c7e26 Compare May 10, 2026 22:48
@lsiepel
lsiepel requested a review from Copilot May 11, 2026 20:25
@lsiepel lsiepel added the enhancement An enhancement or new feature for an existing add-on label May 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (6)

bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/handler/light/LightSetHandler.java:169

  • This always forwards member attributes to the light handler even when the update came from a member that just reported isReachable=false. If another member is still reachable, online is set to true before the delegate call, so BaseHandler/light handlers can overwrite the set's power/brightness/color with stale data from the unreachable bulb. Skip delegating attributes for unreachable member updates (or only delegate when the source member is reachable).
        super.handleUpdate(stripped);

bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/handler/light/LightSetHandler.java:140

  • The copy here is shallow: the nested attributes object is shared with update, so removing customName mutates the original websocket payload. DirigeraHandler passes the same JSONObject instance to every handler registered for a device ID, so if a light-set handler runs before the member's own handler, the member handler will no longer see its customName update. Create a deep copy of the attributes object before stripping fields.
        JSONObject stripped = new JSONObject(update, update.keySet().toArray(new String[0]));

        // strip customName for each member update
        if (update.has(JSON_KEY_ATTRIBUTES)) {
            stripped.getJSONObject(JSON_KEY_ATTRIBUTES).remove(ATTRIBUTES_KEY_CUSTOM_NAME);
        }

bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/handler/light/LightSetHandler.java:184

  • Disposing a light-set unregisters each member ID, but the gateway's current unregister implementation removes the whole deviceTree entry for that ID rather than only this handler. If a member bulb also has its own thing handler, disposing the set stops websocket updates for that bulb until it re-registers. Either fix unregister to remove only the supplied handler or avoid unregistering shared member IDs here.
        memberDeviceIds.forEach(memberId -> {
            try {
                gateway().unregisterDevice(child, memberId);

bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/handler/light/LightSetHandler.java:103

  • Registering each member ID through gateway().registerDevice(...) also adds that member ID to the gateway's persisted knownDevices list. If a user adds only the light-set thing, its bulbs become marked as known even though they do not have their own thing handlers, so discovery will stop offering those bulbs (and the entries remain after dispose because unregister does not remove known devices). Use a subscription path that does not persist member IDs as known devices, or change registration to distinguish aliases from real things.
        gateway().registerDevice(child, config.id);
        memberDeviceIds.forEach(memberId -> gateway().registerDevice(child, memberId));

bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/handler/light/LightSetHandler.java:73

  • This status description is a raw English string, unlike the other device status messages in this binding that use @text/... keys for localization. Add an i18n entry and reference it here so the OFFLINE reason is localizable like the surrounding status messages.
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
                    "No member devices found for light set");

bundles/org.openhab.binding.dirigera/src/main/java/org/openhab/binding/dirigera/internal/handler/light/LightSetHandler.java:95

  • This synthetic update does not actually initialize the set name: LightSetHandler.handleUpdate() unconditionally removes customName from every update before delegating to BaseHandler, so the custom-name channel remains unset. Only strip customName for member-device updates (or set the channel directly here) so the light-set name from metadata is published.
            JSONObject nameInit = new JSONObject();
            JSONObject attributes = new JSONObject();
            attributes.put(ATTRIBUTES_KEY_CUSTOM_NAME, nameStr);
            nameInit.put(JSON_KEY_ATTRIBUTES, attributes);
            super.handleUpdate(nameInit);

@lsiepel lsiepel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, LGTM

@lsiepel
lsiepel merged commit 1bd4da1 into openhab:main May 13, 2026
6 checks passed
@lsiepel lsiepel added this to the 5.2 milestone May 13, 2026
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request May 19, 2026
* initial contribution

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request Jun 13, 2026
* initial contribution

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
darkscout pushed a commit to darkscout/openhab-addons that referenced this pull request Jul 5, 2026
* initial contribution

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
olemr pushed a commit to olemr/openhab2-addons that referenced this pull request Aug 8, 2026
* initial contribution

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
Signed-off-by: olemr <olemr@olemr.com>
cipianpascu pushed a commit to cipianpascu/openhab-addons that referenced this pull request Aug 16, 2026
* initial contribution

Signed-off-by: Bernd Weymann <bernd.weymann@gmail.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement An enhancement or new feature for an existing add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dirigera ] Device-Set support

3 participants