Methods
getArgument
getArgument(name): FlowArgumentParameters
Name | Type | Description |
---|---|---|
name
|
string | the flow card argument name |
Returns
registerArgumentAutocompleteListener
registerArgumentAutocompleteListener(name, listener): FlowCardRegister 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): FlowCardRegister 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.ArgumentAutocompleteResultsParameters
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
ArgumentAutocompleteResultsType
- object
Properties
Name | Type | Description |
---|---|---|
name
|
string | |
description
|
string <optional> | |
icon
|
string <optional> | |
image
|
string <optional> |
RunCallback
RunCallback(args, state): Promise.<any>|anyParameters
Name | Type | Description |
---|---|---|
args
|
any | The arguments of the Flow Card, with keys as defined in the |
state
|
any | The state of the Flow |
Returns
Events
update
.on('update')This event is fired when the card is updated by the user (e.g. a Flow has been saved).