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

Allow using * as wildcard in thing status triggers #2832

Merged
merged 1 commit into from
Apr 25, 2022

Conversation

J-N-K
Copy link
Member

@J-N-K J-N-K commented Mar 11, 2022

Closes #2167

Signed-off-by: Jan N. Klug github@klug.nrw

Signed-off-by: Jan N. Klug <github@klug.nrw>
@J-N-K J-N-K requested a review from a team as a code owner March 11, 2022 18:53
@@ -77,6 +79,9 @@ public ThingStatusTriggerHandler(Trigger module, BundleContext bundleContext) {
this.types = Set.of(ThingStatusInfoChangedEvent.TYPE);
}
this.bundleContext = bundleContext;

this.eventTopicFilter = Pattern.compile("^openhab/things/" + thingUID.replace("*", ".*?") + "/.*$");

Dictionary<String, Object> properties = new Hashtable<>();
properties.put("event.topics", "openhab/things/" + thingUID + "/*");
Copy link
Member Author

Choose a reason for hiding this comment

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

What is this used for? I didn't find code that uses this property. It also contradicts the description here which states that regular expressions should be used as filters.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did the initial implementation based on the GenericEventTriggerHandler which uses nearly the same code for event subscription. Currently I cannot tell you whether there is a spacial purpose or not.

@wborn wborn added the enhancement An enhancement or new feature of the Core label Mar 13, 2022
@@ -10,7 +10,7 @@
"type": "TEXT",
"context": "thing",
"label": "Thing",
"description": "The UID of the thing.",
"description": "The UID of the thing. You can use '*' as wildcard to match multiple things.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really related to your PR. Just wondering if we already have a way to translate these labels an descriptions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't that what ModuleTypeI18nService and ModuleTypeI18nServiceImpl is for?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that is right.

All we have to do next is to define the related property files for translation in JSON based module types.

Copy link
Contributor

@cweitkamp cweitkamp left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

@cweitkamp cweitkamp merged commit 86960f2 into openhab:main Apr 25, 2022
@cweitkamp cweitkamp added this to the 3.3 milestone Apr 25, 2022
@J-N-K J-N-K deleted the feature-allowwildcardthingtriggers branch April 25, 2022 15:09
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this pull request Jul 12, 2023
…hab#2832)

Signed-off-by: Jan N. Klug <github@klug.nrw>
GitOrigin-RevId: 86960f2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automation enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve thing status handling features
3 participants