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 to a separate icon in the Flow Editor's sidebar.

/app.json

{
    "id": "com.athom.hello",
    ...
    "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'.

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 = new Homey.FlowCardTriggerDevice('turned_on')
            .register()

    }

    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 = this.getDriver();
        this._driver.ready(() => {
            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.