[ST Edge] What is expected for Display Type 'list' supportedValues?

The example for Display Type list includes the following reference:

"supportedValues": "supportedThermostatModes.value"

What data type is expected and how should the value be formatted?

It is an array of strings. An example using the similar supportedButtonValues in a driver is:

device:emit_event(capabilities.button.supportedButtonValues({"pushed","held","double"}))

1 Like

OK, that’s what I thought. Maybe the array helper only exists for particular attributes?

I have a custom capability with an attribute named filter which is used in a list presentation as “supportedValues”: “filter.value”. If I set filter as “`type”: “string”, I can set it to a string and my list goes empty which makes sense. However, if I set filter as “type”: “array”,

"filter": {
  "schema": {
    "type": "object",
    "properties": {
      "value": {
        "type": "array"
      }
    },

    "additionalProperties": false,
    "required": ["value"]
  }
}

then device:emit_event(fanSpeed3.filter({"Off", "Low", "High"})) generates the error

TimeStamp ERROR MyDriver MyDevice thread encountered error: [string "st/dispatcher.lua"]:229: Error encountered while processing event for <Device: MyDeviceID (MyDevice)>:
    arg1: added
    arg2: table: 0xb2aff8

It sure looks like it doesn’t know what to do with a table regardless of the underlying attribute type.

I don’t really pretend to understand these schema thing. I notice that in the button capability the value has a bit more to it …

"value": {
    "type": "array",
    "items": {
        "title": "ButtonState",
        "type": "string",
        "enum": [
            "pushed",
            "held",
            ...
            "up_hold"
        ]
    }
}

Could that extra bit of structure be important?

Yes, that makes a difference. The error is gone. I think I must have the keys/values reversed because my list is blank.

EDIT: Works as expected. Don’t know if I’ll ultimately have a need for this, but at least we know (how) it works. This is one of the few ways to dynamically alter the UI. Thanks for your help!