-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathnspanel_esphome_base.yaml
More file actions
136 lines (121 loc) · 3.79 KB
/
nspanel_esphome_base.yaml
File metadata and controls
136 lines (121 loc) · 3.79 KB
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
#####################################################################################################
##### NSPanel Easy - https://github.com/edwardtfn/NSPanel-Easy #####
#####################################################################################################
##### ESPHOME CORE - Base #####
##### PLEASE only make changes if it is necessary and also the required knowledge is available. #####
##### For normal use with the Blueprint, no changes are necessary. #####
#####################################################################################################
---
substitutions:
##############################
## Change only in your ##
## local yaml substitutions ##
##############################
BOOT_STEP_BASE: 0
device_name: nspanel
friendly_name: ${device_name}
GPIO_PSRAM_CLK_PIN: '5'
GPIO_PSRAM_CS_PIN: '18'
name: ${device_name}
ota_password: ""
project_tag: nspanel_easy
TAG_BASE: nspanel.base
ref_url: https://github.com/edwardtfn/NSPanel-Easy
ref_name: v${version}
button:
- id: restart_nspanel # Reboot ESP32
name: Restart
platform: restart
esp32:
# Extended by:
# - hw_memory
board: esp32dev
framework:
type: esp-idf
esphome:
name: ${name}
friendly_name: ${friendly_name}
comment: NSPanel Easy
project:
name: edwardtfn.NSPanel-Easy
version: ${version}
platformio_options:
build_flags:
- -D NSPANEL_EASY_BASE
external_components:
- source:
type: git
url: ${ref_url}
ref: ${ref_name}
refresh: 300s
components:
- nspanel_easy
interval:
- interval: 89s # Intentionally a prime to reduce the occurences of this happening together with the time update
startup_delay: 89s
then:
- lambda: |-
if (!system_flags.ota_in_progress and !system_flags.tft_upload_active) {
ESP_LOGV("${TAG_BASE}", "Calling the watchdog");
watchdog_round->execute();
}
logger:
nspanel_easy: # Adds custom library for NSPanel HA Blueprint project
id: nspanel_easy_component
disable_bootloader_logs: false # To do: The code supporting this should be removed
on_dump_config:
then:
- script.execute: dump_config
ota:
- id: ota_std
platform: esphome
password: ${ota_password}
on_begin:
then:
- lambda: |-
system_flags.ota_in_progress = true;
stop_all->execute();
safe_mode:
id: safe_mode_component
script:
- id: dump_config
mode: restart
then:
- id: stop_all
mode: restart
then:
- lambda: |-
dump_config->stop();
watchdog_round->stop();
watchdog_round_wait_to_end->stop();
- id: wait_to_be_ready
mode: single
then:
- while:
condition:
- lambda: return !is_device_ready_for_tasks();
then:
- lambda: |-
ESP_LOGW("${TAG_BASE}", "Waiting for the system to be ready before executing an action");
- delay: 5s
- lambda: |-
ESP_LOGV("${TAG_BASE}", "The system is ready to run actions");
- id: watchdog_round
mode: restart
then:
- lambda: |-
if (system_flags.ota_in_progress or system_flags.tft_upload_active) {
ESP_LOGW("${TAG_BASE}", "The watchdog cannot run now");
watchdog_round_wait_to_end->stop();
watchdog_round->stop();
return;
}
ESP_LOGV("${TAG_BASE}", "The watchdog is starting a round");
watchdog_round_wait_to_end->execute();
- id: watchdog_round_wait_to_end
mode: single
then:
- script.wait: watchdog_round
- lambda: |-
ESP_LOGV("${TAG_BASE}", "The watchdog completed the round");
...