-
Notifications
You must be signed in to change notification settings - Fork 0
/
.sonoff_delayed_start.yaml
49 lines (46 loc) · 1.06 KB
/
.sonoff_delayed_start.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
globals:
- id: relay_state
type: boolean
restore_value: true
initial_value: "true"
esphome:
esp8266_restore_from_flash: true
on_boot:
priority: 600
then:
- if:
condition:
- lambda: 'return id(relay_state);'
then:
- if:
condition:
- lambda: 'return system_get_rst_info()->reason == 0;'
then:
- delay: ${delay_time}
- switch.turn_on: relay_phy
binary_sensor:
- platform: gpio
pin:
number: ${button_pin}
mode: INPUT_PULLUP
inverted: true
id: relay_button
internal: true
on_press:
- switch.toggle: relay_phy
switch:
- platform: gpio
id: relay_phy
name: "${device_name} relay"
pin: ${relay_pin}
restore_mode: ALWAYS_OFF
on_turn_on:
- lambda: id(relay_state) = true;
on_turn_off:
- lambda: |-
static bool initial = true;
if (initial) {
initial = false;
} else {
id(relay_state) = false;
}