# Is it possible to set the custom capability max value dynamically from the driver?

**URL:** <https://community.homey.app/t/is-it-possible-to-set-the-custom-capability-max-value-dynamically-from-the-driver/74102>\
**Category:** Developers\
**Created:** [December 25, 2022, 2:49pm UTC](https://community.homey.app/t/is-it-possible-to-set-the-custom-capability-max-value-dynamically-from-the-driver/74102 "2022-12-25T14:49:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![OH2TH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/oh2th/32/111414_2.png) [@OH2TH](https://community.homey.app/u/OH2TH)\
**Post date:** [December 25, 2022, 2:49pm UTC](https://community.homey.app/t/is-it-possible-to-set-the-custom-capability-max-value-dynamically-from-the-driver/74102/1 "2022-12-25T14:49:46Z")

</div>

For a capability for current\_limit the target device can be configured in hardware for 16A or 32A in addition depending on connected cable type, it may change to for example 20A.

```auto
{
  "type": "number",
  "title": {
    "en": "Current Limit",
  },
  "getable": true,
  "setable": true,
  "min": 6,
  "max": 32,
  "step": 1,
  "units": {
    "en": "A"
  },
  "uiComponent": "slider",
}

```

For above capability, I would like to be able set the max value on the fly. Can it be done directly on the capability, or do I need to remove and add it back with new limit?

---

<div class="post-metadata">

**Author:** ![OH2TH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/oh2th/32/111414_2.png) [@OH2TH](https://community.homey.app/u/OH2TH)\
**Post date:** [December 25, 2022, 3:17pm UTC](https://community.homey.app/t/is-it-possible-to-set-the-custom-capability-max-value-dynamically-from-the-driver/74102/2 "2022-12-25T15:17:56Z")

</div>

And answer is yes:

```auto
const currentLimitOpts = await this.getCapabilityOptions('current_limit');
// Check for device's maximum current configuration and adjust device current_limit capability maximum setting value.
// Only update if different.
if(currentLimitOpts.max !== deviceInfo.current_max) {
  this.log(`[Device] ${this.getName()}: ${this.getData().id} setCurrentLimitOpts Max: '${deviceInfo.current_max}'`);
  await this.setCapabilityOptions('current_limit', { max: deviceInfo.current_max })
}

```

deviceInfo has been read from the device earlier.
