State Description metadata

I;m wanting to retrieve the state description metadata in a Blockly rule, I see we have some metadata blocks now, but I;m unclear how I retrieve a state description. What namespace do I need to use? The state description options are in the form of a map, how do I retrieve and use this?

Thanks.

  • Platform information:
    • Hardware: amd64 / oodles
    • OS: Linux 5.14.21-150400.24.81-default
    • Java Runtime Environment: OpenJDK 17.0.8
    • openHAB version: 4.0.2

stateDescription

As a general rule, one way to find the namespace for the well known metadata is to click on it in MainUI and look at the top of the page.

For custom metadata, well you should know those namespaces since you create them yourself.

There are a limited set of blocks for working with maps but what’s there should be sufficient.

The “config” of the metadata is a map in the metadata called configuration. options is itself a map.

Thanks for the hint.

With this definition:

I could not get that shape to work:


This approach fails at this point:
[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'UpsChange' failed: org.graalvm.polyglot.PolyglotException: ReferenceError: "ApcStatus_Output" is not defined

Oddly if I dump just the get metadata value straight into the log I get an empty value instead of undefined.

I tried some of the other shapes and have found this approach gets what I need:

It’s quite convoluted, but this example will output the value “CAL”.

I used the wrong block in my example. It should be the get metadata config block like you are using in your working example. But you shouldn’t have to convert the configuration to a String and then convert it back into a List. It’s already a dictionary. You should be able to just pull the value using the get “options” from dictionary block.