# Custom capability Enum dynamic values

**URL:** <https://community.homey.app/t/custom-capability-enum-dynamic-values/21609>\
**Category:** Developers\
**Created:** [November 30, 2019, 10:08pm UTC](https://community.homey.app/t/custom-capability-enum-dynamic-values/21609 "2019-11-30T22:08:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaxvandeLaar](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/maxvandelaar/32/18367_2.png) [@MaxvandeLaar](https://community.homey.app/u/MaxvandeLaar)\
**Post date:** [November 30, 2019, 10:08pm UTC](https://community.homey.app/t/custom-capability-enum-dynamic-values/21609/1 "2019-11-30T22:08:37Z")

</div>

Hello everyone,

I am developing an app where the user can select/set the TV channel by picking it from a list. I figured the list should be a custom capability of type enum, however, it requires me to set the values in the app.json. I do not want this, as the values should be the TV channels coming from the tv’s API.

```auto
// app.json

  ...
  "capabilities": {
    "channel_set": {
      "type": "enum",
      "title": {
        "en": "Channel"
      },
      "uiComponent": "picker",
      "getable": true,
      "setable": true,
      "values": [{
        "id": "empty",
        "title": {
          "en": "Empty"
        }
      }],
      "icon": "/assets/icon.svg"
    }
  },
  drivers: [
    ...
    "capabilities": [
      ...
      "channel_set"
    ],
  ]

```

This shows a picker with only 1 value, ‘Empty’. This is good, so far, now I want to change the picker values. So what I tried, when the TV connects (device.js), gather the list from the API and map it correctly.

```javascript
// device.js

    ... // TV connects here
    const channelList = [
        {
            id: 'some_id',
            title: {
                en: "Some Title"
            }
        }
    ]
    this.setCapabilityOptions('channel_set', {values: channelList}).then(() => {
        this.log('Finished setting list'); // THIS IS CALLED, SO I EXPECT AN UPDATED PICKER
    }, (error) => {
        this.error(error)
    });

```

This however does not seem to do anything.

The picker in the app still has the values declared in the app.json instead of what is set in the device.js. Any help or pointers are welcome.

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [November 30, 2019, 11:14pm UTC](https://community.homey.app/t/custom-capability-enum-dynamic-values/21609/2 "2019-11-30T23:14:08Z")

</div>

capabilities are _static_ as soon as the device is paired, so values need to be determined before/during pairing, that also includes the enum values.  
This is done on purpose, as it might be confusing if a user suddenly has more or less values to select from, also breaking flows.

---

<div class="post-metadata">

**Author:** ![MaxvandeLaar](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/maxvandelaar/32/18367_2.png) [@MaxvandeLaar](https://community.homey.app/u/MaxvandeLaar)\
**Post date:** [December 1, 2019, 10:05am UTC](https://community.homey.app/t/custom-capability-enum-dynamic-values/21609/3 "2019-12-01T10:05:51Z")

</div>

Thanks for pointing this out, I partially agree with the reason why (but that’s not up for discussion anyway). How to deal with these situations? Is there a workaround or a different technique I should look into?

---

<div class="post-metadata">

**Author:** ![MaxvandeLaar](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/maxvandelaar/32/18367_2.png) [@MaxvandeLaar](https://community.homey.app/u/MaxvandeLaar)\
**Post date:** [December 1, 2019, 12:17pm UTC](https://community.homey.app/t/custom-capability-enum-dynamic-values/21609/4 "2019-12-01T12:17:32Z")

</div>

I tried setting the capabilities in the createDevice method during pairing, however I cannot seem to get this to work? Am I missing something?

---

<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:** [February 9, 2022, 7:50pm UTC](https://community.homey.app/t/custom-capability-enum-dynamic-values/21609/5 "2022-02-09T19:50:55Z")

</div>

+1
