# getCapabilityOptions : how does it work?

**URL:** <https://community.homey.app/t/getcapabilityoptions-how-does-it-work/49400>\
**Category:** Developers\
**Created:** [July 13, 2021, 8:02pm UTC](https://community.homey.app/t/getcapabilityoptions-how-does-it-work/49400 "2021-07-13T20:02:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aybert](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Aybert](https://community.homey.app/u/Aybert)\
**Post date:** [July 13, 2021, 8:02pm UTC](https://community.homey.app/t/getcapabilityoptions-how-does-it-work/49400/1 "2021-07-13T20:02:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 14, 2021, 5:37am UTC](https://community.homey.app/t/getcapabilityoptions-how-does-it-work/49400/2 "2021-07-14T05:37:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Aybert](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Aybert](https://community.homey.app/u/Aybert)\
**Post date:** [July 14, 2021, 1:30pm UTC](https://community.homey.app/t/getcapabilityoptions-how-does-it-work/49400/3 "2021-07-14T13:30:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 14, 2021, 1:44pm UTC](https://community.homey.app/t/getcapabilityoptions-how-does-it-work/49400/4 "2021-07-14T13:44:20Z")

</div>

I tested with defining options in `app.json`:

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

```

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

```auto
{ units: { en: 'μfoo' } }

```

---

<div class="post-metadata">

**Author:** ![Aybert](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Aybert](https://community.homey.app/u/Aybert)\
**Post date:** [July 14, 2021, 3:12pm UTC](https://community.homey.app/t/getcapabilityoptions-how-does-it-work/49400/5 "2021-07-14T15:12:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [July 14, 2021, 3:15pm UTC](https://community.homey.app/t/getcapabilityoptions-how-does-it-work/49400/6 "2021-07-14T15:15:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [July 15, 2021, 12:18pm UTC](https://community.homey.app/t/getcapabilityoptions-how-does-it-work/49400/7 "2021-07-15T12:18:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Aybert](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@Aybert](https://community.homey.app/u/Aybert)\
**Post date:** [July 15, 2021, 4:00pm UTC](https://community.homey.app/t/getcapabilityoptions-how-does-it-work/49400/8 "2021-07-15T16:00:54Z")

</div>

ok now we are two… 😪

---

<div class="post-metadata">

**Author:** ![Fredric\_Georgsson](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fredric_georgsson/32/59646_2.png) [@Fredric\_Georgsson](https://community.homey.app/u/Fredric_Georgsson)\
**Post date:** [September 18, 2022, 11:43am UTC](https://community.homey.app/t/getcapabilityoptions-how-does-it-work/49400/9 "2022-09-18T11:43:10Z")

</div>

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