Skip to content

[items] Add support for providing Items, metadata & channel links from file-based scripts#441

Merged
florian-h05 merged 14 commits intoopenhab:mainfrom
florian-h05:provider
Jul 8, 2025
Merged

[items] Add support for providing Items, metadata & channel links from file-based scripts#441
florian-h05 merged 14 commits intoopenhab:mainfrom
florian-h05:provider

Conversation

@florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Jul 4, 2025

No description provided.

@florian-h05 florian-h05 added the enhancement New feature or request label Jul 4, 2025
@florian-h05 florian-h05 requested a review from Copilot July 4, 2025 14:12

This comment was marked as outdated.

@florian-h05 florian-h05 marked this pull request as ready for review July 4, 2025 14:29
@florian-h05 florian-h05 requested a review from a team as a code owner July 4, 2025 14:29
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>
@florian-h05 florian-h05 added this to the to be released milestone Jul 8, 2025
@florian-h05 florian-h05 requested a review from Copilot July 8, 2025 21:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 environment module to detect file- vs UI-based execution and conditionally use provider registries.
  • Enhances addItem (and related metadata functions) to accept a persist flag and wire up metadata & channel links.
  • Adds a new flat items.itemChannelLink API and deprecates the old items.metadata.itemchannellink namespace.

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 (and useProviderRegistries) to verify detection of file-based vs UI-based contexts.
function isFileBasedScript () {

src/items/metadata.js:133

  • Consider adding tests for addMetadata to cover both successful additions and the duplicate‐metadata error path.
function addMetadata (itemOrName, namespace, value, configuration, persist = false) {

src/items/itemchannellink.js:98

  • The addItemChannelLink and replaceItemChannelLink methods have different parameter lists (persist only on the former); consider unifying their signatures for consistency.
function addItemChannelLink (itemOrName, channelUID, configuration, persist = false) {

Signed-off-by: Florian Hotze <dev@florianhotze.com>
@florian-h05 florian-h05 merged commit 456800c into openhab:main Jul 8, 2025
5 checks passed
@florian-h05 florian-h05 deleted the provider branch July 8, 2025 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants