FlowCardTriggerDevice

The FlowCardTriggerDevice class is a programmatic representation of a Flow Card with type trigger and an argument with type device and a filter with driver_id, as defined in an app's app.json.

Extends

Methods

getArgument

getArgument(name): FlowArgument

Parameters

Name Type Description
name
string

the flow card argument name

Returns

getArgumentValues

getArgumentValues(device): Promise.<Array.<any>>

Get the current argument values of this card, as filled in by the user, for a specific device.

Parameters

Name Type Description
device
Device

A Device instance

Returns

A Promise that resolves to an array of key-value objects with the argument's name as key. Every array entry represents one Flow card.

Promise.<Array.<any>>

registerArgumentAutocompleteListener

registerArgumentAutocompleteListener(name, listener): FlowCard

Register a listener for a autocomplete event of a specific flow card argument. This is fired when the argument is of type autocomplete and the user typed a query.

Parameters

Name Type Description
name
string

name of the desired flow card argument.

listener
FlowCard.ArgumentAutocompleteCallback

Should return a promise that resolves to the autocomplete results.

Returns

Example

const myActionCard = this.homey.flow.getActionCard('my_action');

myActionCard.registerArgumentAutocompleteListener('my_arg', async (query, args) => {
  const results = [
    {
      name: 'Value name',
      description: 'Optional description',
      icon: 'https://path.to/icon.svg',
      // For images that are not svg use:
      // image: 'https://path.to/icon.png',

      // You can freely add additional properties to access in registerRunListener
      id: '...',
    },
  ];
  // filter based on the query
  return results.filter((result) => {
    return result.name.toLowerCase().includes(query.toLowerCase());
  });
});

registerRunListener

registerRunListener(listener): FlowCard

Register a listener for a run event.

Parameters

Name Type Description
listener
FlowCard.RunCallback

Should return a promise that resolves to the FlowCards run result

Returns

trigger

(async) trigger(device, tokens, state): Promise.<any>

Trigger this card to start a Flow

Parameters

Name Type Description
device
Device

A Device instance

tokens
object

An object with tokens and their typed values, as defined in an app's app.json

state
object

An object with properties which are accessible throughout the Flow

Returns

Promise resolves when flow is triggered

Promise.<any>

Events

update

.on('update')

This event is fired when the card is updated by the user (e.g. a Flow has been saved).