# How to use homey.setTimeout in a custom class

**URL:** <https://community.homey.app/t/how-to-use-homey-settimeout-in-a-custom-class/128299>\
**Category:** Developers\
**Created:** [January 19, 2025, 4:42pm UTC](https://community.homey.app/t/how-to-use-homey-settimeout-in-a-custom-class/128299 "2025-01-19T16:42:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![s\_dimaio](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/s_dimaio/32/78995_2.png) [@s\_dimaio](https://community.homey.app/u/s_dimaio)\
**Post date:** [January 19, 2025, 4:42pm UTC](https://community.homey.app/t/how-to-use-homey-settimeout-in-a-custom-class/128299/1 "2025-01-19T16:42:02Z")

</div>

Hi, I created a simple class to manage a timer in Homey that I call from app.js.

I would like to use the Homey setTimer method (this.homey.setTimer) inside the class instead of the standard method (I don’t know the difference but I imagine that the first one is optimized for Homey).  
However, I can use it without problems inside a class that extends Homey.App, Homey.Driver or Homey.Device but I don’t know how to call it inside a custom class that doesn’t extend one of these three.

Thanks in advance,  
Simone

---

<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:** [January 20, 2025, 6:44am UTC](https://community.homey.app/t/how-to-use-homey-settimeout-in-a-custom-class/128299/2 "2025-01-20T06:44:10Z")

</div>

> [@s\_dimaio](#):
>
> but I don’t know how to call it inside a custom class that doesn’t extend one of these three.

Pass it as constructor argument:

```auto
this.myInstance = new MyClass(this.homey);

```

Or make your app instance “globally” available:

```auto
// app.js
async onInit() {
  Homey.app = this;
  ...
}

// my-class.js
const Homey = require('homey');
...
Homey.app.homey.setTimeout(...);

```

---

<div class="post-metadata">

**Author:** ![s\_dimaio](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/s_dimaio/32/78995_2.png) [@s\_dimaio](https://community.homey.app/u/s_dimaio)\
**Post date:** [January 20, 2025, 8:04pm UTC](https://community.homey.app/t/how-to-use-homey-settimeout-in-a-custom-class/128299/3 "2025-01-20T20:04:54Z")

</div>

Thanks!
