# Device Capabilities

Starting from version 12.2.0, Homey Pro (Early) 2023 will shift its approach to favour custom capabilities over system capabilities, aligning with the behaviour already seen in Homey Pro 2016-2019.

Currently, when a custom capability on Homey Pro (Early) 2023 shares an ID with a system capability, system Flow cards are generated for that device. However, with the upcoming change, these Flow cards will no longer be available.

To ensure that existing Flows continue to work seamlessly, apps that use system IDs for custom capabilities will need to update their drivers. There are two ways to make sure nothing in your app breaks. The easiest way is to remove your custom capability from your .homeycompose. This will instead make Homey use the system capability and generate the system Flow cards.

### Keeping your custom capability

You can also choose to keep your custom capability. This can be useful if it differs from the system capability. To avoid breaking Flow cards, make sure to add a flow\.compose.json to the effected Drivers containing the Flow cards with the same Flow IDs.

The capability IDs listed below are currently used in various apps as custom capabilities. Each file contains the Flow card ID's for that capability. By copying these Flow card ID's and adding them to your drivers flow\.compose.json all Flows should keep running.

### Device Flow Cards

When your app has multiple drivers that require the same device Flow card, you can put the Flow card definition in your .homeycompose. You can then add a device argument and a filter to make the Flow card appear for the right drivers. See [device Flow arguments](https://apps.developer.homey.app/the-basics/flow/arguments#device) for more information.

{% code title="/.homeycompose/flow/actions/disco\_mode.json" %}

```json
{
  "title": { "en": "Disco mode" },
  "args": [
    {
      "type": "device",
      "name": "device",
      "filter": "driver_id=my_driver"
    }
  ]
}
```

{% endcode %}

### Registering Run Listeners

For some Flow cards you will also need to register the correct listeners. The listeners for each capability can be found below the corresponding files. These listeners can be added to your app in the app.js `onInit()` function.

### Duration

If you have enabled duration for any capabilities through the capability options, you will also have to add `duration: true` to each action Flow card that should support it in your `driver.flow.compose.json`.

{% code title="/drivers/\<driver\_id>/driver.flow\.compose.json" %}

```json
{
  "actions": [
    {
      "id": "on",
      "highlight": true,
      "duration": true,
      "title": { "en": "Turn on" }
    }
  ]
}
```

{% endcode %}

### Capabilities

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-6aa0451ff9cce42082572d025b81de11e7460b91%2Falarm_contact.json?alt=media&token=2a272c16-868a-41bf-af9e-31582c51fa50>" %}

{% code title="/app.js" %}

```javascript
this.homey.flow.getConditionCard('alarm_contact').registerRunListener((args, state) => {
  return args.device.getCapabilityValue('alarm_contact');
});
```

{% endcode %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-3b663acbe3e14b06fe26b6813cb41b04efbbacb1%2Falarm_generic.json?alt=media&token=c32d92e3-63b1-4306-a249-4a4d8139cf50>" %}

{% code title="/app.js" %}

```javascript
this.homey.flow.getConditionCard('alarm_generic').registerRunListener((args, state) => {
  return args.device.getCapabilityValue('alarm_generic');
});
```

{% endcode %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-a46b32cd520d067cd3511c12313b2e3ae8289360%2Falarm_motion.json?alt=media&token=d518573c-7c53-433b-b43c-352fe11af502>" %}

{% code title="/app.js" %}

```javascript
this.homey.flow.getConditionCard('alarm_motion').registerRunListener((args, state) => {
  return args.device.getCapabilityValue('alarm_motion');
});
```

{% endcode %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-e165572c896cefd94498d6d02346c058da11bf56%2Falarm_smoke.json?alt=media&token=18e3457c-fcc0-427d-a6bb-55ac5603666b>" %}

{% code title="/app.js" %}

```javascript
this.homey.flow.getConditionCard('alarm_smoke').registerRunListener((args, state) => {
  return args.device.getCapabilityValue('alarm_smoke');
});
```

{% endcode %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-9cff85f94a3b53d5a77e7efb568f06a6c388024e%2Falarm_tamper.json?alt=media&token=b683a691-5335-46b0-af63-e405a90212e5>" %}

{% code title="/app.js" %}

```javascript
this.homey.flow.getConditionCard('alarm_tamper').registerRunListener((args, state) => {
  return args.device.getCapabilityValue('alarm_tamper');
});
```

{% endcode %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-924477459d2f79b2ddca6be4e36349af77b4b023%2Fhomealarm_state.json?alt=media&token=cb418a85-ef3b-4b6d-9e44-1b040fa5ee5a>" %}

{% code title="/app.js" %}

```javascript
this.homey.flow.getDeviceTriggerCard('homealarm_state_changed').registerRunListener((args, state) => {
  return args.device.getCapabilityValue('homealarm_state') === args.state;
});
this.homey.flow.getConditionCard('homealarm_state_is').registerRunListener((args, state) => {
  return args.device.getCapabilityValue('homealarm_state') === args.state;
});
this.homey.flow.getActionCard('set_homealarm_state').registerRunListener((args, state) => {
  return args.device.setCapabilityValue('homealarm_state', args.state);
});
```

{% endcode %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-90574660f1f54c684c18a3b11226e61d7fd222d9%2Fmeasure_battery.json?alt=media&token=b95977c4-194d-4c6c-b9c6-63b0f237aa85>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-e64f76a5e2d24e9e58f1823a3ad838b9082c6c56%2Fmeasure_co.json?alt=media&token=e49f944c-e32e-40c0-9c89-4a9d1da6dc02>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-451a95c5808c92e8ef7a2287be42c648c2757c23%2Fmeasure_co2.json?alt=media&token=81f16cbd-d274-49ad-beb3-7fc68f27cc69>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-8f3c82949cd3cc798773864e43a434b1c25f4263%2Fmeasure_current.json?alt=media&token=4c6c011f-dd45-4f76-953b-7ea371198fe5>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-d6707a2b0b519f7e1297f3147104959d5663fa51%2Fmeasure_humidity.json?alt=media&token=6104ed62-ddfc-4af8-abe2-f778b98726ba>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-988dc8a919de07bb879a33f12ef5dab18683d7ac%2Fmeasure_luminance.json?alt=media&token=3199059c-8dc1-4290-a2e5-ad7a38a59132>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-709cf07305cb3fb027913fe4e277edfcf0e2782e%2Fmeasure_pm25.json?alt=media&token=3a81e892-ad64-4b65-bdb3-14d4570c52b9>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-47c392b24665f2fc5da6b65adc2bf8662c226e9f%2Fmeasure_power.json?alt=media&token=9a192dfc-ddef-4649-b002-f2ee0f481a54>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-af1ddf2b6bc6911a392781540104d2aa05df41e5%2Fmeasure_pressure.json?alt=media&token=9ffb8b1a-b279-4a7e-8599-1cbd95027b0c>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-f41d50efe87d374a375c0f3472a6f78223934bb3%2Fmeasure_rain.json?alt=media&token=6cb4a199-aae9-4259-80f7-d8eb5183f382>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-d775a27172e1b7cb3642c7373a8320d91c78c2ec%2Fmeasure_temperature.json?alt=media&token=4b23539f-61df-49d3-a39f-a42f89e35557>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-bb71c5402a9815a74cf2ab0eddfd894b9fba6848%2Fmeasure_ultraviolet.json?alt=media&token=c7ff1d7b-e658-4e33-a51a-81908db0f845>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-fd12297823e09438403f8a57f2f7e3fac1694f98%2Fmeasure_voltage.json?alt=media&token=6aea9dbe-6b0b-4c8b-88cf-1827c07dceb6>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-91718872ffc3fdc689dc82e810b4165da5440532%2Fmeasure_wind_angle.json?alt=media&token=d5c5245c-b5ba-46ca-ab7b-ef080cce86a9>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-87d1f1a60f0797bc537a2830cdb813cf8c145c95%2Fmeasure_wind_strength.json?alt=media&token=09663792-730f-4afb-a25c-d5aac3dc1cc2>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-a8a666c3fb099d2b1993bf9c43a2cd304c4788f9%2Fmeter_power.json?alt=media&token=fa6ee42d-35de-4b5b-a4ab-05cad99aa189>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-9feefeccd064031bf8dc2213c393c849f78d057e%2Fmeter_water.json?alt=media&token=b85b4e94-2ad9-4180-9bd2-6e1500f86a67>" %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-994f91985999fde03481d8041ae7d2f27000e694%2Fonoff.json?alt=media&token=fb8cc8b9-e127-403a-9b65-6786c8e86e76>" %}

{% code title="/app.js" %}

```javascript
this.homey.flow.getConditionCard('on').registerRunListener((args, state) => {
  return args.device.getCapabilityValue('onoff');
});
this.homey.flow.getConditionCard('open').registerRunListener((args, state) => {
  return args.device.getCapabilityValue('onoff');
});
this.homey.flow.getActionCard('on').registerRunListener((args, state) => {
  return args.device.setCapabilityValue('onoff', true);
});
this.homey.flow.getActionCard('off').registerRunListener((args, state) => {
  return args.device.setCapabilityValue('onoff', false);
});
this.homey.flow.getActionCard('toggle').registerRunListener((args, state) => {
  const value = args.device.getCapabilityValue('onoff');
  return args.device.setCapabilityValue('onoff', !value);
});
this.homey.flow.getActionCard('open').registerRunListener((args, state) => {
  return args.device.setCapabilityValue('onoff', true);
});
this.homey.flow.getActionCard('close').registerRunListener((args, state) => {
  return args.device.setCapabilityValue('onoff', false);
});
```

{% endcode %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-4ab60b844495d8c944d303fc85ed865a6d9ed344%2Ftarget_temperature.json?alt=media&token=b9c28320-8810-444a-ac73-b43d01865f0d>" %}

{% code title="/app.js" %}

```javascript
this.homey.flow.getActionCard('target_temperature_set').registerRunListener((args, state) => {
  return args.device.setCapabilityValue('target_temperature', args.target_temperature);
});
```

{% endcode %}

{% file src="<https://998911913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MPk9cn4V7WnnKt7fbry%2Fuploads%2Fgit-blob-7ef77fa672fbfd7b04da29d094f44dab680019eb%2Fthermostat_mode.json?alt=media&token=c0937fbe-f4e2-4034-88f0-125016a0070f>" %}

{% code title="/app.js" %}

```javascript
this.homey.flow.getDeviceTriggerCard('thermostat_mode_changed').registerRunListener((args, state) => {
  return args.device.getCapabilityValue('thermostat_mode') === args.thermostat_mode;
});
this.homey.flow.getConditionCard('thermostat_mode_is').registerRunListener((args, state) => {
  return args.device.getCapabilityValue('thermostat_mode') === args.thermostat_mode;
});
this.homey.flow.getActionCard('thermostat_mode_set').registerRunListener((args, state) => {
  return args.device.setCapabilityValue('thermostat_mode', args.thermostat_mode);
});
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apps.developer.homey.app/upgrade-guides/device-capabilities.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
