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

Can not create item metadata config using openhab-js #108

Closed
jhuizingh opened this issue Apr 10, 2022 · 2 comments · Fixed by #109
Closed

Can not create item metadata config using openhab-js #108

jhuizingh opened this issue Apr 10, 2022 · 2 comments · Fixed by #109
Labels
bug Something isn't working

Comments

@jhuizingh
Copy link

Although itemMetadata is included as an option on the createItem function, that value does not seem to be used if I am reading this correctly.

Additionally, there is a mismatch between the signatures for addItem, createItem, and replaceItem, although it seems like they all ultimately call createItem under the hood so it would be really nice if they had the same options. On a related note, it is not clear to me what the difference between addItem and createItem is or what it means to me when I am developing a script.

Expected Behavior

When creating an item using this library, I can configure any metadata I need.

Current Behavior

I am unable to create/configure metadata on an item. There is an ability to set the value of metadata, but i want to set the config of metadata.

Possible Solution

Steps to Reproduce (for Bugs)

Context

Your Environment

  • Version used: (e.g., openHAB and JS Scripting add-on version)
  • Environment name and version (e.g. Chrome 76, Java 8, Node.js 12.9, ...):
  • Operating System and version (desktop or mobile, Windows 10, Raspbian Buster, ...):
@jhuizingh jhuizingh added the bug Something isn't working label Apr 10, 2022
@florian-h05
Copy link
Contributor

florian-h05 commented Apr 10, 2022

Additionally, there is a mismatch between the signatures for addItem, createItem, and replaceItem, although it seems like they all ultimately call createItem …

Yes, they all ultimately call createItem. The mismatch in their params/signature is something I will correct as soon as I had a look at everything you mentioned.

On a related note, it is not clear to me what the difference between addItem and createItem is or what it means to me when I am developing a script.

createItem creates a new Item object that is not registered with any provider and therefore not in the Item registry. That means, that createItem actually doesn‘t really create an openHAB Item, it only creates an Item object. Currently I have no use case for createItem in mind for developing a script. I think createItem is meant to be a private function the normal user should not see.

addItem adds the Item object that createItem returns to the registry, what makes it a real openHAB Item.

When you develop a script, you can ignore createItem and use addItem to add/create openHAB Items.

When creating an item using this library, I can configure any metadata I need.

I am working on fixing this now

florian-h05 added a commit to florian-h05/openhab-js that referenced this issue Apr 10, 2022
Fixes openhab#108.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@jpg0 jpg0 closed this as completed in #109 Apr 23, 2022
@jhuizingh
Copy link
Author

Thank you, @florian-h05!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants