Commit Graph
43 Commits
Author SHA1 Message Date
NadaharandGitHub f842e2692d Disable Graal language cache (#5614)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-06-19 17:37:17 +02:00
NadaharandGitHub 22f29c5d10 [automation] Enable asynchronous execution of rules and lock engine lock when loading scripts (#5635)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-06-19 14:50:35 +02:00
NadaharandGitHub 29cfacf293 Try to fix the flaky automation integration test (#5656)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-06-18 22:35:57 +02:00
c6be254433 Fix missing regex replace escaping in DslRuleConverter (#5653)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Co-authored-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-06-14 14:59:21 +02:00
6ad0192975 Rule and RuleTemplate file format conversion (#5572)
* Create ObjectParser and ObjectSerializer interfaces for rules and rule templates

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Embed DSL rule source with the Rule

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Detect shared context DSL rules

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Update YAML DTOs to support serialization

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Create rule converters

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Create rule template YAML converter

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Implement rule and rule template conversion in the REST API

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Handle DSL conditions

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Create check serializability endpoint

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Don't deserialize TemplateState - deduce it from templateUID

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Add GenericEventTrigger to ModuleTypeAliases

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Fix JavaDoc errors

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Allow triggerless DSL rules

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Fix negative indentation issue during DSL formatting

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Add rule configuration to "rule summary"

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Fix rule template REST API schema

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Address review feedback

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Address review feedback

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Handle single digit hour specification during DSL serialization

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Address review comments

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Address review comments

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Apply review suggestion

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Remove seemingly needless import

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Apply review derived fixes

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Review fixes

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Address review formatter feedback

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Fix YAML bundle feature dependency

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

---------

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Co-authored-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-06-12 19:49:35 +02:00
3c147e8fe4 [DSL] Add extra commands/abilities to DSL scripts/rules (#5481)
* Add access to various system registries, OSGi instances and the ability to run and enable/disable rules to DSL scripts

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Set required startlevel in ScriptEngineOSGiTest

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Make RuleManager a dynamic reference

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Revert "Set required startlevel in ScriptEngineOSGiTest"

This reverts commit ee8ae1ed198b267c8e2311d9bc025a49be5c8ca9.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Add additional convenience methods

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Add more overloads

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Fix socket leak

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Reorganize classes and implement extensions

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Complete reorganization

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Add missed JavaDocs

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Fix missed JavaDocs

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Modify implicit imports:

- Remove unnecessary, left-over persistence imports
- Add potentially useful import considering the new stricter class resolution mechanism in the recently bumped Xtext version

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Call existing static methods from RuleExtensions, some further JavaDoc cleanup

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Revise implicit imports

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Add TimeZone and Locale to available providers and methods

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Move "helper" classes to existing package with similar content

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Address some review comments

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Remove export of no longer existing package

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Add missing import

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Move common methods to new class Utils and try to get map nullness under control

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Create tests for Rules.java

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Create tests for Items.java

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Create tests for Channels.java

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Create tests for ItemExtensions.java and RuleExtensions.java

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Reintroduce warnings and reduce logging flexibility

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

---------

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Co-authored-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-06-11 23:17:36 +02:00
12acddf927 Include rule UID in log message when executions fails (#5627)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Co-authored-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-06-04 17:18:38 +02:00
927f244419 Revert "[automation] AbstractScriptModuleHandler: Remove prefixes from context entries before injecting ctx into execution context (#4919)" (#5621)
This reverts commit 9c27b896d0.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Co-authored-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-06-02 17:46:24 +02:00
1132515ae4 Various YAML fixes (#5588)
* Create YamlConfigDescriptionDTO and YamlConfigDescriptionParameterGroupDTO

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Use YamlConfigDescriptionDTO for YAML pages and widgets

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Create YamlWidgetParser and add getAllFromModel() to YamlWidgetProvider.java

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Make sure that ObjectParser.getParsedObjects() returns a copy

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Update bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/config/YamlConfigDescriptionDTO.java

Co-authored-by: Mark Herwege <mherwege@users.noreply.github.com>
Signed-off-by: Nadahar <Nadahar@users.noreply.github.com>

* Address review feedback and apply explicit charset to other "converters"

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

---------

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Signed-off-by: Nadahar <Nadahar@users.noreply.github.com>
Co-authored-by: Ravi Nadahar <nadahar@rediffmail.com>
Co-authored-by: Mark Herwege <mherwege@users.noreply.github.com>
2026-05-29 15:33:57 +02:00
85c7c3c469 Make RuleManager.runNow() run in the dedicated rule thread (#5069)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Co-authored-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-05-17 18:42:58 +02:00
NadaharandGitHub 8b3e8b53ec Update GenericEventTrigger label and requirements (#5544)
Fix configuration parameters' requirements

Signed-off-by: Nadahar <Nadahar@users.noreply.github.com>
2026-05-17 00:26:07 +02:00
055259bd2e Rule UID syntax validation (#5467)
* Add a validity check for the rule UID

A valid rule UID must consist of one or several segments separated by a colon, each segment must only contain alphanumeric, underscore or hyphen, and must not contain any other symbols.

Signed-off-by: Laurent Garnier <lg.hc@free.fr>

* Apply UID validation to YAML rules

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Alternatives

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Implement RulesValidator in Java instead

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Workaround to let specific errors fail rule parsing while others are just a warning

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Alternative way to express model validation expression

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Enforce rule UID in RuleRegistry

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Apply my preferred alternative

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Address review feedback

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Add tests for RuleUtil

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

* Address review comments

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>

---------

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Co-authored-by: Laurent Garnier <lg.hc@free.fr>
Co-authored-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-05-05 20:45:04 +02:00
NadaharandGitHub 0926c54c1e Rule conversion preparation (#5502)
* Make YAML Rule and RuleTemplate providers handle isolated models
* Fix bug from #4633
* TemplateState was originally (during #4718 development) called TemplateStatus, and when changed, not every reference was included, which is corrected here
* Add a new constructor to RuleBuilder that allows to make a "copy" of a Rule using a new UID, and add Javadocs to the constructors
* Remove remnants of pre #4718 logic in Rule Javadocs
* Make StateAndCommandProvider sets immutable and all getters static
* Add /src.moved/ to .gitignore because it appears there after every build, constantly causing diffs.
* Use the new constants in ModuleTypeAliases and fix a bug in typeToAlias()
* Minor refactoring of rule template resolving
* Correct ConfigDescriptionParameter Javadoc and create toString() in ModuleImpl to ease debugging

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-04-23 15:06:02 +02:00
NadaharandGitHub 2960545bd1 Fix Operator definition in Rules.xtext (#5491)
Signed-off-by: Nadahar <Nadahar@users.noreply.github.com>
2026-04-16 16:55:31 +02:00
NadaharandGitHub 62924f52b9 Include cause in thrown ScriptExceptions from DSLScriptEngine (#5480)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-04-09 18:38:56 +02:00
NadaharandGitHub 0bc16195cb Reorganize file conversion classes/interfaces (#5370)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-03-15 21:23:04 +01:00
NadaharandGitHub 4757e22a23 Fix community marketplace discourse parsing (#5376)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-02-21 12:58:54 +01:00
NadaharandGitHub 767e809e5a Rule file provider (#4633)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-02-14 19:57:24 +01:00
NadaharandGitHub 7343711214 Adjust REST HTTP response status codes (#5236)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-02-05 18:57:27 +01:00
NadaharandGitHub de14a998c5 Add time zone support for ZonedDateTime action inputs (#5235)
* Add time zone support for ZonedDateTime action inputs

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2026-01-17 19:17:17 +01:00
dea60ca1e0 Switch to using asynchronous send with Jetty websockets (#5225)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
Co-authored-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-12-27 22:17:24 +01:00
NadaharandGitHub fd00c77ff5 Refactor websocket concurrency handling (#5165)
* Refactor websocket concurrency handling
* Modify web socket buffering logic to ensure FIFO and avoid blocking the logger thread
* Use a dedicated executor that is guaranteed not to log anything
* Logging tweak

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-12-14 22:14:42 +01:00
NadaharandGitHub 409ab79101 Use dedicated executor for long-running SDDP discovery tasks (#5174)
Some of the SDDP tasks are long-running by design, the background scan task in particular runs indefinitely (until interrupted). This clashes with the idea in #4969, and perhaps with the envisioned use of OH's shared thread pools in general, in that pools are small and tasks are expected to be short-lived. When setting logging to DEBUG, the log will be constantly "spammed" with complaints about the SDDP discovery task taking more than 5 seconds, which it is in fact designed to do.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-12-09 22:51:04 +01:00
NadaharandGitHub 84cfec2925 Eliminate double localization of discovery results (#5151)
* Remove double localization of discovery results

Localization of discovery results requires a bundle from which to acquire the translations. When bindings implement AbstractDiscoveryService themselves, the bundle is resolved using the class of the implementation. For "sub discovery services" where bindings are "participants", this doesn't work, because the  implementing class is the "sub discovery service" itself, not the binding, which means that the resolved bundle doesn't have any translations. This has been solved by doing an extra round of localization in the "sub discovery service" (using the correct bundle) before passing the DiscoveryResult on to AbstractDiscoveryService, which will attempt localization again, with the wrong bundle, but since no translations are found in this bundle, it has no other consequences than being wasteful.

This solves the problem by adding a second thingDiscovered() method to AbstractDiscoveryService, which accepts a bundle as a second argument. That way, "sub discovery services" can resolve the correct bundle using the participant class, and pass on the correct bundle, avoiding the "double localization".

In addition, a new factory method is added to DiscoveryResultBuilder that allows initializing a new builder from an existing DiscoveryResult instance, so that this doesn't have to be done in the localization method itself.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-12-09 22:18:14 +01:00
NadaharandGitHub 75b885a137 Refactor Windows USB discovery (#5092)
* Create User32Ex with some mappings missing in JNA's User32
* Create WindowMessageHandler for subscribing to device change messages

The class, when run as a Runnable, creates an invisible window and uses that to listen for device change events for USB devices and serial ports. It listens in a blocking message loop, so it's necessary to call terminate() for the loop to exit and the run() method to exit. Results are sent to subscribing WindowMessageListeners.

* Refactor WindowsUsbSerialDiscovery to use a different approach to gathering device information

The previous implementation scanned the registry for USB devices on a fixed interval. This implementation changes most of the core logic, using SetupAPI as the primary source of information instead of the registry. That allows it to process less information to get to the information of interest, in addition to only "discovering" devices that are currently connected to the computer. The registry keeps the entries for all devices that have previously been connected as well, which would also be "discovered" with the previous implementation.

In addition, this implementation uses WindowMessageHandler to receive device change messages from Windows, making regular scanning unnecessary. If the WindowMessageHandler fails for some reason, the implementation will fall back to scanning on an interval, but this scanning is still using SetupAPI to acquire the data.

* Various thread-safety and consistency fixes

- UsbAddonFinder: Remove unused Set and fix concurrency behavior. ConcurrentHashMap is unsuitable here because it doesn't allow locking the full map, which is needed during "merging" and when resolving suggested add-ons.
- DeltaUsbSerialScanner: Make lastScanResult thread-safe.
- Ser2NetUsbSerialDiscovery: Make lastScanResult thread-safe, reduce the scope of locking to reduce contention and lessen how many locks are held at once. Make notifyListeners volatile for thread-safe access, and stop reacting to jmdns serviceAdded events. jmdns first fires serviceAdded when the service has just been discovered, but most of the information hasn't yet been gathered, and then fires serviceResolved once all the data has been registered. The data received in serviceAdded is incomplete and rarely useful, at best it's a "heads-up, this device might be resolved soon".
- UsbSerialDiscovery: Correct JavaDoc
- UsbSerialDiscoveryService: Minor logging tweaks, only log "Discovered new" the first time the device is "discovered".

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-11-23 00:02:54 +01:00
NadaharandGitHub dd2a59a7b5 Make ConfigDescriptionParameter.stepsize serialize to "step" to be consistent with XML schema (#5132)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-11-22 23:44:27 +01:00
NadaharandGitHub 6f51ef2143 Minor rulesupport fixes (#5074)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-11-10 19:58:23 +01:00
NadaharandGitHub 08b3fb2a31 Add AbstractThingHandlerDiscoveryService constructor for tests (#5100)
* Add AbstractThingHandlerDiscoveryService constructor for tests to use a different executor
* Add JavaDocs
* Make ThingHandler type generic

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-10-26 07:20:28 +01:00
NadaharandGitHub 58c9bb2812 Same thread executor (#5072)
* Create SameThreadExecutorService for use by tests

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-10-25 20:54:50 +02:00
NadaharandGitHub d10530817f IP add-on finder: resolve source IP before broadcast scan (#5090)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-10-24 00:40:27 +02:00
NadaharandGitHub 191b62df7f Fix ActionHandler.execute() nullness annotation (#4974)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-10-11 08:35:39 +02:00
NadaharandGitHub 5972b1ea31 Make TimerImpl thread-safe (#5051)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-10-10 23:24:43 +02:00
NadaharandGitHub aa73ac8171 Isolate discovery result registrations from binding threads (#5032)
By using the discovery thread pool to do the actual registrations in AbstractDiscoveryService, binding threads won't have to wait for the registration to complete, which can be slow.

In addition, some thread-safety fixes have been done in AbstractDiscoveryService and DiscoveryServiceRegistryImpl, both to avoid contention and to ensure isolation of mutable objects.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-10-10 23:19:14 +02:00
NadaharandGitHub 9d679718ed Fix AddonSuggestionService configuration (#5042)
AddonSuggestionService has had a delayed application of configuration because it was based on a timer that refreshed it every minute. This led to various issue where "wrong decision" were made based on stale information. This addresses the root cause for why the configuration wasn't delivered in a timely manner by OSGi, and removes the scheduled configuration refresh.

For the configuration to be accessible to multiple bundles, its "location" must be "a region". This must be configured before any bundle tries to use the configuration. To do this very early, it has been attached to the Activator of the "main core bundle". It doesn't have to be there, as long as it will always run very early during startup.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-10-08 20:30:06 +02:00
NadaharandGitHub 9aa597249a Add tests for rules and rule templates JSON parser (#4910)
Additionally, change HashSet to LinkedHashSet in classes RuleGSONParser and TemplateGSONParser
to make iteration order predictable.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-10-08 19:04:22 +02:00
NadaharandGitHub f5d2746c04 SDDP clarification (#5031)
* Clarify that SDDP isn't SSDP

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-09-27 15:51:02 +02:00
NadaharandGitHub 44a9bb3280 Marketplace fixes (#4929)
* Remove forum compatibility range from add-on title
* Fix and unify error handling of missing content in community marketplace add-on handlers

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-09-16 22:02:03 +02:00
NadaharandGitHub e39fb12112 Make REST endpoints accept more logger name characters (#4983)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-09-14 16:56:16 +02:00
NadaharandGitHub adfa286a3a Fix network interface configuration option enumeration (#5006)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-09-07 18:51:51 +02:00
NadaharandGitHub 8537a1b822 Reintroduce a check with scriptEngineManager if the script type is supported before attempting to compile it (#4971)
It was removed in 8154dce3076d56df5e1d87b2fd465c8232f7cba1 (#4922) and might be causing the logging of errors during startup, as reported in #4965.

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-08-24 08:22:29 +02:00
NadaharandGitHub a6ea26f8f5 Prevent file system access for WatchService DELETE events in FolderObserver (#4907)
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-07-17 12:10:13 +02:00
NadaharandGitHub 5b12280f5b Regenerate rules from templates (#4718)
* Rule template regeneration support

Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
2025-05-26 22:53:17 +02:00
NadaharandGitHub d3cfba562b Fix managed transformations retrieval (#4574) 2025-02-05 15:15:03 +01:00