openhab / openhab-js

openHAB JavaScript Library for JavaScript Scripting Automation
https://www.openhab.org/addons/automation/jsscripting/
Eclipse Public License 2.0
38 stars 31 forks source link

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

Closed jhuizingh closed 2 years ago

jhuizingh commented 2 years ago

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)

1. 2.

Context

Your Environment

florian-h05 commented 2 years ago

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

jhuizingh commented 2 years ago

Thank you, @florian-h05!