FlowCardAction

The FlowCardAction class is a programmatic representation of a Flow Card with type action, as defined in an app's app.json.

Table of Contents

Extends

Methods

getArgumentValues() → {Promise.<Array.<any>>}

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

Overrides:
Returns:
Type:
Promise.<Array.<any>>

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.

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.

Overrides:
Parameters:
Name Type Description
name string

name of the desired flow card argument.

listener function

Should return a promise that resolves to the autocomplete results.

Name Type Description
query string

The typed query by the user

args object

The current state of the arguments, as selected by the user in the front-end

Returns:
Type:
FlowCard
Example
let myAction = this.homey.flow.getActionCard('my_action');

myAction.registerArgumentAutocompleteListener('my_arg', async (query, args) => {
  let results = [
    { id: 'abcd', name: 'My Value' },
  ];

  // filter for query
  results = results.filter((result) => {
    return result.label.toLowerCase().includes(query.toLowerCase());
  });

  return results;
});

registerRunListener(listener) → {FlowCard}

Register a listener for a run event.

Overrides:
Parameters:
Name Type Description
listener function

Should return a promise that resolves to the FlowCards run result

Name Type Description
args object

The arguments of the Flow Card, with keys as defined in the /app.json and values as specified by the user

state object

The state of the Flow

Returns:
Type:
FlowCard

Events

.on('update')

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

Overrides: