Accessing item metadata from DSL rules in OH 4.3 (or 5.x if it helps )

I need to access item metadata from DSL rules

  val SwitchItem myitem = ScriptServiceUtil.getItemRegistry.getItem( myitemname )
  myitem.getMetadata("mymetaname").value  // this does not work    

is my only option restapi from inside of DSL rules?
or maybe 5.0 implements this?

couldnt find any solution on forums :confused:

This is still not implemented in OH5. Theoretically it can be implemented, but you’d need to find someone motivated to do so.

Or, you can delve into the openhab java API from RulesDSL to do it. I think it’s possible, albeit a bit more cumbersome.

Alternatively, switch to jsscripting, jruby or python.

@Lolodomo AFAIK you’re still using a lot of DSL.
Would you maybe be willing to take a shot at this?

1 Like