esphome / esphome/issues

delay() in lambda should issue an error

Open
#3,870 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
313
Forks
40
PR merge metrics
No merged PRs in 30d

Description

### The problem

delay() in lambda does not work. It does nothing, just silently skips further.

Novice users do not know that and are loosing their minds expecting it to work.

Compiler should report error like "delay() does not work in this environment." And stop compiling.

### Which version of ESPHome has the issue?

2022.11.4

### What type of installation are you using?

Home Assistant Add-on

### Which version of Home Assistant has the issue?

2022.11.5

### What platform are you using?

ESP8266

### Board

Sonoff Basic

### Component causing the issue

_No response_

### Example YAML snippet

```yaml
I needed LED to blink to show progress while executing code in lambda. I tried this:

id (red_led).turn_on().perform();
delay(300);
id (red_led).turn_off().perform();

LED did not blink as expected. After lots of time lost trying to find out what I did wrong I finally found some explanation to other guy having the same issue and that that said delay() does not work. It just skips. That is why you cannot make LED blink this way. It turns it on and then instantly turns it off without any delay.
```

### Anything in the logs that might be useful for us?

_No response_

### Additional information

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.