Run "Then"-cards from Homeyscript

I have the app CountDown installed, and I would like to set a timer from Homeyscript. I used the getFlowCardActions(); to find the action flow card to set a timer, which looks like this:

Start countdown timer
{
  "uri": "homey:app:nl.bevlogenheid.countdown",
  "id": "set_countdown_timer",
  "args": [
    {
      "name": "variable",
      "type": "autocomplete",
      "placeholder": "name"
    },
    {
      "name": "value",
      "type": "text",
      "placeholder": "seconds"
    }
  ]
}

However, I don’t really understand how to execute this flow card to start a named timer (which is already defined in the app). I tried a couple of variants, but I only managed to crash the countdown app.

Here’s an example of what I tried (which times out after 30 seconds):

await Homey.flow.runFlowCardAction({
  uri: 'homey:app:nl.bevlogenheid.countdown',
  id: 'set_countdown_timer',
  args: [
    {
      name: 'test_timer',
    },
    {
      name: '30',
    }
  ],
});

The goal is to set the timer called test_timer to 30 seconds, but the script fails:

:x: Script Error
:warning: Error: Timed out after 30000ms.
at Timeout._onTimeout (/node_modules/athom-api/dist/index.js:1:1260520)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492:7)

What am I doing wrong?

I’m not very familiar with the Countdown app or calling flows from Homeyscript, but from the example scripts I would expect that args should look like this:

args: {
  variable: 'test_timer',
  value: '30'
}

And since variable is an autocomplete, I would also expect that the timer should already exist (but like I said, I’m not familiar with the Countdown app).

Thanks, @robertklep. Makes sense, but it didn’t work. This is the call I tried:

await Homey.flow.runFlowCardAction({
  uri: 'homey:app:nl.bevlogenheid.countdown',
  id: 'set_countdown_timer',
  args:
    {
      variable: 'test_timer',
      value: '30'
    }
});

I get the same error after 30 seconds as before, unfortunately. The timer must (and does) exist before doing the call.

There’s a bug in the app where it will not report back errors with arguments (or rather, it will simply not return from the flow action handler unless all arguments are present and correct), which is causing the timeouts.

This should work:

args: {
  variable: { name: 'test_timer' },
  value: '30'
}

I just came here to say I figured it out, and the solution is exactly what you wrote. I figured it out by creating a normal flow to update the timer, and then look at the output from Homey.flow.getFlows(); in the web api playground. There I noticed the additional indirection for the variable.

Thanks for your assistance!

1 Like