Publish diagnostic sensor "Blueprint" and simplify TFT upload
This commit is contained in:
@@ -383,17 +383,6 @@ script:
|
|||||||
- lambda: !lambda return (!id(tft_is_valid));
|
- lambda: !lambda return (!id(tft_is_valid));
|
||||||
timeout: 1s
|
timeout: 1s
|
||||||
|
|
||||||
### Attempt twice with upload engine from v4.1.4 (115200bps) when TFT isn't detected
|
|
||||||
# - if:
|
|
||||||
# condition:
|
|
||||||
# - lambda: !lambda return (not id(tft_is_valid));
|
|
||||||
# then:
|
|
||||||
# - script.execute:
|
|
||||||
# id: upload_tft_sequence_attempt_v414
|
|
||||||
# url: !lambda return url.c_str();
|
|
||||||
# baud_rate: 115200
|
|
||||||
# - script.wait: upload_tft_sequence_attempt_v414
|
|
||||||
|
|
||||||
### Attempt twice at the target baud rate
|
### Attempt twice at the target baud rate
|
||||||
- script.execute:
|
- script.execute:
|
||||||
id: upload_tft_sequence_attempt
|
id: upload_tft_sequence_attempt
|
||||||
@@ -401,16 +390,26 @@ script:
|
|||||||
- script.wait: upload_tft_sequence_attempt
|
- script.wait: upload_tft_sequence_attempt
|
||||||
|
|
||||||
### Attempt twice at the original baud rate
|
### Attempt twice at the original baud rate
|
||||||
- script.execute:
|
- if:
|
||||||
id: upload_tft_sequence_attempt
|
condition:
|
||||||
baud_rate: !lambda return id(baud_rate_original);
|
- lambda: |-
|
||||||
- script.wait: upload_tft_sequence_attempt
|
return (id(baud_rate_original) != id(baud_rate_target));
|
||||||
|
then:
|
||||||
|
- script.execute:
|
||||||
|
id: upload_tft_sequence_attempt
|
||||||
|
baud_rate: !lambda return id(baud_rate_original);
|
||||||
|
- script.wait: upload_tft_sequence_attempt
|
||||||
|
|
||||||
### Attempt twice at the Nextion's default baud rate (115200bps)
|
### Attempt twice at the Nextion's default baud rate (115200bps)
|
||||||
- script.execute:
|
- if:
|
||||||
id: upload_tft_sequence_attempt
|
condition:
|
||||||
baud_rate: 115200
|
- lambda: |-
|
||||||
- script.wait: upload_tft_sequence_attempt
|
return (id(baud_rate_original) != 115200 and id(baud_rate_target) != 115200);
|
||||||
|
then:
|
||||||
|
- script.execute:
|
||||||
|
id: upload_tft_sequence_attempt
|
||||||
|
baud_rate: 115200
|
||||||
|
- script.wait: upload_tft_sequence_attempt
|
||||||
|
|
||||||
### Attempt twice with upload engine from v4.1.4 (115200bps)
|
### Attempt twice with upload engine from v4.1.4 (115200bps)
|
||||||
- script.execute:
|
- script.execute:
|
||||||
@@ -419,15 +418,6 @@ script:
|
|||||||
baud_rate: 115200
|
baud_rate: 115200
|
||||||
- script.wait: upload_tft_sequence_attempt_v414
|
- script.wait: upload_tft_sequence_attempt_v414
|
||||||
|
|
||||||
### Exit reparse and attempt twice again
|
|
||||||
- script.execute:
|
|
||||||
id: report_upload_progress
|
|
||||||
message: "Exiting reparse mode"
|
|
||||||
- script.execute:
|
|
||||||
id: upload_tft_sequence_attempt
|
|
||||||
baud_rate: 115200
|
|
||||||
- script.wait: upload_tft_sequence_attempt
|
|
||||||
|
|
||||||
### Restart Nextion and attempt twice again at default baud rate (115200bps)
|
### Restart Nextion and attempt twice again at default baud rate (115200bps)
|
||||||
- script.execute:
|
- script.execute:
|
||||||
id: report_upload_progress
|
id: report_upload_progress
|
||||||
|
|||||||
@@ -762,12 +762,6 @@ globals:
|
|||||||
restore_value: false
|
restore_value: false
|
||||||
initial_value: 'false'
|
initial_value: 'false'
|
||||||
|
|
||||||
##### Is blueprint updated #####
|
|
||||||
- id: is_blueprint_updated
|
|
||||||
type: bool
|
|
||||||
restore_value: false
|
|
||||||
initial_value: 'false'
|
|
||||||
|
|
||||||
##### Is global settings loaded #####
|
##### Is global settings loaded #####
|
||||||
- id: is_global_settings_loaded
|
- id: is_global_settings_loaded
|
||||||
type: bool
|
type: bool
|
||||||
@@ -1082,6 +1076,23 @@ binary_sensor:
|
|||||||
then:
|
then:
|
||||||
- script.execute: watchdog
|
- script.execute: watchdog
|
||||||
|
|
||||||
|
- name: Blueprint
|
||||||
|
id: blueprint_status
|
||||||
|
platform: template
|
||||||
|
device_class: connectivity
|
||||||
|
publish_initial_state: false
|
||||||
|
entity_category: diagnostic
|
||||||
|
icon: mdi:link-variant
|
||||||
|
internal: false
|
||||||
|
disabled_by_default: false
|
||||||
|
on_state:
|
||||||
|
then:
|
||||||
|
- lambda: |-
|
||||||
|
static const char *const TAG = "binary_sensor.blueprint_status";
|
||||||
|
ESP_LOGD(TAG, "Blueprint synced: %s", x ? "True" : "False");
|
||||||
|
// Update api value on Nextion
|
||||||
|
disp1->send_command_printf("api=%i", x ? 1 : 0);
|
||||||
|
|
||||||
##### START - BUTTON CONFIGURATION #####
|
##### START - BUTTON CONFIGURATION #####
|
||||||
button:
|
button:
|
||||||
###### Factory Reset button #####
|
###### Factory Reset button #####
|
||||||
@@ -1749,7 +1760,7 @@ text_sensor:
|
|||||||
entity_category: diagnostic
|
entity_category: diagnostic
|
||||||
icon: mdi:tag-text-outline
|
icon: mdi:tag-text-outline
|
||||||
internal: false
|
internal: false
|
||||||
update_interval: never
|
#update_interval: never
|
||||||
lambda: |-
|
lambda: |-
|
||||||
return {"${version}"};
|
return {"${version}"};
|
||||||
on_value:
|
on_value:
|
||||||
@@ -1932,7 +1943,7 @@ script:
|
|||||||
page_screensaver->execute();
|
page_screensaver->execute();
|
||||||
|
|
||||||
id(is_global_settings_loaded) = true;
|
id(is_global_settings_loaded) = true;
|
||||||
id(is_blueprint_updated) = true;
|
blueprint_status->publish_state(true);
|
||||||
disp1->send_command_printf("api=1");
|
disp1->send_command_printf("api=1");
|
||||||
|
|
||||||
if (current_page->state != "boot") {
|
if (current_page->state != "boot") {
|
||||||
@@ -2424,12 +2435,12 @@ script:
|
|||||||
- lambda: |-
|
- lambda: |-
|
||||||
if (nextion_init->state) {
|
if (nextion_init->state) {
|
||||||
// Update Wi-Fi icon color
|
// Update Wi-Fi icon color
|
||||||
disp1->set_component_font_color("home.wifi_icon", (id(is_blueprint_updated)) ? (wifi_rssi->state > -70 ? 33808 : 64992) : 63488);
|
disp1->set_component_font_color("home.wifi_icon", (blueprint_status->state) ? (wifi_rssi->state > -70 ? 33808 : 64992) : 63488);
|
||||||
// Update Wi-Fi icon
|
// Update Wi-Fi icon
|
||||||
disp1->set_component_text_printf("home.wifi_icon", "%s",
|
disp1->set_component_text_printf("home.wifi_icon", "%s",
|
||||||
wifi_component->is_connected() ?
|
wifi_component->is_connected() ?
|
||||||
(api_server->is_connected() ?
|
(api_server->is_connected() ?
|
||||||
(id(is_blueprint_updated) ? "\uE5A8" : // mdi:wifi - All right!
|
(blueprint_status->state ? "\uE5A8" : // mdi:wifi - All right!
|
||||||
"\uE7CF") : // mdi:home-assistant - Blueprint is out
|
"\uE7CF") : // mdi:home-assistant - Blueprint is out
|
||||||
"\uF256") : // mdi:api-off
|
"\uF256") : // mdi:api-off
|
||||||
"\uE5A9"); // mdi:wifi-off
|
"\uE5A9"); // mdi:wifi-off
|
||||||
@@ -3191,13 +3202,13 @@ script:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// report API status
|
// report API status
|
||||||
bool previous_blueprint_status = id(is_blueprint_updated);
|
bool previous_blueprint_status = blueprint_status->state;
|
||||||
bool api_connected = api_server->is_connected();
|
bool api_connected = api_server->is_connected();
|
||||||
if (api_connected) {
|
if (api_connected) {
|
||||||
ESP_LOGI(TAG, "API: Connected");
|
ESP_LOGI(TAG, "API: Connected");
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGW(TAG, "API: DISCONNECTED");
|
ESP_LOGW(TAG, "API: DISCONNECTED");
|
||||||
id(is_blueprint_updated) = false;
|
blueprint_status->publish_state(false);
|
||||||
if (current_page->state != "blank" and
|
if (current_page->state != "blank" and
|
||||||
current_page->state != "boot" and
|
current_page->state != "boot" and
|
||||||
current_page->state != "home" and
|
current_page->state != "home" and
|
||||||
@@ -3210,8 +3221,8 @@ script:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Report blueprint version
|
// Report blueprint version
|
||||||
id(is_blueprint_updated) = id(is_blueprint_updated) and wifi_connected and api_connected and (not version_blueprint->state.empty());
|
blueprint_status->publish_state(blueprint_status->state and wifi_connected and api_connected and (not version_blueprint->state.empty()));
|
||||||
if (id(is_blueprint_updated))
|
if (blueprint_status->state)
|
||||||
ESP_LOGI(TAG, "Blueprint: %s", version_blueprint->state.c_str());
|
ESP_LOGI(TAG, "Blueprint: %s", version_blueprint->state.c_str());
|
||||||
else {
|
else {
|
||||||
ESP_LOGW(TAG, "Blueprint: %s", (wifi_connected and api_connected) ? "Pending" : "DISCONNECTED");
|
ESP_LOGW(TAG, "Blueprint: %s", (wifi_connected and api_connected) ? "Pending" : "DISCONNECTED");
|
||||||
@@ -3259,8 +3270,6 @@ script:
|
|||||||
}
|
}
|
||||||
if (nextion_init->state) {
|
if (nextion_init->state) {
|
||||||
ESP_LOGI(TAG, " Init: True");
|
ESP_LOGI(TAG, " Init: True");
|
||||||
// Update api value on Nextion
|
|
||||||
if (id(is_blueprint_updated) != previous_blueprint_status) disp1->send_command_printf("api=%i", id(is_blueprint_updated) ? 1 : 0);
|
|
||||||
} else
|
} else
|
||||||
ESP_LOGW(TAG, " Init: False");
|
ESP_LOGW(TAG, " Init: False");
|
||||||
if (version_tft->state.empty())
|
if (version_tft->state.empty())
|
||||||
|
|||||||
Reference in New Issue
Block a user