Commit Graph
42 Commits
Author SHA1 Message Date
a221c4fa41 Persistence upgrader: Create default persistence settings if no configuration so far (#5212)
* fix persistence upgrade

Signed-off-by: Florian Hotze <dev@florianhotze.com>
Co-authored-by: Mark Herwege <mark.herwege@telenet.be>
2025-12-19 21:06:37 +01:00
Florian HotzeandGitHub cbf43fdc9c Update path for persistence health endpoint (#5198)
See https://github.com/openhab/openhab-core/pull/4682#discussion_r2619044396.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-12-16 22:50:05 +01:00
Florian HotzeandGitHub ac59fba8a7 BusEventImpl: Fix source not passed for sendCommand(Item, String, String) (#5150)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-11-25 18:17:32 +01:00
Florian HotzeandGitHub e39eb5df7c DefaultScriptScopeProvider: Provide BusEventImpl instead of ScriptBusEventImpl (#5136)
org.openhab.core.automation.module.script...ScriptBusEventImpl was a copy of org.openhab.core.model.script...BusEvent,
which was removed in #5122.
In #5122, a org.openhab.core.automation.module.script...BusEventImpl was added, which is already used by the org.openhab.core.model.script bundle.

I think the ScriptBusEventImpl copy of the old BusEvent class was done to avoid a dependency org.openhab.core.automation.module.script => org.openhab.core.model.script.
As we now have a BusEventImpl in the automation bundle, we can use it for the DefaultScriptScopeProvider and get rid of ScriptBusEventImpl.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-11-21 08:43:44 +01:00
Florian HotzeandGitHub a1a92f2dcc Populate source when sending Item events via BusEvent (#5122)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-11-13 21:48:19 +01:00
Florian HotzeandGitHub 7e3ceea80c ConfigDescriptionParameter: Format JavaDoc using HTML tags (#5126)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-11-13 21:43:51 +01:00
Florian HotzeandGitHub ed8f54a41c Refactor BusEvent to ScriptExtension (#5064)
Comparable to #3155.

JSR-223 automation add-ons often use the script actions from the org.openhab.core.model.script bundle.
The downside is that the actions are tied to XText or at least use some hacks to provide static access to OSGi services.

This refactors the BusEvent actions, making them available as ScriptExtension via import-preset ScriptAction.
The actions are wrapped for DSL rules, to stay backward compatible.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-11-10 22:49:19 +01:00
Florian HotzeandGitHub 26015ff8c5 ScriptTransformationService: Handle engine removal through ScriptEngineManager (#5063)
* ScriptTransformationService: Fix engine closed too early

Currently, there are two issues:

When a ScriptRecord is cleared from the cache,
the ScriptTransformationService currently closes the ScriptEngine itself, without involving the ScriptEngineManager.
If a transformation script is invoked again after it has been cleared from the scriptCache, the ScriptEngineManager::createScriptEngine call makes the ScriptEngineManager first remove the old engine from its internal "store",
which includes invoking the scriptUnloaded hook. This invocation can cause an exception because the engine is already closed (by ScriptTransformationService) and hence function/method invocations inside the engine are not possible anymore.

Ff the engine implement Compilable, it is even closed two times by ScriptTransformationService, possibly causing an exception if the ScriptEngine doesn't handle multiple close() calls gracefully.

These issues are fixed by properly notifying the ScriptEngineManager when an engine should be removed and leaving the removal handling to the ScriptEngineManager.

The issues were discovered while working on #5062.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-10-10 23:30:56 +02:00
Florian HotzeandGitHub 508f1f61cc ScriptTransformationService: Implement missing script dependency tracking (#5062)
Closes #5046.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-10-10 23:26:34 +02:00
Florian HotzeandGitHub f600c8dcba [automation] AbstractScriptModuleHandler: Inject module type ID early (#5058)
Follow-up for #5054.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-10-05 20:50:35 +02:00
Florian HotzeandGitHub 86e8adb42e [automation] AbstractScriptModuleHandler: Inject module type ID into context (#5054)
* [automation] AbstractScriptModuleHandler: Inject module type ID into context

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-10-03 19:43:23 +02:00
Florian HotzeandGitHub dc48fb8527 [automation] Skip pre-compilation if rule engine not yet started (#5001)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-09-07 15:16:33 +02:00
Florian HotzeandGitHub 9c27b896d0 [automation] AbstractScriptModuleHandler: Remove prefixes from context entries before injecting ctx into execution context (#4919)
This aligns the keys of the injected `ctx` HashMap with the keys used when injecting the single entries of that HashMap.

It will allow JS Scripting to provide event information in a native JS object in UI-based scripts similarly to how it's done for file-based scripts.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-08-16 13:15:08 +02:00
Florian HotzeandGitHub e3ecd8d4d2 [rest] Remove faulty caching from add-on resource (#4925)
Fixes #4834.
Partly reverts #4107.

The caching of the add-on resource is faulty, e.g. changes to the community marketplace settings don't invalidate the cache.
As Main UI now better handles add-on store loading, caching is no more needed there.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-08-15 00:31:44 +02:00
Florian HotzeandGitHub 2689f5f2dc AbstractScriptModuleHandler: Recompile scripts on dependency change (#4922)
* AbstractScriptModuleHandler: Recompile scripts on dependency change

When a script's dependency changes, it should recompile the compiled script similarly to resetting the engine for uncompiled scripts.
Fixing this behaviour fixes an issue where compiled scripts stopped working after a dependency changed.

This also simplifies the code a bit.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-08-15 00:25:42 +02:00
Florian HotzeandGitHub d83d35cd00 [automation] Add logging to script actions/conditions pre-compilation (#4893)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-07-11 19:17:47 +02:00
Florian HotzeandGitHub 77530fe2eb [thing] Add SemverVersion type to be used by bindings (#4875)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-07-01 08:31:31 +02:00
Florian HotzeandGitHub 80d20d1f3e [automation] Extend provider script extension for metadata & ItemChannelLinks (#4865)
* [automation] Move provider script extension to a new bundle
* [automation] Add ProviderRegistryDelegate interface and improve ProviderScriptExtension code
* [automation] Add ScriptedMetadataProvider & ProviderMetadataRegistryDelegate
* Rename ProviderRegistryDelegate.java to ProviderRegistry.java
* [automation] Add ScriptedItemChannelLinkProvider & ProviderItemChannelLinkRegistry
* [automation] Implement ProviderItemChannelLinkRegistry::purge

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-06-29 11:32:10 +02:00
Florian HotzeandGitHub 6bd830af24 [rest] Add editable field to metadata (#4874)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-06-28 18:51:25 +02:00
Florian HotzeandGitHub 7b56bdbaf2 Fix itests after #4513 (#4856)
This change fixes the problem by explicitly retrieving the GenericItemProvider.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-06-17 22:45:45 +02:00
Florian HotzeandGitHub f695acfc4c [automation] Add provider script extension (#4513)
* [automation] Add provider script extension

This new script extension allow scripts to provide openHAB entities like Items without needing to manually handle the lifecycle of those.
First, we will only provide an itemRegistry, but this can easily be extended later.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-06-14 14:46:59 +02:00
Florian HotzeandGitHub 5126166611 [rest] Add timezone information to root resource (#4826)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-05-30 03:12:10 +02:00
Florian HotzeandGitHub 8ff69a3f50 [rest] Support sending Item command/state as JSON (#4760)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-05-09 22:32:38 +02:00
Florian HotzeandGitHub e41db78804 JsonAddonService: Fix warning on startup (#4602)
When starting openHAB, I always get the following warning:

```
14:44:47.082 [WARN ] [tplace.internal.json.JsonAddonService] - JSON Addon Service invalid URL:
```

We should avoid this warning, I don't see a problem there, and we should not confuse users with unnecessary warnings.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-02-16 15:52:39 +01:00
Florian HotzeandGitHub 4ec2b3c457 Add topic filter for event WebSocket (#4550)
* Add topic filter for event WebSocket

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-02-15 16:20:41 +01:00
Florian HotzeandGitHub f8fdd66f78 [websocket] Change EventWebSocketAdapter adapter id to events (#4540)
This is aligns the event WS name with the SSE events endpoint.
This is a breaking change for clients that have explicitly used `/ws/event-subscriber` instead of the default `/ws`.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2025-01-06 19:57:55 +01:00
Florian HotzeandGitHub cb4d4b8c74 Item triggers: Suggest using conditions that for comparing Item state (#4530)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-12-31 17:30:56 +01:00
Florian HotzeandGitHub 25ca43d165 [websocket] Support token authentication through header (#4515)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-12-31 17:00:40 +01:00
Florian HotzeandGitHub 7a61dc4b5b Start spifly early (#4526)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-12-28 18:35:13 +01:00
Florian HotzeandGitHub 7005c7f15e ConfigDescriptionParameter & Input: Add null annotations & improve JavaDoc (#4465)
* Add null annotations to org.openhab.core.automation.type.Input
* Add null annotations to org.openhab.core.config.core.ConfigDescriptionParameter

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-12-01 12:28:25 +01:00
Florian HotzeandGitHub 31d3434893 [rest] Fix ThingActionsResource does not accept new Thing action UIDs with hash (#4445)
* [rest] Fix ThingActionsResource does not accept new Thing action UIDs due to wrong path RegEx

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-11-11 09:13:25 +01:00
Florian HotzeandGitHub 0d031a3b78 [automation] Ensure unique module IDs for overloaded @RuleAction methods (#4441)
* [automation] Handle overloaded `@RuleAction`s - Append signature hash to avoid duplicate module ids.
* [automation] ThingActionsResource: Provide action visibility

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-11-10 14:11:24 +01:00
Florian HotzeandGitHub 3bc9ae3e14 [automation] ActionInputsHelper: Enhance ZonedDateTime & Instant input support (#4440)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-11-08 17:59:55 +01:00
4eec4a3e45 ScriptProfile: Recover from closed context for JS Scripting (#4437)
Co-authored-by: J-N-K <github@klug.nrw>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-11-06 21:20:34 +01:00
Florian HotzeandGitHub a31e8376a4 [automation] ActionInputsHelper: Set step size to 1 for datetime & time to enable seconds (#4436)
Refs https://github.com/openhab/openhab-webui/pull/2848.
Discussion in https://github.com/openhab/openhab-webui/issues/2847#issuecomment-2446426478.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-11-06 09:17:29 +01:00
Florian HotzeandWouter Born 9646607e47 [rest] VoiceResource: Return answer from /interpreters endpoint & Add annotations for answer
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-11-02 11:09:58 +01:00
Florian HotzeandGitHub 7f5fbbb22f Thing actions: Process @ActionOutput for actions with single return value & Enforce proper annotations (#4430)
See discussion in https://github.com/openhab/openhab-addons/issues/17504#issuecomment-2439906483.

This adds processing of the ActionOutput annotation for Thing actions with a single return value, which allows providing a label for use in the UI.
The output name for those actions is "result", which is now the default value in the @ActionOutput annotation. If a binding overrides the default name, a warning is logged.

If a Thing action returns a Map<String, Object> but does not provide the @ActionOutputs annotation, a warning is logged.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-10-27 19:53:19 +01:00
Florian HotzeandGitHub 922a2068c0 [automation] Synchronize script action/condition execution if engine implements Lock (#4426)
This moves the locking mechanism added in #4402 to the inheritors of AbstractScriptModuleHandler
to synchronize execution context access as well.

This fixes the problem thathttps://github.com/openhab/openhab-addons/pull/17510 worked around by using Thread.sleep.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-10-26 23:26:20 +02:00
Florian HotzeandGitHub 52b26baf17 ActionInputsHelper: Allow any number of decimals & Apply primitive input default values (#4424)
* ActionInputHelper: Set step site to 0 if param type decimal

This makes the UI allow any step size, i.e. entering any number of decimals.

Signed-off-by: Florian Hotze <dev@florianhotze.com>

* ActionInputHelper: Apply default values when mapping from serialised to action inputs

This has been forgotten to be implemented.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-10-26 21:49:18 +02:00
Florian HotzeandGitHub 4125f3d87b ConfigDescriptionParameter: Document step size value 0 to allow any step size (#4425)
Refs https://github.com/openhab/openhab-webui/pull/2832.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-10-26 20:36:03 +02:00
Florian HotzeandGitHub ae1f763b62 ConfigDescriptionParameter: Change default format for datetime & Update context docs (#4428)
* ConfigDescriptionParameter: Change default format for datetime & Update context docs

This changes the default format for the datetime context to the ISO standard.
This context is not used by add-ons and supported by the UI, so it should be possible to change it (again after #4392.)

Also update the context docs from https://next.openhab.org/docs/developer/addons/config-xml.html#supported-contexts and the UI code.

Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-10-26 20:31:08 +02:00
Florian HotzeandGitHub 63788b061b ActionOutput: Document QR code rendering & Fix action REST doc (#4421)
Signed-off-by: Florian Hotze <dev@florianhotze.com>
2024-10-26 09:12:11 +02:00