Skip to content

[wled] Fix discovery inbox entry matching existing things#20345

Open
t2000 wants to merge 4 commits intoopenhab:mainfrom
t2000:fixWledDiscovery
Open

[wled] Fix discovery inbox entry matching existing things#20345
t2000 wants to merge 4 commits intoopenhab:mainfrom
t2000:fixWledDiscovery

Conversation

@t2000
Copy link
Contributor

@t2000 t2000 commented Mar 7, 2026

It also uses the new context parameter from #20294

Fixes #20344

It also uses the new context parameter from openhab#20294

Fixes openhab#20344

Signed-off-by: Stefan Triller <github@stefantriller.de>
@lsiepel
Copy link
Contributor

lsiepel commented Mar 7, 2026

I would also expect the mac-address to be the representation property, did you consider adding this property as representation property?

Copy link
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 aims to improve WLED discovery so inbox entries correctly match already-existing Things by using MAC address as the representation key (and leveraging the newly introduced mac-address config context).

Changes:

  • Add a macAddress bridge configuration parameter with mac-address context validation.
  • Format the discovered MAC address into colon-delimited form when storing Thing.PROPERTY_MAC_ADDRESS in discovery results.

Reviewed changes

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

File Description
bundles/org.openhab.binding.wled/src/main/resources/OH-INF/thing/thing-types.xml Adds a macAddress bridge config parameter (with mac-address context) intended to support consistent identification/matching.
bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedDiscoveryService.java Changes discovery result MAC property to a colon-delimited format for representation-based matching.

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

@t2000
Copy link
Contributor Author

t2000 commented Mar 8, 2026

I would also expect the mac-address to be the representation property, did you consider adding this property as representation property?

That is the reason why I have created this PR and the corresponding bug ticket ;-) It already exists in https://github.com/openhab/openhab-addons/blob/main/bundles/org.openhab.binding.wled/src/main/java/org/openhab/binding/wled/internal/WLedDiscoveryService.java#L105

but it is missing as a property on the thing.

Signed-off-by: Stefan Triller <github@stefantriller.de>
@t2000
Copy link
Contributor Author

t2000 commented Mar 8, 2026

Thanks for the reviews, I have addressed your comments.

Copy link
Contributor

@andrewfg andrewfg left a comment

Choose a reason for hiding this comment

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

One comment

@lolodomo
Copy link
Contributor

lolodomo commented Mar 8, 2026

It looks like you make a confusion between a thing configuration parameter and a thing property.
I am also very surprise to add the MAC address as a thing configuration parameter.

Signed-off-by: Stefan Triller <github@stefantriller.de>
@t2000
Copy link
Contributor Author

t2000 commented Mar 8, 2026

It looks like you make a confusion between a thing configuration parameter and a thing property. I am also very surprise to add the MAC address as a thing configuration parameter.

Valid point. Usually the MAC address is not changeable. I have moved it from the configuration section to the properties section of the thing-type.

Copy link
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

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


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

String firmware = WLedHelper.getValue(response, "\"ver\":\"", "\"");
ThingUID thingUID = new ThingUID(THING_TYPE_JSON, macAddress);
Map<String, Object> properties = Map.of(Thing.PROPERTY_MAC_ADDRESS, macAddress,
Map<String, Object> properties = Map.of(Thing.PROPERTY_MAC_ADDRESS, macAddressProperty,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you also retrieve the macadddress and set it as property for things that are unmanaged (file based) and therefor not added by the discovery class?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, properties have to be retrieved and set by the thing handler, generally during its initialisation.

Signed-off-by: Stefan Triller <github@stefantriller.de>
@lsiepel
Copy link
Contributor

lsiepel commented Mar 8, 2026

Almost there, this comment needs to be addressed and then we have a full fix: #20345 (comment)

@lsiepel lsiepel added the bug An unexpected problem or unintended behavior of an add-on label Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An unexpected problem or unintended behavior of an add-on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wled] Discovery uses thing property that does not exist

5 participants