FlowCard

The FlowCard class is a programmatic representation of a Flow card, as defined in the app's /app.json.

Methods

getArgument

getArgument(name): FlowArgument

Parameters

Name Type Description
name
string

the flow card argument name

Returns

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

Type Definitions

ArgumentAutocompleteCallback

ArgumentAutocompleteCallback(query, args): Promise.<FlowCard.ArgumentAutocompleteResults>|FlowCard.ArgumentAutocompleteResults

Parameters

Name Type Description
query
string

The typed query by the user

args
any

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

Returns

ArgumentAutocompleteResults

ArgumentAutocompleteResults

Type

  • object

Properties

Name Type Description
name
string
description
string <optional>
icon
string <optional>
image
string <optional>

RunCallback

RunCallback(args, state): Promise.<any>|any

Parameters

Name Type Description
args
any

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

state
any

The state of the Flow

Returns

Promise.<any> | any

Events

update

.on('update')

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