temporaryItem.label = "testItem Label" // Change label
temporaryItem.category = "slider" // Change Category ie icon
newItem.addTags("Control", "Light") // This does Semantic Class and Semantic Property as well as custom tags.
newItem.removeTag("Control") // Remove a tag
ScriptServiceUtil.getItemRegistry.add(temporaryItem) // Adds this temporary item to the database and model.
ScriptServiceUtil.getItemRegistry.remove(testItem) // Remove item
A_Group.addMember(testItem) // Add to a group
A_Group.removeMember(testItem) // Remove from a group
ScriptServiceUtil.getItemRegistry.update(newItem) // Not 100% how this works. Some changes seem to need to be 'updated' to survive a reboot.
Are there other useful things you can do with items in rules DSL?
And how do I add metadata in rules DSL? Like stateDescription and WidgetOrder and HomeKit etc
There are limitations on what can be done with Items created in this way. You’ll have to experiment to see what works and what doesn’t. For example, you can create the Item but can you later delete it? Is the Item available outside this Rule? Persistence? etc.
You can’t. There’s no access to the metadata registry available in Rules DSL. Other languages do have access though, including Blockly I believe.
These are all Java classes. Make use of that link to the JavaDocs above. You can search for class names (all the Item class names follow the same naming pattern). The only apparent way to set the base type and aggregation function is in the constructor. But I suspect if you create a new GroupItem and call update on the ItemRegistry it will change those to match.
Look at the types of the arguments. It takes a String, an Item, and a GroupFunction as the three arguments. You are passing three Strings. You’ll need to instantiate an Item for the type and instantiate a GroupFunction for the function and pass those as arguments.