How to get and execute TriggerCard with Argument?

Hi. Have an Homey App in development and want to add a trigger card with argument, but struggle to understand how to get and execute only the triggers that shall trigger based on the argument

from my code, so I can display the registered cards with argument, but how to execute a trigger action on the actual card ?

  const card_trigger = this.homey.flow.getTriggerCard("cell-changed");

  var x  = await card_trigger.getArgumentValues();
  x.forEach(element => {
    console.log("element=",element);
  });

//bwa

Do you want to react on argument changes (when user changes the flow card argument)?
Then you need to subscribe the event and read the value in the element handler:

If you only want to “filter” the flow trigger based on the argument, you can do it using the run listener.

From the example:

const rainingCondition = this.homey.flow.getConditionCard('is_raining');
    rainingCondition.registerRunListener(async (args, state) => {
      const raining = await RainApi.isItRaining(); // true or false
      return raining;
    });

Inside the run listener callback you can check the argument (parameter args contains all arguments from JSON definition). Then check this argument if it fits your trigger data.
Return false to prevent the trigger from execution. Return true if the argument is ok to run the trigger.

It looks like I have issues with understanding how this works.

I have this WhenCard with one argument ‘id’, so this ‘id’ is actually a remote resource on internet I want to react on when it changes. So I guess I have to poll that resource. But only for IF there actually exists a WhenCard of that kind, and argument ‘id’ is telling which resource to check for changes.

So in the a flow the user adds a WhenCard with id of 20, and another WhenCard with argument of 30.

So I need to periodically check the resource and if the id of 20 has changed, I need to execute trigger only for the WhenCard that has the argumnet of 20, and not the WhenCard with argumnet of 30.

That means I need to have code for find if a WhenCard actually exists and for each I need to check the condition card by card to execute only that.

Was this easier to understand ?

/bwa