Devices

While devices look like seperate Flow-cards in the Editor, they are actually dynamically generated from your app's cards.

To make them show up, add at least one "type": "device" argument in a flow trigger, condition or action. Then add filter: "driver_id=my_driver" (replace my_driver with your driver's id) to transform the card only show the flow card for devices belonging to that specific driver.

/app.json

{
  "id": "com.athom.example",
  ...
  "flow": {
    "triggers": [
      {
        "id": "turned_on",
        "title": {
          "en": "Turned on"
        },
        "args": [
          {
            "name": "my_device",
            "type": "device",
            "filter": "driver_id=my_driver"
          }
        ]
      }
    ]
  }
}

If your driver has a class that Homey already has support for, like light or socket, your custom card will be added to those cards. For example, if your driver supports a light bulb that has a special disco mode, the user will see 'Turn on', 'Turn off', 'Dim', 'Set color', 'Disco mode'.

Flow Card Device filters

You can add filters to choose for which devices the specific flow card will be available. The filter option supports the following properties:

  • driver_id filters based on the id of the driver that the device belongs to
  • class filtering based on the device class
  • capabilities allows based on available capabilities (note that calls to addCapability and removeCapability don't update this filter)
  • flags filters based on additional device properties, will be explained below

Individual filters can be added in the form "class=socket".

Filters can match one of multiple values by seperating values with a pipe (|), for example: "class=socket|light" will match devices with a device class of either socket or light.

capabilities and flags also support matching on multiple values by seperating the values with a comma (,), for example capabilities=onoff,dim will match devices that have both onoff and dim capabilities.

Multiple properties can be filtered on by seperating the filters with an ampersand (&), for example "driver_id=basic&class=light" will match devices belonging to the basic driver with the light device class. Alternatively you can make the filter an object which will behave the same way, for example:

"filter": {
  "driver_id": "basic",
  "class": "socket|light",
  "capabilities": "onoff,dim"
}

Will match devices belonging to the basic driver with a socket or light device class and onoff and dim capabilities.

There are additional filter flags that can be applied for Z-Wave devices:

  • Target only multi channel node devices:
"filter": {
  "driver_id": "my_driver",
  "flags": "zwaveMultiChannel"
}
  • Target only root node devices:
"filter": {
  "driver_id": "my_driver",
  "flags": "zwaveRoot"
}

Triggering

Instead of creating a regular FlowCardTrigger instance, create a FlowCardTriggerDevice instance.

/drivers/my_driver/driver.js

class MyDriver extends Homey.Driver {
  onInit() {
    this._flowTriggerTurnedOn = this.homey.flow.getDeviceTriggerCard('turned_on');
  }

  triggerMyFlow(device, tokens, state) {
    this._flowTriggerTurnedOn.trigger(device, tokens, state)
      .then(this.log)
      .catch(this.error);
  }
}

/drivers/my_driver/device.js

class MyDevice extends Homey.Device {
  onInit() {
    let device = this; // We're in a Device instance
    let tokens = {};
    let state = {};

    this.driver.ready().then(() => {
      this._driver.triggerMyFlow(device, tokens, state);
    });
  }
}

Conditions and Actions

These are not different from regular Flow cards. The device's instance will be in args.my_device.