Setting capability value for enums

I’m trying to set a capability value for a custom enum capability in my app, but I get a Error: invalid_capability at Remote Process error every time.
Is there a specific way to do this for enums?

climate_mode.json

{
  "type": "enum",
  "uiComponent": "picker",
  "title": {
    "en": "Climate Control Mode"
  },
  "values": [
    {
      "id": "1",
      "title": {
        "en": "Away"
      }
    },
    {
      "id": "2",
      "title": {
        "en": "Home"
      }
    },
    {
      "id": "3",
      "title": {
        "en": "Boost"
      }
    },
    {
      "id": "4",
      "title": {
        "en": "Travel"
      }
    },
    {
      "id": "5",
      "title": {
        "en": "Off"
      }
    },
    {
      "id": "6",
      "title": {
        "en": "Fireplace"
      }
    }
  ],
  "getable": true,
  "setable": true,
  "insights": false
}

This is how I try to set it in device.ts:

this.setCapabilityValue('climate_mode', '1');

Is the capability defined in the driver (app.json)?
And if it was added after inclusion, did you either add the addCapability function (with appropriate checks) or reinclude the device?

Your way if changing the value is the correct way.

1 Like

@Caseda Thanks for the help, it started working after I re-added the device. So I basically need to have some sort of migration if I add capabilities after inclusion?

correct, it is explained here: