FlowCard

homey.flow_card

Base class for flow cards.

This class must not be initialized by the developer, but retrieved by calling ManagerFlow.get_action_card(), ManagerFlow.get_condition_card(), ManagerFlow.get_trigger_card(), or ManagerFlow.get_device_trigger_card().

Ancestors

  • SimpleClass
  • homey.util.event_emitter.EventEmitter
  • typing.Generic
  • abc.ABC

Subclasses

Methods

get_argument

def get_argument(self, name: str) ‑> FlowArgument

Get the argument with the given name from this flow card.

Raises

NotFound:

get_argument_values

async def get_argument_values(self) ‑> tuple[mappingproxy[str, typing.Any], ...]

Get the values of any arguments in instances of the flow card, as currently selected by the user.

register_argument_autocomplete_listener

def register_argument_autocomplete_listener(self,
name: str,
listenerArgumentAutocompleteListener)
‑> Self

Register an autocomplete listener for the argument with the given name.

Args

NameTypeDescription
listener ArgumentAutocompleteListener An async listener for when an autocomplete value is requested for the argument. It receives the query typed by the user, as well as any arguments in the flow card, as currently selected by the user.

Returns

This flow card, for chained calls.

Raises

AlreadyExists
Raised if a listener was already registered for the argument.
NotFound
Raised if no argument with the given name is found.

register_run_listener

def register_run_listener(self,
listenerRunListener)
‑> Self

Register a listener for when this flow card is activated. Raising an exception in the listener will make the flow fail with the exception's message.

Args

NameTypeDescription
listener RunListener An async listener ran when the flow card is activated. It receives the arguments of the flow card, and arguments passed when triggering the flow card.

Returns

This flow card, for chained calls.

Raises

AlreadyExists
Raised if a listener was already registered for this flow card.

on_update

def on_update(self, f: Callable[[], None]) ‑> Self

The update event is fired when the flow card is updated by the user, e.g. when a flow has been saved.

Args

NameTypeDescription
f Callable[[], None] A callback that receives no arguments.

Inherited members

ArgumentAutocompleteResult

class ArgumentAutocompleteResult

Ancestors

  • builtins.dict

Instance variables

name

var name : str

The autocomplete value that will be shown to the user and used in the flow.

description

var description : str

A short description of the result that will be shown below the name.

icon

var icon : str

A path to an .svg file to show as icon for the result.

image

var image : str

A path to an image that is not an .svg file to show as icon for the result.

data

var data : Any

Any additional data you wild like to pass to the flow run listener for this autocomplete value.

ArgumentAutocompleteListener

class ArgumentAutocompleteListener

A listener for when an autocomplete value is requested in a flow card. It receives the query typed by the user, as well as the values of any arguments in the flow card, as currently selected by the user.

Ancestors

  • typing.Protocol
  • typing.Generic

Methods

__call__

async def __call__(self, query: str, **kwargs) ‑> list[ArgumentAutocompleteResult]

Args

NameTypeDescription
query str The query typed by the user.
kwargs The values of any arguments in the flow card, as currently selected by the user.

RunListener

class RunListener

A listener ran when a flow card is activated. It receives the arguments of the flow card, and arguments passed when triggering the flow card.

If an exception is raised, the flow will fail and the error message will be shown to the user.

Ancestors

  • typing.Protocol
  • typing.Generic

Methods

__call__

async def __call__(self, card_arguments: Mapping[str, Any], **trigger_kwargs: Any) ‑> ReturnType

Args

NameTypeDescription
card_arguments Mapping[str, Any] Arguments in the flow card, as currently selected by the user.
trigger_kwargs Any Arguments passed when triggering the flow card.