Hi,
I’m experimenting few things in ESPHome and running into few glitches. Here is the summary:
- Trying to use “interval” feature in ESPHome, in the test script below it should trigger every 2 minutes
- Seems like the first execution time interval is random so trying to identify first run using a global variable (counter) & avoid it.
- But seems like the “If” condition always evaluate to “false” which seems like the source of my problem.
esphome:
name: ${name_of_board}
platform: ESP8266
board: d1_mini
globals:
- id: counter
type: int
restore_value: no
initial_value: "0"
interval:
- interval: 2min
then:
- if:
condition:
lambda: 'return id(counter) == 0;'
then:
- logger.log: "Interval component is working in IF part"
- globals.set:
id: counter
value: '1'
else:
- globals.set:
id: counter
value: '1'
- logger.log: "Interval component is working in ELSE part"
Here are the logs from the device which suggests that “IF” statement not geting “true” may be the solution I need.
[02:46:38][D][main:225]: Test Board booted fine
[02:47:58][D][main:096]: Interval component is working in else part
[02:49:58][D][main:096]: Interval component is working in else part
[02:51:58][D][main:096]: Interval component is working in else part
Let me know if you see any errors in my code, please let me know.