FlowCardAction

The FlowCardAction class is a programmatic representation of a Flow Card with type action, 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(): Promise.<Array.<any>>

Get the current argument values of this card, as filled in by the user.

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

Events

update

.on('update')

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