[JS Rule] How can I get itemConfig data of exist Item?

In addItem() & replaceItem() functions calling should be used “itemConfig”.
But how can I get itemConfig data of exist Item? I need get config data of namespaces.

itemConfig is something that only exists in the openhab-js library. However, most of the properties of an itemConfig are available on the Item Object. But some are missing (e.g. category, giBaseType, etc.) and others will be got to elsewhere (e.g. channel links).

The access to metadata is also not complete.

This does look like something that could be a useful addition so please file an issue on the openhab-js repo.

In the mean time, you’ll need to explore a bit to find how to get all that info from an existing Item. Some, like category is available on the rawItem which is the original Java Item Object. GenericItem (openHAB Core 4.0.0-SNAPSHOT API). The rest you might need to pull the relevant registry service and use that. e.g. ItemChannelLinkRegistry (openHAB Core 4.0.0-SNAPSHOT API)

1 Like

Then you don’t need the itemConfig. A new improved API was introduced to allow this, but currently both good docs and a release that includes this improvement are missing.
If you install the latest openHAB JavaScript library development Version as described here: GitHub - openhab/openhab-js: openHAB JavaScript Library for JavaScript Scripting Automation, you can get metadata configuration as an object:

var conf = items.metadata.getMetadata(itemName, namespace).configuration;

itemConfig was never supposed to be a Item representation for existing Items, instead it just tells addItem/replaceItem how the newly created Item has to „look“.