Where are default flow cards defined and can I remove them?

I am building an app for Homey and defined som flow cards (triggers, conditions and actions) but when I run the app on my Homey and start to create a flow there are some extra cards like “Turned on”, “Turned off” and “The volume is changed”.

I had defined triggers for these actions myself, so they are now duplicate in the card list.
The self created cards do work but the extra cards don’t.
So my question is how can I use this default cards (which value for “getDeviceTriggerCard()”) or how do I remove (or hide) these default cards?

Thanks

Maybe you’re familiar with this already, but nonetheless, I think this might help

You’d start reading at “Device cards”

Thanks,

Yes, I have read those, I used that to create my flow cards and it states there are some flow cards created by default.
image
But I can’t find how to use them. Like which id should a use in the getDeviceTriggerCard() function. I tried getDeviceTriggerCard('onoff') and getDeviceTriggerCard('turned_on') but that didn’t work

Is there a list with default (reserved) ID’s and which classes have which cards by default?

You should take a look at the SDK reference.

There you can find all standard capabilities.
In details (3 points at the right) you can see the whole capability details incl. units, descriptions, flows…

If you add such a standard capability to your device, the standard flows will be added, too.

What do you mean?
If a capability is changed (from your app), the triger is executed. No need to do something.
The flow action will change the capability (like it’s done when you klick a switch in the device details). Then a capability listener can be used to react on the changed value (e.g. to send something to the device/API).

There is an example. Use the capability id (like onoff).

1 Like

Thanks,

I already read those documentation. The flow cards I made myself are working fine. It’s the “built-in” flowcards I can’t get to work.

For example I have created these trigger as follow:

  "triggers": [
    {
      "id": "power_off",
      "title": {
        "en": "Turned off",
        "nl": "Uitgezet"
      }
    },
    {
      "id": "power_on",
      "title": {
        "en": "Turned on",
        "nl": "Aangezet"
      }
    },
    ...
  ]

In the flow editor, when choosing a trigger, I now see two cards for “Turned on” and two cards for “Turned off”.

I implemented the card(s) this way:

...
async onInit() {
...
  this.powerOffTrigger = this.homey.flow.getDeviceTriggerCard('power_off')
  this.powerOnTrigger = this.homey.flow.getDeviceTriggerCard('power_on')

  this.amp.addListener('powerState', (zone: number, isOn: boolean) => this.onAmpPowerStateChanged(zone, isOn))
...
}

async onAmpPowerStateChanged(zone: number, value: boolean): Promise<void> {
  this.setCapabilityValue('onoff', value).catch(this.error)

  if (value) {
    await this.powerOnTrigger!.trigger(this, {}, { zone, value }).catch(this.error)
  } else {
    await this.powerOffTrigger!.trigger(this, {}, { zone, value }).catch(this.error)
  }
}

When I use my own created card “Turned on” in a flow, the flow is executed when I turn my amplifier on or off.
When I use the “Turned on” card that is automatically created by Homey, the flow is not executed when I turn my amplifier on or off.

So how can I accomplish that when I use the “build-in” “Turned on” card, the function onAmpPowerStateChanged gets triggered when I turn my amplifier on or off?

Or is there a possibility to remove or hide these “build-in” cards? Is there maybe a class that doesn’t have “built-in” cards?

Thanks

I’m no expert on this, but what if you turn it around: (temporary) remove your defined flow triggers?
The automagically added, or “built in”, triggers should function in that situation?

:thinking: you mean my cards override the “build-in” cards. I will try that.

Thanks.

Um, yes. That crossed my mind as possible cause.

If possible, you should use the built in cards for built in capabilities.
Is there a need for your cards? I would only use a second custom trigger if I want to pass additional tokens.

In your code, you only get the event from your amplifier and then you execute your trigger.
But you don’t set the capability.
If you set the capability there. the standard trigger should be executed. They are started on capability change.

If you really want to relove the standard trigger (I would not do that), you have to add two triggers to your app:
onoff_true
onoff_false
where you set “deprecated”:true to hide them in flow selection.

I temporary removed al the code for “on” and “off” trigger cards but without result.
The “built-in” “Turned on” and “Turned off” cards do not trigger the flow.

For “power on” and “power off” I would if I could get it working.

Well, for the “Set volume” I would like to do some magic before sending it to my amplifier.

In the onAmpPowerStateChanged function I call setCapabilityValue or is that not what you mean?

I also added the following line to the onInit function:

this.addCapability('onoff')

But de “build-in” trigger cards are still not triggering the flows when I cycle power on my amplifier.

Thanks

I did notice that when I switch my amplifier on or off in the Homey app the flow with the “build-in” cards did trigger.

So I might be missing some listener, I guess?

Thanks

Yes, I missed this line :slight_smile:

Just to be sure…
The input value isOn is also changing its value?
And both custom triggers “power_off” and “power_on” are executed alternating?
If you set the currently set value again with setCapabilityValue(), the trigger is not started. So perhaps your event handler gets the same value every time?

Not sure if this is what you mean, but the state of the tile and the power button in the app change state accordingly.

Everything seems to work as planned flow triggers, flow actions, control in the app, updating state according the the devices local changes, etc. It’s just the “build-in” cards I cannot get to work.

Not sure what you mean by this. But even when I comment out all the custom on/of code, the “build-in” trigger card is not firing.

Thanks.