[items] Add support for providing Items, metadata & channel links from file-based scripts#441
Merged
florian-h05 merged 14 commits intoopenhab:mainfrom Jul 8, 2025
Merged
Conversation
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Has been tested. Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Florian Hotze <dev@florianhotze.com>
There was a problem hiding this comment.
Pull Request Overview
This PR extends script-based item management by enabling file-based scripts to provide Items, metadata, and channel links with optional persistence.
Key changes:
- Introduces an
environmentmodule to detect file- vs UI-based execution and conditionally use provider registries. - Enhances
addItem(and related metadata functions) to accept apersistflag and wire up metadata & channel links. - Adds a new flat
items.itemChannelLinkAPI and deprecates the olditems.metadata.itemchannellinknamespace.
Reviewed Changes
Copilot reviewed 9 out of 26 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/environment.js | New environment utilities to detect script context |
| src/items/metadata.js | Added addMetadata API with persistence support |
| src/items/itemchannellink.js | New items.itemChannelLink module exposing channel-link methods |
| src/items/items.js | Updated addItem to include persist, metadata & channel linking |
| src/index.js | Exposed environment in top‐level API |
| README.md | Documentation for new persistence options |
| CHANGELOG.md | Unreleased entries for environment and items enhancements |
Comments suppressed due to low confidence (3)
src/environment.js:18
- Add unit tests for
isFileBasedScript(anduseProviderRegistries) to verify detection of file-based vs UI-based contexts.
function isFileBasedScript () {
src/items/metadata.js:133
- Consider adding tests for
addMetadatato cover both successful additions and the duplicate‐metadata error path.
function addMetadata (itemOrName, namespace, value, configuration, persist = false) {
src/items/itemchannellink.js:98
- The
addItemChannelLinkandreplaceItemChannelLinkmethods have different parameter lists (persistonly on the former); consider unifying their signatures for consistency.
function addItemChannelLink (itemOrName, channelUID, configuration, persist = false) {
Signed-off-by: Florian Hotze <dev@florianhotze.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.