# Can't get "setTimeout()" to work (SOLVED!)

**URL:** https://community.homey.app/t/cant-get-settimeout-to-work-solved/26871
**Category:** Developers
**Tags:** app
**Created:** [March 8, 2020, 10:37am UTC](https://community.homey.app/t/cant-get-settimeout-to-work-solved/26871 "2020-03-08T10:37:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Hans-Kristian\_Berg](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/hans-kristian_berg/32/18371_2.png) [@Hans-Kristian\_Berg](https://community.homey.app/u/Hans-Kristian_Berg)
#### Post date: [March 8, 2020, 10:37am UTC](https://community.homey.app/t/cant-get-settimeout-to-work-solved/26871/1 "2020-03-08T10:37:38Z")

</div>

## Using script example “Say.js” as template…

// Say Something  
function talk() {  
say(“I am Homey, and this is written in HomeyScript!”);  
} //END Talk

setTimeout(talk, 5000);

* * *

Console output:  
" Script Error:  
setTimeout is not defined"

I’m new to JS, just trying to make the function to wait 5sec. before executing…

---

<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: [March 8, 2020, 10:51am UTC](https://community.homey.app/t/cant-get-settimeout-to-work-solved/26871/2 "2020-03-08T10:51:03Z")

</div>

Athom apparently doesn’t want you to use timers from Homeyscript, but they weren’t careful enough and left a few workarounds because they’re passing in `lodash`:

```auto
function talk() {
  say("I am Homey, and this is written in HomeyScript!");
}

// workaround one:
_.debounce(talk, 5000)();

// workaround two:
_.delay(talk, 5000);

```

However, if you want to introduce delays like this, it’s probably better to use the standard “delay” option for flow cards.

---

<div class="post-metadata">

### Author: ![Hans-Kristian\_Berg](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/hans-kristian_berg/32/18371_2.png) [@Hans-Kristian\_Berg](https://community.homey.app/u/Hans-Kristian_Berg)
#### Post date: [March 8, 2020, 11:05am UTC](https://community.homey.app/t/cant-get-settimeout-to-work-solved/26871/3 "2020-03-08T11:05:33Z")

</div>

Tank you, it worked… ( \_,delay() doesn’t seem precise, 10sec delay was really more like 8, but works for me)  
I am planning to use this inside my own app, so having to use flow cards is not somthing i want to do…

---

<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: [March 8, 2020, 11:30am UTC](https://community.homey.app/t/cant-get-settimeout-to-work-solved/26871/4 "2020-03-08T11:30:34Z")

</div>

Apps aren’t built using Homeyscript though, so inside a proper app you’re able to use `setTimeout` and other timers just fine.

---

<div class="post-metadata">

### Author: ![Hans-Kristian\_Berg](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/hans-kristian_berg/32/18371_2.png) [@Hans-Kristian\_Berg](https://community.homey.app/u/Hans-Kristian_Berg)
#### Post date: [March 8, 2020, 12:07pm UTC](https://community.homey.app/t/cant-get-settimeout-to-work-solved/26871/5 "2020-03-08T12:07:07Z")

</div>

Ok, tanks, was using homeyScript to test solutions to various problems, was not aware of different behaviour from apps…
