-
Notifications
You must be signed in to change notification settings - Fork 0
/
on-time-example.yaml
75 lines (66 loc) · 1.89 KB
/
on-time-example.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
esphome:
name: on-time-example
esp32:
board: esp32dev
framework:
type: arduino
logger:
level: DEBUG
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
web_server:
js_include: "www.js"
js_url: ""
time:
- platform: sntp
id: my_time
on_time_sync:
then:
- datetime.set:
id: turn_on_time_datetime
value: !lambda |-
return ESPTime::from_epoch_local(id(my_time).now().timestamp + 30).strftime("%H:%M:%S");
- datetime.set:
id: turn_off_time_datetime
value: !lambda |-
return ESPTime::from_epoch_local(id(my_time).now().timestamp + 40).strftime("%H:%M:%S");
button:
- platform: template
name: Set the time inputs to local time + 10 seconds
on_press:
then:
- datetime.set:
id: turn_on_time_datetime
value: !lambda |-
return ESPTime::from_epoch_local(id(my_time).now().timestamp + 10).strftime("%H:%M:%S");
- datetime.set:
id: turn_off_time_datetime
value: !lambda |-
return ESPTime::from_epoch_local(id(my_time).now().timestamp + 20).strftime("%H:%M:%S");
switch:
- platform: template
name: "Template Switch"
id: my_switch
optimistic: yes
datetime:
- platform: template
id: turn_on_time_datetime
name: 1.Time to turn the switch on
time_id: my_time
optimistic: yes
# valid formats are '%Y-%m-%d %H:%M:%S' - '%Y-%m-%d %H:%M' - '%H:%M:%S' - '%H:%M'
initial_value: "16:45:20"
on_time:
- switch.turn_on:
id: my_switch
- platform: template
id: turn_off_time_datetime
name: 2.Time to trun the switch off
time_id: my_time
optimistic: yes
# valid formats are '%Y-%m-%d %H:%M:%S' - '%Y-%m-%d %H:%M' - '%H:%M:%S' - '%H:%M'
initial_value: "16:45:20"
on_time:
- switch.turn_off:
id: my_switch