# Homeyscript start a "Then" flow

**URL:** <https://community.homey.app/t/homeyscript-start-a-then-flow/74679>\
**Category:** Developers\
**Created:** [January 6, 2023, 3:05pm UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679 "2023-01-06T15:05:59Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 6, 2023, 3:05pm UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/1 "2023-01-06T15:05:59Z")

</div>

For Homeyscript I want to activate two flows at the THEN part. The app MQTT Hub has the possibility at the THEN part for “Trigger Broadcast”, and Homey System has the possibility at the THEN part for “Restart an App” MQTT Hub. How can I make this possible in a script?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 6, 2023, 5:20pm UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/2 "2023-01-06T17:20:16Z")

</div>

Not sure if you mean something like this:  
These scripts show all And & Then cards for your apps in script version.  
There’s also an example.

 ![Screenshot_20230106-181822_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/2/f2e1d9181ad2b3e7c117e98d87b63810e3333ea5.jpeg)

Timeline notification example

 ![Screenshot_20230106-182342_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/7/77bce4aa8da676354f161178cfd5d08bdda8086d.jpeg)

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 6, 2023, 6:55pm UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/3 "2023-01-06T18:55:22Z")

</div>

Yes, exactly what i needed. Was aware these exaples were there, but had no idea how to work with it. First attempt was bullseye;

```auto
await Homey.flow.runFlowCardAction({
  uri: 'homey:app:nl.hdg.mqtt',
  id: 'broadcast',
  
});

```

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 6, 2023, 7:19pm UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/4 "2023-01-06T19:19:10Z")

</div>

But the second one doesn’t work, any idea?

```auto
await Homey.flow.runFlowCardAction({
  uri: 'homey:manager:system',
  id: 'restartApp',
  'args': [
    {
      'name': 'nl.hdg.mqtt',
      'type': 'autocomplete'
    }
  ]
});

```

---

<div class="post-metadata">

**Author:** ![Dijker](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@Dijker](https://community.homey.app/u/Dijker)\
**Post date:** [January 6, 2023, 7:50pm UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/5 "2023-01-06T19:50:23Z")

</div>

> [@Marcel\_Ubels](#):
>
> second one doesn’t work, any idea?

Check Develop tools in your browser on test of a simple Flow:

```auto
{
    "id": "restartApp",
    "uri": "homey:manager:system",
    "group": "then",
    "delay": null,
    "duration": null,
    "args": {
        "app": {
            "id": "nl.klikaanklikuit",
            "name": "KlikAanKlikUit"
        }
    }
}

```

Leave away the “group”: “then”, “delay”: null, “duration”: null,

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 6, 2023, 8:09pm UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/6 "2023-01-06T20:09:20Z")

</div>

```auto
await Homey.flow.runFlowCardAction({
    'id': 'restartApp',
    'uri': 'homey:manager:system',
    'args': {
        'app': {
            'id': 'nl.hdg.mqtt',
            'name': 'MQTT Hub'
        }
    }
});

```

This way You mean? Doesn’t work either

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [January 6, 2023, 8:19pm UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/7 "2023-01-06T20:19:54Z")

</div>

This should work:

```auto
await Homey.flow.runFlowCardAction({
  uri: 'homey:manager:system',
  id: 'restartApp',
  args: {
    app: {
      id: 'nl.hdg.mqtt',
      name: 'MQTT-Hub'
    }
  }
})
.catch(err => {
  log('error:', err);
})
.then(res => {
  log('result:', res);
});

```

In theorie you only wrote the name wrong (the `.catch()` and `.then()` are optional), but I like the additional error catching and being able to do anything if the action card succeeded.

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 6, 2023, 9:03pm UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/8 "2023-01-06T21:03:34Z")

</div>

works great,thx. Out of curiosity; How do I know what is the right name? I had a little script which gave the name, but that name was wrong

```auto
let Appsopvraag = await Homey.apps.getApps();
_.forEach(Appsopvraag, app =>{
    console.log(app.name, '',app.id);
})
return true

```

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [January 6, 2023, 10:36pm UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/9 "2023-01-06T22:36:13Z")

</div>

I copied the name of the app from the app store (the URL).  
Looks like it is based on that 🤔 I guess the regular name (i18n) is able to be changed thus not reliable.  
Not sure if you can get it with a script, doesn’t look like it is in the app’s object.

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 7, 2023, 8:41am UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/10 "2023-01-07T08:41:31Z")

</div>

When i open the link i find this:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/2/92fa25ad16e4a31968fe9f785cb497be13efbc0b.jpeg)

Where did you find MQTT-Hub?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 7, 2023, 10:50am UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/11 "2023-01-07T10:50:39Z")

</div>

This is the full link  
`https://homey.app/en-us/app/nl.hdg.mqtt/MQTT-Hub/`

`https://homey.app/en-us/app/id/name/`

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [January 7, 2023, 11:52am UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/12 "2023-01-07T11:52:01Z")

</div>

That’s the _redirect link_ to the local language app page, curious why your webbrowser still shows that, even all the links on my laptop are all the full-on link, not the redirect link as it already knows the local language.  
Perhaps it is being blocked by a (privacy) setting? 🤔

---

<div class="post-metadata">

**Author:** ![Marcel\_Ubels](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marcel_ubels/32/18860_2.png) [@Marcel\_Ubels](https://community.homey.app/u/Marcel_Ubels)\
**Post date:** [January 7, 2023, 11:59am UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/13 "2023-01-07T11:59:03Z")

</div>

Because i always on my iphone that’s the url i get. I tried with my laptop and in that case i get the full link. This is helpfull for the next time i want to script something.

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [January 7, 2023, 12:15pm UTC](https://community.homey.app/t/homeyscript-start-a-then-flow/74679/14 "2023-01-07T12:15:38Z")

</div>

In Firefor I open the app store with [apps.athom.com](http://apps.athom.com) and get redirected to [Apps für Homey Pro](https://homey.app/de-de/apps/homey-pro/)  
After selecting the app I’m on [Home Assistant Community App für Homey | Homey](https://homey.app/de-de/app/io.home-assistant.community/Home-Assistant/)
