I’d love to dynamically populate the StateDescription.option list of an Item, in order to add/remove entries from a selection on a sitemap.
... Selection item=TestSelection ...
String TestSelection "Demo [%s]"
var List<StateOption> options=newArrayList() options.add(new StateOption("1", "Label1")); options.add(new StateOption("2", "Label2")); state = new StateDescription(null, null, null, "%s", false, options); TestSelection.stateDescription.options=options // TestSelection.stateDescription=state
However, the item’s stateDescription does not change, inspecting it with the REST API, neither by assigning values to the stateDescription.options nor by assigning the stateDescription.
Is there any way to replace/modify the stateDescription part of an item from a rule?
Background: I can read playlist options from the Spotify binding using this code:
ItemPlaylists.commandDescription.commandOptions.forEach[ entry | logInfo("Line is",entry.label) ]
Now I want to populate several other items with that information and mix it up with entries from other sources. Currently, I solve this with external PHP scripts that pull the required info from various sources and inject it into the .sitemap file, but I would love to do this within OH.