I need some help for this topic. I’ve already tried a lot and I’m sure there is an easy way to get the Metadata that is assigned to an Item from an jsr223 script using Groovy.
Id like to use some “shading” related metadata that I add to my blinds rather than hard-code them into the script.
Can you help me?
Hi,
A bit short on information, but I’ll give it a try.
If the values are stored under config, you can access them with getItemMetaConfigValue.
Beispiel: Item have metadata “automation”
sorry for the little amount of detail. Seems I underestimate the complexity. Thanks for trying to answer any way!
A method like getItemMetaConfigValue('itemID', 'automation', '4'); sounds exactly like what I need. But I can not get hold of one. Might be I miss something I need to call or statically import before to get the method injected?
All I get is:
No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getItemMetaConfigValue() is applicable for argument types: (String, String, String)
So unfortunately this does not work (for me).
Here a simple sample groovy file that I now use to test this and should give the details about what I want to do:
Error during evaluation of script '/openhab/conf/automation/jsr223/groovy/.../MetadataAccess.groovy':
javax.script.ScriptException: groovy.lang.MissingMethodException:
No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.getItemMetaConfigValue()
is applicable for argument types: (String, String, String) values: [Raffstore_Essen_Schiebeture, shading, travelTimeOpenSeconds]
Sorry, my mistake. Created with Blockly and overlooked a feature. It’s been added above. I’m using the wrong language—those who can read have a clear advantage. I’m too small for this world. I’m so sorry.
As documented at JSR223 Scripting | openHAB I see ‘items’ but it is a Instance of java.util.Map<String, State>. It has no property ‘metadata’. So items.metadata is null in my case.