# HomeyScript newby question(s)

**URL:** <https://community.homey.app/t/homeyscript-newby-question-s/125644>\
**Category:** Questions & Help\
**Tags:** homeyscript, advancedflow\
**Created:** [December 27, 2024, 9:28pm UTC](https://community.homey.app/t/homeyscript-newby-question-s/125644 "2024-12-27T21:28:28Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![JESO](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jeso/32/49150_2.png) [@JESO](https://community.homey.app/u/JESO)\
**Post date:** [December 27, 2024, 9:28pm UTC](https://community.homey.app/t/homeyscript-newby-question-s/125644/1 "2024-12-27T21:28:28Z")

</div>

Dear all,

I am trying to use a HomeyScript in an advanced flow, but I do not even get a first simple script running. The documentation is far from clear, so I looking for some help, hopefully some very simple things that I overlook.

When at [https://my.homey.app](https://my.homey.app) I select the \</\> button on the left, and here I have several example script that are marked as classic (i.e. using the deprecated API version). I have created a new script, which is not marked as such, so that is great. However, when I try to call a simple Homey.flow.runFlowCardCondition or Homey.flow.runFlowCardAction I get errors all the time.

For instance, when using

```auto
let result = await this.Homey.flow.runFlowCardCondition({
  uri: 'homey:manager:cron',
  id: 'day_equals',
  args: {
    day: 6, // for Saturday
  },
});
log(result);

```

gives, when running the script, a script error, and no log. What am I doing wrong?  
When I remove the await, I get a

```auto
Promise { <pending> }

```

in the log, which is also unwanted, and the result is undefined.

Hope someone can help.

---

<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:** [December 27, 2024, 9:48pm UTC](https://community.homey.app/t/homeyscript-newby-question-s/125644/2 "2024-12-27T21:48:33Z")

</div>

Can you start by editing your post, and format the code as code?  
Use the `</>` icon,  
Or  
Add ````` as first and last line.

Why?  
To avoid errors like using fancy qoutes,

> ![1000040215](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/2/42540d3a4f9e991c7d06e78b562a668d718a45c8.jpeg)

which make scripts error.  
Only straight quotes `' "` and back ticks ` ` `  
are allowed

---

<div class="post-metadata">

**Author:** ![JESO](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jeso/32/49150_2.png) [@JESO](https://community.homey.app/u/JESO)\
**Post date:** [December 27, 2024, 9:58pm UTC](https://community.homey.app/t/homeyscript-newby-question-s/125644/3 "2024-12-27T21:58:58Z")

</div>

Done. Thanks for _that_ tip. 🙂

---

<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:** [December 27, 2024, 11:10pm UTC](https://community.homey.app/t/homeyscript-newby-question-s/125644/4 "2024-12-27T23:10:46Z")

</div>

Next tip:

As ‘new’ script, you’d use it this way (and leave out _this_ from `this.Homey.fl ...`):

```auto
const { result: isSaturday } = await Homey.flow.runFlowCardCondition({
  // uri: 'homey:manager:cron', // classic script code only!
  id: 'homey:manager:cron:day_equals', // 'new' script code (uri and id are now combined)
  args: {
    day: 6,
  },
});

log('Is Saturday:', isSaturday);

```

Result:

> ![1000000252](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/5/b55a71656262803757d65d357873010de1e6623b.jpeg)

Oh, and about:

> [@JESO](#):
>
> and the result is undefined.

It’s because a line with something like

```auto
try {
  let result = riskyOperation(); 
  return result;
} catch (error) {
  // Handle the error and include it in the result
  return { success: false, message: error.message };
}

```

isn’t there.  
You’d add it yourself.

Classic to ‘new’ Homeyscript migration:

> **[Tutorial: Migrating deprecated scripts - HomeyScript](https://athombv.github.io/com.athom.homeyscript/tutorial-migrate)**

> ![1000040218](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/3/43b9d9be7860ba3c08390bbbe7c3a39509adaabb.jpeg)

---

<div class="post-metadata">

**Author:** ![JESO](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jeso/32/49150_2.png) [@JESO](https://community.homey.app/u/JESO)\
**Post date:** [December 27, 2024, 11:56pm UTC](https://community.homey.app/t/homeyscript-newby-question-s/125644/5 "2024-12-27T23:56:33Z")

</div>

Thanks for the - indeed simple - solution!  
I read the text you refer to, but did not understand that it required me to _add_ the uri to the id; I simply removed the uri argument, but _that_ did not work.

---

<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:** [December 28, 2024, 12:07am UTC](https://community.homey.app/t/homeyscript-newby-question-s/125644/6 "2024-12-28T00:07:44Z")

</div>

YW.  
I also didn’t get it at first, _how should it ever work without uri…_  
it finally worked by trying different combinations of uri and id as id.

You’re absolutely right about documentation not being clear at certain points

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [December 28, 2024, 5:48am UTC](https://community.homey.app/t/homeyscript-newby-question-s/125644/7 "2024-12-28T05:48:09Z")

</div>

The documentation isn’t just unclear, it’s just plain wrong. For this method, it shows that both `id` and `uri` are required parameters:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/8/2841d2b99c9257c5fc5785bd27c4cb4d9f518f27.png)

(I won’t be able to say that Athom doesn’t care about maintaining documentation, at the risk of this post being removed because it’s “too negative”, so I will refrain from saying so)

---

<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:** [December 28, 2024, 4:42pm UTC](https://community.homey.app/t/homeyscript-newby-question-s/125644/8 "2024-12-28T16:42:20Z")

</div>

> [@robertklep](#):
>
> Athom doesn’t care about maintaining documentation

Just rephrase it: “apparently somehow it slipped past Athom’s test team, which has to approve the documentation” 🫣😬

But don’t tell me posts (can) get removed when you show and explain what’s wrong?

And imho it’s not helping there’s no  
timestamps / versioning / author initials, and last but not least no ordinairy “comments” section, to have the improvement ideas right where the issue is.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [December 28, 2024, 6:39pm UTC](https://community.homey.app/t/homeyscript-newby-question-s/125644/9 "2024-12-28T18:39:35Z")

</div>

> [@Peter\_Kawa](#):
>
> But don’t tell me posts (can) get removed when you show and explain what’s wrong?

I’ve had posts removed when I pointed out that it felt like Athom seemed perhaps somewhat less motivated to improve certain parts of Homey that are known, and have been known for a long time, to be um “problematic” 🤷🏼‍♂️

> [@](#):
>
> And imho it’s not helping there’s no  
> timestamps / versioning / author initials, and last but not least no ordinairy “comments” section, to have the improvement ideas right where the issue is.

The various Github repositories that are used to “track” issues with the SDK or Web API are filled with comments that point out incorrect and/or insufficient documentation.
