Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[discovery] Added validation for relation between ThingUID and BridgeUID #1481

Merged

Conversation

cweitkamp
Copy link
Contributor

  • Added validation for relation between ThingUID and BridgeUID

See discussion in openhab/openhab-addons#7496 (comment)

Signed-off-by: Christoph Weitkamp github@christophweitkamp.de

@@ -36,7 +36,7 @@
private final ThingUID thingUID;

private @Nullable ThingUID bridgeUID;
private final Map<String, Object> properties = new HashMap<>();
private @Nullable Map<String, Object> properties;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would be careful here since it changes behavior of the builder. I know that 3.0.x addons must be recompiled to new packages, however such small changes remain undocumented and can blow up only when running a discovery with (most often) real things.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right. I reverted it for the moment. Even if my change streamlined this builder with other OHC builders.

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
@cweitkamp cweitkamp force-pushed the feature-discovery-thinguid-validation branch from 0ed1f2a to 7864ba3 Compare May 25, 2020 14:55
@cweitkamp cweitkamp added the bug An unexpected problem or unintended behavior of the Core label May 25, 2020
@cweitkamp cweitkamp added rebuild Triggers the Jenkins PR build and removed rebuild Triggers the Jenkins PR build labels Jun 7, 2020
@cweitkamp cweitkamp marked this pull request as ready for review July 22, 2020 19:17
}

@Test
@Ignore
Copy link
Member

Choose a reason for hiding this comment

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

Why is this test ignored?

Copy link
Contributor Author

@cweitkamp cweitkamp Jul 26, 2020

Choose a reason for hiding this comment

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

To streamline our builders (following eclipse-archived/smarthome#5929) I first changed the behavior of the withProperties(Map<String, Object>) method to replace existing properties map by the one set. This has been reverted after #1481 (comment) and thus the test is failing now. Will come up with a follow-up PR if the change should be applied at all to separate it from this feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have a look here for the changes I am talking about.

Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

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

Thanks!

@kaikreuzer kaikreuzer merged commit 7eb6d39 into openhab:master Sep 3, 2020
@cweitkamp cweitkamp deleted the feature-discovery-thinguid-validation branch September 3, 2020 19:07
@cweitkamp
Copy link
Contributor Author

Thanks for merging. The unit test were not yet migrated to JUnit 5. I fixed them in #1619.

@kaikreuzer
Copy link
Member

Thanks for #1619 and sorry that I didn't notice that.

@wborn wborn added this to the 3.0 milestone Sep 8, 2020
wborn added a commit to wborn/openhab-addons that referenced this pull request Sep 11, 2020
Fixes exceptions thrown in OH3 when building discovery results for things with bridges where the thing UID is missing the bridge UID.

Related to openhab/openhab-core#1481

Signed-off-by: Wouter Born <github@maindrain.net>
Hilbrand pushed a commit to openhab/openhab-addons that referenced this pull request Sep 11, 2020
Fixes exceptions thrown in OH3 when building discovery results for things with bridges where the thing UID is missing the bridge UID.

Related to openhab/openhab-core#1481

Signed-off-by: Wouter Born <github@maindrain.net>
CSchlipp pushed a commit to CSchlipp/openhab-addons that referenced this pull request Sep 12, 2020
Fixes exceptions thrown in OH3 when building discovery results for things with bridges where the thing UID is missing the bridge UID.

Related to openhab/openhab-core#1481

Signed-off-by: Wouter Born <github@maindrain.net>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request Sep 19, 2020
Fixes exceptions thrown in OH3 when building discovery results for things with bridges where the thing UID is missing the bridge UID.

Related to openhab/openhab-core#1481

Signed-off-by: Wouter Born <github@maindrain.net>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Oct 8, 2020
Fixes exceptions thrown in OH3 when building discovery results for things with bridges where the thing UID is missing the bridge UID.

Related to openhab/openhab-core#1481

Signed-off-by: Wouter Born <github@maindrain.net>
@splatch
Copy link
Contributor

splatch commented Dec 14, 2020

FYI I spotted this one while migrating my own bindings. Now it did hit bacnet integration. This validation rule is completely unclear to me. It was not enforced in 2.5 hence it impacts migration and makes maintenance of 2.5 and 3.0 versions troublesome.

I believe this check is unnecessary since each and every binding declares bridge-thing matches. The ThingUID in my understanding serves an ID and should be used in such a way. Looking at fragment of @kaikreuzer comment in related addon:

ThingUID: It is recommended to use it (especially when textually defining a thing), but there must not be any semantics being assumed within a ThingUID.

This change does introduce assumption that ThingUID include bridge identifier. I believe that this change might be also problematic when binding use multiple nesting levels. For example when there is more than just one bridge above the thing.

Please also update developer/migration docs accordingly so other people do not fall into same trap all over again.

@cdjackson
Copy link
Contributor

It does feel that this is a bad idea. If we think back a few years, we had these links (ie the thing type, bridge were encoded in the thing uid). This was removed as it caused problems when the thing type or bridge changed. A UID should be universally unique - it should NEVER change through the life of a system (in theory at least). Now, by imposing a hard link to the bridge UID, it is no longer possible to move a thing between bridges (if I understand this correctly) without changing the thing UID (which IMHO is a no-no and will have side effects through persistence etc).

@cweitkamp
Copy link
Contributor Author

I understand your concerns. But as stated in #1800 (comment) I do not seen a problem here. This validation is restricted for building discovery results and will not prevent switching bridges during runtime. AFAIK the UI uses a similar approach to create random ThingUIDs for Things related to Bridges. And it is the recommended syntax to be used for textual configuration.

Both of you are long time contributors and probably remember a lot more historical changes than I do so if it really is a problem or a step backwards we can revert it before final OH 3 release.

@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/satel-binding-support-announcements-and-feature-requests/56135/252

splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 11, 2023
…UID (openhab#1481)

* Added validation for relation between ThingUID and BridgeUID

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
GitOrigin-RevId: 7eb6d39
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 the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants