-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnspanel_esphome_version.yaml
More file actions
202 lines (188 loc) · 8.84 KB
/
nspanel_esphome_version.yaml
File metadata and controls
202 lines (188 loc) · 8.84 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
#####################################################################################################
##### NSPanel Easy - https://github.com/edwardtfn/NSPanel-Easy #####
#####################################################################################################
##### ESPHOME VERSION #####
##### 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:
# Automatically updated by CI/CD on each release
# Value is imported from versioning/version.yaml
<<: !include ../versioning/version.yaml
# Minimum required versions for compatibility
min_blueprint_version: 17
min_tft_version: 15
min_esphome_compiler_version: 2026.1.0
TAG_VERSIONING: nspanel.versioning
esphome:
project:
version: '"${version}"'
platformio_options:
build_flags:
- -D NSPANEL_EASY_VERSIONING
min_version: ${min_esphome_compiler_version}
script:
- id: !extend action_component_val
then:
- lambda: |-
if (page != "mem") return;
if (component != "ver_blueprint") return;
if (val <= 0) return;
version_blueprint_set->execute(static_cast<uint8_t>(val));
- id: !extend boot_early_routines
then:
- delay: ${DELAY_DEFAULT}ms
- script.execute: versions_publish
- id: check_versions
mode: restart
parameters:
reset_flag: bool
then:
- lambda: |-
ESP_LOGV("${TAG_VERSIONING}", "Script: Check version");
ESP_LOGV("${TAG_VERSIONING}", " reset_flag: %s", TRUEFALSE(reset_flag));
ESP_LOGV("${TAG_VERSIONING}", " VERSION_CHECK_OK: %s", (system_flags.version_check_ok) ? "Set" : "NOT set");
ESP_LOGV("${TAG_VERSIONING}", " is_device_ready_for_tasks: %s", YESNO(is_device_ready_for_tasks()));
ESP_LOGV("${TAG_VERSIONING}", " Versions:");
ESP_LOGV("${TAG_VERSIONING}", " Blueprint: %" PRIu8, version_blueprint);
ESP_LOGV("${TAG_VERSIONING}", " ESPHome: ${version}");
ESP_LOGV("${TAG_VERSIONING}", " TFT: %" PRIu8, version_tft);
if (reset_flag) system_flags.version_check_ok = false;
if (system_flags.version_check_ok) {
ESP_LOGD("${TAG_VERSIONING}", "VERSION_CHECK_OK is already set");
return;
}
if (!is_device_ready_for_tasks()) {
ESP_LOGD("${TAG_VERSIONING}", "Device not ready for tasks - Skip version check");
return;
}
- delay: 5s
- script.execute: wait_for_versions
- script.wait: wait_for_versions
- lambda: |-
ESP_LOGD("${TAG_VERSIONING}", "Versions:");
ESP_LOGD("${TAG_VERSIONING}", " Blueprint: %" PRIu8, version_blueprint);
ESP_LOGD("${TAG_VERSIONING}", " ESPHome: ${version}");
ESP_LOGD("${TAG_VERSIONING}", " TFT: %" PRIu8, version_tft);
system_flags.version_check_ok = true;
if (version_blueprint != ${min_blueprint_version}) {
ESP_LOGW("${TAG_VERSIONING}", "Blueprint version mismatch!");
if (version_blueprint > 0) {
system_flags.version_check_ok = false;
ESP_LOGE("${TAG_VERSIONING}", "Blueprint v${min_blueprint_version} is required");
ESP_LOGE("${TAG_VERSIONING}", "How to Resolve This Issue:");
ESP_LOGE("${TAG_VERSIONING}", "1. Navigate to your Blueprint Dashboard on Home Assistant" \
"(Settings > Automations & scenes, tab 'Blueprints')");
ESP_LOGE("${TAG_VERSIONING}", "2. Locate the blueprint named 'NSPanel Easy Configuration'");
ESP_LOGE("${TAG_VERSIONING}", "3. Click on the corresponding 3-dot menu");
ESP_LOGE("${TAG_VERSIONING}", "4. Choose 'Re-import blueprint'");
ESP_LOGE("${TAG_VERSIONING}", "5. Select the 'Re-import' button");
ESP_LOGE("${TAG_VERSIONING}", "6. Navigate to YAML configuration reloading dashboard");
ESP_LOGE("${TAG_VERSIONING}", "7. Select 'Automations' to reload the automations");
ESP_LOGE("${TAG_VERSIONING}", "For more detailed instructions, please refer to the online documentation:");
ESP_LOGE("${TAG_VERSIONING}", "https://github.com/edwardtfn/NSPanel-Easy/blob/main/docs/howto.md#update-blueprint");
}
}
if (version_tft != ${min_tft_version}) {
ESP_LOGW("${TAG_VERSIONING}", "TFT version mismatch!");
if (version_tft > 0) {
ESP_LOGE("${TAG_VERSIONING}", "TFT v${min_tft_version} is required");
system_flags.version_check_ok = false;
}
}
fire_ha_event("version", {
{"blueprint", std::to_string(static_cast<unsigned int>(version_blueprint))},
{"min_blueprint_version", "${min_blueprint_version}"},
{"esphome", "${version}"},
{"tft", std::to_string(static_cast<unsigned int>(version_tft))},
{"min_tft_version", "${min_tft_version}"},
#ifdef NSPANEL_EASY_ADDON_UPLOAD_TFT
{"upload_tft_installed", "true"},
{"upload_tft_auto", "${upload_tft_automatically}"},
{"upload_tft_wait_ms", "${upload_tft_wait_ms_after_boot}"}
#else // Upload TFT add-on is not installed
{"upload_tft_installed", "false"}
#endif // NSPANEL_EASY_ADDON_UPLOAD_TFT
});
ESP_LOGD("${TAG_VERSIONING}", "Check version completed");
- id: !extend dump_config
then:
- lambda: |-
// Report blueprint version
ESP_LOGCONFIG("${TAG_VERSIONING}", "Blueprint:");
if (system_flags.blueprint_ready) {
ESP_LOGCONFIG("${TAG_VERSIONING}", " Version: %" PRIu8, version_blueprint);
ESP_LOGCONFIG("${TAG_VERSIONING}", " Progress: %0.1f%%", blueprint_status_flags.get_completion_percentage());
} else {
ESP_LOGW("${TAG_VERSIONING}", " Progress: %0.1f%%", blueprint_status_flags.get_completion_percentage());
ESP_LOGW("${TAG_VERSIONING}", " State: %s", (system_flags.wifi_ready and system_flags.api_ready)
? "Pending" : "DISCONNECTED");
}
// Report ESPHome
ESP_LOGCONFIG("${TAG_VERSIONING}", "ESPHome:");
ESP_LOGCONFIG("${TAG_VERSIONING}", " Version: ${version}");
ESP_LOGCONFIG("${TAG_VERSIONING}", " Compiler: %s", ESPHOME_VERSION);
// Report framework
#ifdef USE_ESP_IDF
ESP_LOGCONFIG("${TAG_VERSIONING}", " Framework: ESP-IDF");
#elif defined(USE_ARDUINO)
ESP_LOGW("${TAG_VERSIONING}", " Framework: Arduino");
#else
ESP_LOGE("${TAG_VERSIONING}", " Framework: Unknown");
#endif
- id: !extend stop_all
then:
- lambda: |-
check_versions->stop();
version_blueprint_set->stop();
versions_publish->stop();
wait_for_version_blueprint->stop();
wait_for_versions->stop();
- id: version_blueprint_set
mode: restart
parameters:
version: uint8_t
then:
- lambda: |-
if (version == 0) {
ESP_LOGE("${TAG_VERSIONING}", "Invalid Blueprint version");
return;
}
version_blueprint = version;
ESP_LOGI("${TAG_VERSIONING}", "Blueprint version: %" PRIu8, version_blueprint);
versions_publish->execute();
- id: versions_publish
mode: restart
then:
- lambda: |-
char buf[32];
snprintf(buf, sizeof(buf), "${version}/%" PRIu8 "/%" PRIu8, version_blueprint, version_tft);
version_info->publish_state(std::string(buf));
blueprint_status_flags.version = version_blueprint == ${min_blueprint_version};
check_versions->execute(!blueprint_status_flags.version or version_tft != ${min_tft_version});
- id: wait_for_version_blueprint
mode: single
then:
- repeat:
count: 60 # seconds
then:
- lambda: |-
if (version_blueprint > 0) wait_for_version_blueprint->stop();
if (iteration % 5 == 1) boot_log->execute("Boot", "Waiting for Blueprint version");
if (iteration % 9 == 0) boot_request_blueprint_settings->execute("timeout");
- delay: 1s
- id: wait_for_versions
mode: single
then:
- script.execute: wait_for_version_blueprint
- script.wait: wait_for_version_blueprint
text_sensor:
- id: version_info
name: Version
platform: template
entity_category: diagnostic
icon: mdi:tag-text-outline
internal: false
update_interval: never
...