-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yaml
160 lines (137 loc) · 3.51 KB
/
template.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
esphome:
name: "template"
friendly_name: "Template"
name_add_mac_suffix: true
on_boot:
- priority: 600.0
then:
- lambda: |-
// Default: Connecting
id(wifi_led_pwm).set_level(0.5);
id(wifi_led_pwm).set_period(1000);
id(wifi_led_pwm).turn_on();
- script.execute: fast_reboot_factory_reset
on_loop:
then:
- lambda: |-
// Captive portal
if(id(wifi_component).has_ap() && !id(wifi_component).has_sta()) {
id(wifi_led_pwm).set_level(0.5);
id(wifi_led_pwm).set_period(200);
} else {
id(wifi_led_pwm).set_period(1000);
// Connected
if(id(wifi_component).is_connected())
id(wifi_led_pwm).set_level(1);
// Connecting
else
id(wifi_led_pwm).set_level(0.5);
}
esp32:
board: esp32-c3-devkitm-1
# esp8266:
# board: esp8285
# restore_from_flash: true
globals:
- id: fast_reboot
type: int
restore_value: yes
initial_value: '0'
- id: factory_reset_reboot_counter
type: int
initial_value: '10'
logger:
baud_rate: 0
level: info
script:
- id: fast_reboot_factory_reset
then:
- if:
condition:
lambda: return ( id(fast_reboot) >= id(factory_reset_reboot_counter) );
then:
- lambda: |-
ESP_LOGI("Fast Boot Factory Reset", "Performing factotry reset");
id(fast_reboot) = 0;
fast_reboot->loop();
global_preferences->sync();
- button.press: factory_reset_button
- lambda: |-
if(id(fast_reboot) > 0)
ESP_LOGI("Fast Boot Factory Reset", "Quick reboot %d/%d, do it %d more times to factory reset", id(fast_reboot), id(factory_reset_reboot_counter), id(factory_reset_reboot_counter) - id(fast_reboot));
id(fast_reboot) += 1;
fast_reboot->loop();
global_preferences->sync();
- delay: 10s
- lambda: |-
id(fast_reboot) = 0;
fast_reboot->loop();
global_preferences->sync();
wifi:
id: wifi_component
ap:
ap_timeout: 0s
reboot_timeout: 0s
power_save_mode: none
captive_portal:
web_server:
api:
reboot_timeout: 0s
ota:
safe_mode: false
#prometheus:
#debug:
# update_interval: 5s
binary_sensor:
- platform: status
name: "Status"
sensor:
- platform: uptime
name: 'Uptime'
update_interval: 15s
- platform: wifi_signal
name: "WiFi Signal"
update_interval: 15s
# - platform: debug
# free:
# name: "Debug: Heap Free"
# # esp8266
# # fragmentation:
# # name: "Debug: Heap Fragmentation"
# block:
# name: "Debug: Heap Largest Contiguous Free Block"
# loop_time:
# name: "Debug: Loop Time"
# # esp32
# # psram:
# # name: "Debug: Free PSRAM"
output:
- platform: slow_pwm
id: wifi_led_pwm
period: 1s
pin: 5
button:
- platform: factory_reset
id: factory_reset_button
name: "Factory reset"
- platform: restart
name: "Restart"
- platform: safe_mode
name: "Safe Mode"
text_sensor:
- platform: wifi_info
ip_address:
name: "Wifi Info: IP Address"
ssid:
name: "Wifi Info: SSID"
bssid:
name: "Wifi Info: BSSID"
mac_address:
name: "Wifi Info: MAC Address"
dns_address:
name: "Wifi Info: DNS Address"
# - platform: debug
# device:
# name: "Debug: Device Info"
# reset_reason:
# name: "Debug: Reset Reason"