getCapabilityOptions : how does it work?

Hello
I’m trying to play with custom capabilities, to enrich my app
but i (again) bump into I presume a bad understanding of how this all works. Probably my level of english not good enough to perfectly understand the manuals

there is my problem : when init’ing my device (within the onInit method) I just want to update some options of my capability. But I do not know how to access the options.

When I run :

const capabilityList = this.getCapabilities();
this.log (capabilityList);

this works fine, I properly get the list that I defined in the json files :

[
‘onoff’,
‘volume_down’,
‘volume_mute’,
‘volume_up’,
‘station_capability’,
‘measure_channel_capability’
]

but at the same place within onInit, if i try to access the options :

        const option = this.getCapabilityOptions ('*any of the above capability id*');
        this.log (option);

I just get

{}

any clue of what I’m doing wrong ?
Thank you

I think the object will only be populated if you explicitly set options for the capability (from app.json or programmatically).

Thank you @robertklep. Actually options are populated from the json files - and it even does not work if I try setCapabilityOptions just before.
It just looks like I’m using a kind of wrong syntax basically

I tested with defining options in app.json:

      "capabilitiesOptions": {
        "meter_power": {
          "units": {
            "en": "μfoo"
          }
        }
      }

And when calling console.log(this.getCapabilityOptions('meter_power')), I get what was defined:

{ units: { en: 'μfoo' } }
1 Like

Oh thank you I now realize my error.
I actually wanted to update the values list for an enum capability. But these values are a property of the capability, not an option.
So I have to search elsewhere how I could define this list dynamically.

As far as I know, you can’t change those properties. You’d have to create a custom capability with your particular values.

I have been asking for a long time to be able to create a pick list type UI element that can be changed at runtime. I’m not sure it will ever happen.

ok now we are two… :sleepy:

Three. I have a number with min/max that can change at runtime. No way to change that?