-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnspanel_esphome_core.yaml
More file actions
218 lines (203 loc) · 8.21 KB
/
nspanel_esphome_core.yaml
File metadata and controls
218 lines (203 loc) · 8.21 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#####################################################################################################
##### NSPanel Easy - https://github.com/edwardtfn/NSPanel-Easy #####
#####################################################################################################
##### ESPHOME CORE #####
##### 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 ##
##############################
DELAY_DEFAULT: 25 # delay in msec
DELAY_LONG: 125 # delay in msec
DELAY_SHORT: 5 # delay in msec
TAG_CORE: "nspanel.core"
packages:
# yamllint disable rule:colons
version: !include nspanel_esphome_version.yaml
api: !include nspanel_esphome_api.yaml
base: !include nspanel_esphome_base.yaml
boot: !include nspanel_esphome_boot.yaml
datetime: !include nspanel_esphome_datetime.yaml
hw_buttons: !include nspanel_esphome_hw_buttons.yaml
hw_display: !include nspanel_esphome_hw_display.yaml
hw_memory: !include nspanel_esphome_hw_memory.yaml
hw_wifi: !include nspanel_esphome_hw_wifi.yaml
localization: !include nspanel_esphome_localization.yaml
page_boot: !include nspanel_esphome_page_boot.yaml
page_home: !include nspanel_esphome_page_home.yaml
page_screensaver: !include nspanel_esphome_page_screensaver.yaml
# yamllint enable rule:colons
##### ESPHOME CONFIGURATION #####
esphome:
platformio_options:
build_flags:
- -D NSPANEL_EASY_CORE
##### START - GLOBALS CONFIGURATION #####
globals:
- id: hardware_settings
type: nspanel_easy::HardwareSettings
restore_value: true
initial_value: 'nspanel_easy::HardwareSettings{}'
#### Localization (MUI) ####
- id: mui_decimal_separator
type: std::string # To do: Should this be optimized as it is always 1-char?
restore_value: true
initial_value: '"."'
##### START - NUMBER CONFIGURATION #####
number:
##### Timers settings #####
- name: Timeout Page
platform: template
id: timeout_page
entity_category: config
min_value: 0
max_value: 86400
initial_value: 15
step: 1
restore_value: true
optimistic: true
icon: mdi:timer
unit_of_measurement: "s"
update_interval: never
on_value:
then:
- script.execute: timer_page
- name: Timeout Dimming
platform: template
id: timeout_dim
entity_category: config
min_value: 0
max_value: 86400
initial_value: 30
step: 1
restore_value: true
optimistic: true
icon: mdi:timer
unit_of_measurement: "s"
update_interval: never
on_value:
then:
- script.execute: timer_dim
script: # Scripts
- id: !extend action_component_text
then:
- lambda: |-
if (page == "mem" && component == "decimal_separator" && !txt.empty())
id(mui_decimal_separator) = txt[0];
- id: !extend dump_config
then:
- lambda: |-
// Report Packages
ESP_LOGCONFIG("${TAG_CORE}", "Packages:");
#ifdef NSPANEL_EASY_CORE
ESP_LOGCONFIG("${TAG_CORE}", " - Core");
#endif
#ifdef NSPANEL_EASY_ADVANCED
ESP_LOGCONFIG("${TAG_CORE}", " - Advanced");
#endif
#ifdef NSPANEL_EASY_ADDON_BLUETOOTH_PROXY
ESP_LOGCONFIG("${TAG_CORE}", " - Bluetooth Proxy");
#endif
#ifdef NSPANEL_EASY_ADDON_UPLOAD_TFT
ESP_LOGCONFIG("${TAG_CORE}", " - Upload TFT");
#endif
#ifdef NSPANEL_EASY_ADDON_CLIMATE_BASE
ESP_LOGCONFIG("${TAG_CORE}", " - Climate - Base");
#endif
#ifdef NSPANEL_EASY_ADDON_CLIMATE_COOL
ESP_LOGCONFIG("${TAG_CORE}", " - Climate - Cool");
#endif
#ifdef NSPANEL_EASY_ADDON_CLIMATE_DUAL
ESP_LOGCONFIG("${TAG_CORE}", " - Climate - Dual");
#endif
#ifdef NSPANEL_EASY_ADDON_CLIMATE_HEAT
ESP_LOGCONFIG("${TAG_CORE}", " - Climate - Heat");
#endif
#ifdef NSPANEL_EASY_PREBUILT
ESP_LOGCONFIG("${TAG_CORE}", " - Pre-built");
#endif
#ifdef NSPANEL_EASY_PREBUILT_WALL_DISPLAY
ESP_LOGCONFIG("${TAG_CORE}", " - Pre-built (Wall Display)");
#endif
#if defined(USE_BLUETOOTH_PROXY) || defined(USE_WEBSERVER) || defined(USE_CAPTIVE_PORTAL)
ESP_LOGCONFIG("${TAG_CORE}", "Components:");
#ifdef USE_ESP32_BLE_SERVER
ESP_LOGCONFIG("${TAG_CORE}", " - BLE server");
#endif
#ifdef USE_ESP32_BLE_CLIENT
ESP_LOGCONFIG("${TAG_CORE}", " - BLE tracker");
#endif
#ifdef USE_BLUETOOTH_PROXY
ESP_LOGCONFIG("${TAG_CORE}", " - Bluetooth proxy");
#endif
#ifdef USE_CAPTIVE_PORTAL
ESP_LOGCONFIG("${TAG_CORE}", " - Captive portal");
#endif
#ifdef USE_IMPROV
ESP_LOGCONFIG("${TAG_CORE}", " - Improv (BLE)");
#endif
#ifdef USE_WEBSERVER
ESP_LOGCONFIG("${TAG_CORE}", " - Web server");
#endif
#endif
- id: !extend stop_all
then:
- lambda: |-
wait_for_api->stop();
wait_for_blueprint->stop();
- id: wait_for_api
mode: single
then:
- repeat:
count: 60 # seconds
then:
- lambda: |-
if (system_flags.api_ready) wait_for_api->stop();
if (iteration % 5 == 1) boot_log->execute("Boot", "Waiting for API");
- delay: 1s
- id: wait_for_blueprint
mode: single
then:
- lambda: boot_log->execute("Boot", "Waiting for Blueprint");
- while:
condition:
- lambda: return (not system_flags.blueprint_ready) and (not is_blueprint_fully_ready());
then:
- lambda: |-
// Single counter for all periodic actions
static uint8_t counter = 1; // Start at 1 to skip actions on first run
// Log at DEBUG on progress change or every 5s as heartbeat
#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
const bool is_verbose_log = true;
#else
const bool is_verbose_log = false;
#endif
static uint8_t last_flags_count = 0;
const uint8_t current_flags_count = blueprint_status_flags.count_active_flags_set();
if (is_verbose_log || current_flags_count != last_flags_count || counter % 5 == 0) {
last_flags_count = current_flags_count;
ESP_LOGD("${TAG_CORE}", "Receiving settings from Blueprint: %0.1f%%",
blueprint_status_flags.get_completion_percentage());
ESP_LOGV("${TAG_CORE}", " Page home: %s", YESNO(blueprint_status_flags.page_home));
ESP_LOGV("${TAG_CORE}", " Page qrcode: %s", YESNO(blueprint_status_flags.page_qrcode));
ESP_LOGV("${TAG_CORE}", " Relay settings: %s", YESNO(blueprint_status_flags.relay_settings));
ESP_LOGV("${TAG_CORE}", " Version: %s", YESNO(blueprint_status_flags.version));
ESP_LOGV("${TAG_CORE}", " HW Buttons settings: %s",
YESNO(blueprint_status_flags.hw_buttons_settings));
}
// Re-request blueprint settings on timeout (every 30s)
if (counter % 30 == 0) {
boot_request_blueprint_settings->execute("timeout");
}
counter++;
- delay: 1s
- lambda: |-
ESP_LOGI("${TAG_CORE}", "Receiving settings from Blueprint: %0.1f%%",
blueprint_status_flags.get_completion_percentage());
boot_log->execute("Boot", "Blueprint is ready");
refresh_wifi_icon->execute();
...