@@ -325,6 +325,9 @@ api:
|
||||
relay2_icon: !lambda "return relay2_icon;"
|
||||
relay2_icon_color: !lambda "return relay2_icon_color;"
|
||||
relay2_fallback: !lambda "return relay2_fallback;"
|
||||
- script.wait: relay_settings
|
||||
- lambda: |-
|
||||
blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 4));
|
||||
|
||||
##### Service for transferring global settings from the blueprint to ESPHome #####
|
||||
- service: global_settings
|
||||
@@ -350,6 +353,9 @@ api:
|
||||
mui_unavailable: !lambda "return mui_unavailable;"
|
||||
screensaver_time: !lambda "return screensaver_time;"
|
||||
screensaver_time_color: !lambda "return screensaver_time_color;"
|
||||
- script.wait: global_settings
|
||||
- lambda: |-
|
||||
blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 5));
|
||||
|
||||
##### Service to show a notification-message on the screen #####
|
||||
- service: notification_show
|
||||
@@ -410,6 +416,7 @@ api:
|
||||
disp1->set_component_text_printf("qrcode.qrcode_label", "%s", title.c_str());
|
||||
disp1->set_component_text_printf("qrcode.qrcode_value", "%s", qrcode.c_str());
|
||||
if (show) disp1->goto_page("qrcode");
|
||||
blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 2));
|
||||
}
|
||||
|
||||
#### Service to set climate state ####
|
||||
@@ -614,6 +621,8 @@ api:
|
||||
disp1->set_component_text_printf("home.bt_entities", "%s", entities_pages_icon.c_str());
|
||||
//set_component_color->execute("home.bt_entities", entities_pages_icon_color);
|
||||
set_component_color->execute("home.bt_entities", entities_pages_icon_color);
|
||||
|
||||
blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 1));
|
||||
}
|
||||
|
||||
#### Service to populate the page Settings #####
|
||||
@@ -630,6 +639,7 @@ api:
|
||||
disp1->set_component_text_printf("settings.lbl_brightness", " %s", brightness.c_str());
|
||||
display_wrapped_text->execute("settings.lbl_bright", bright.c_str(), display_mode->state == 2 ? 25 : 10);
|
||||
display_wrapped_text->execute("settings.lbl_dim", dim.c_str(), display_mode->state == 2 ? 25 : 10);
|
||||
blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 3));
|
||||
}
|
||||
|
||||
#### Service to populate the media player page #####
|
||||
@@ -773,12 +783,6 @@ globals:
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
|
||||
##### Is global settings loaded #####
|
||||
- id: is_global_settings_loaded
|
||||
type: bool
|
||||
restore_value: false
|
||||
initial_value: 'false'
|
||||
|
||||
##### Is boot sequence completed? #####
|
||||
- id: setup_sequence_completed
|
||||
type: bool
|
||||
@@ -1087,23 +1091,6 @@ binary_sensor:
|
||||
then:
|
||||
- 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 #####
|
||||
button:
|
||||
###### Factory Reset button #####
|
||||
@@ -1328,6 +1315,36 @@ select:
|
||||
|
||||
##### START - SENSOR CONFIGURATION #####
|
||||
sensor:
|
||||
##### Blueprint status #####
|
||||
# Bit # Settings step #
|
||||
# 0 # reserved #
|
||||
# 1 # page_home #
|
||||
# 2 # qrcode #
|
||||
# 3 # page_settings #
|
||||
# 4 # relay_settings #
|
||||
# 5 # global_settings #
|
||||
# 6 # reserved #
|
||||
# 7 # reserved #
|
||||
##############################
|
||||
- name: Blueprint
|
||||
id: blueprint_status
|
||||
platform: template
|
||||
unit_of_measurement: "%"
|
||||
accuracy_decimals: 1
|
||||
entity_category: diagnostic
|
||||
icon: mdi:link-variant
|
||||
internal: false
|
||||
disabled_by_default: false
|
||||
filters:
|
||||
- lambda: return (x / 62) * 100.0f;
|
||||
on_value:
|
||||
then:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "sensor.blueprint_status";
|
||||
ESP_LOGD(TAG, "Blueprint progress: %i%%", int(round(x)));
|
||||
// Update api value on Nextion
|
||||
disp1->send_command_printf("api=%i", (x > 99) ? 1 : 0);
|
||||
|
||||
##### INTERNAL TEMPERATURE SENSOR, ADC VALUE #####
|
||||
- id: ntc_source
|
||||
platform: adc
|
||||
@@ -1473,12 +1490,12 @@ switch:
|
||||
on_turn_on:
|
||||
- wait_until:
|
||||
condition:
|
||||
- lambda: !lambda return id(is_global_settings_loaded);
|
||||
- lambda: !lambda return (blueprint_status->state > 99);
|
||||
- lambda: set_component_color->execute("home.bt_notific", id(home_notify_icon_color_unread));
|
||||
on_turn_off:
|
||||
- wait_until:
|
||||
condition:
|
||||
- lambda: !lambda return id(is_global_settings_loaded);
|
||||
- lambda: !lambda return (blueprint_status->state > 99);
|
||||
- lambda: set_component_color->execute("home.bt_notific", id(home_notify_icon_color_normal));
|
||||
|
||||
##### Notification sound #####
|
||||
@@ -1954,10 +1971,6 @@ script:
|
||||
id(screensaver_display_time_color) = screensaver_time_color;
|
||||
page_screensaver->execute();
|
||||
|
||||
id(is_global_settings_loaded) = true;
|
||||
blueprint_status->publish_state(true);
|
||||
disp1->send_command_printf("api=1");
|
||||
|
||||
if (current_page->state != "boot") {
|
||||
// Update current page
|
||||
ESP_LOGV(TAG, "Update current page");
|
||||
@@ -2430,7 +2443,6 @@ script:
|
||||
bool is_notification = ((not notification_text->state.empty()) or (not notification_label->state.empty()));
|
||||
ESP_LOGV(TAG, "Notification: %s", is_notification ? "True" : "False");
|
||||
disp1->send_command_printf("is_notification=%i", is_notification ? 0 : 1);
|
||||
set_component_color->execute("home.bt_notific", notification_unread->state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal));
|
||||
if (current_page->state == "home") {
|
||||
if (is_notification) {
|
||||
disp1->show_component("bt_notific");
|
||||
@@ -2438,6 +2450,11 @@ script:
|
||||
disp1->hide_component("bt_notific");
|
||||
}
|
||||
}
|
||||
- wait_until:
|
||||
condition:
|
||||
- lambda: return (blueprint_status->state > 99);
|
||||
- lambda: |-
|
||||
set_component_color->execute("home.bt_notific", notification_unread->state ? id(home_notify_icon_color_unread) : id(home_notify_icon_color_normal));
|
||||
|
||||
- id: refresh_relays
|
||||
mode: restart
|
||||
@@ -2456,15 +2473,15 @@ script:
|
||||
- lambda: |-
|
||||
if (nextion_init->state) {
|
||||
// Update Wi-Fi icon color
|
||||
disp1->set_component_font_color("home.wifi_icon", (blueprint_status->state) ? (wifi_rssi->state > -70 ? 33808 : 64992) : 63488);
|
||||
disp1->set_component_font_color("home.wifi_icon", (blueprint_status->state > 99) ? (wifi_rssi->state > -70 ? 33808 : 64992) : 63488);
|
||||
// Update Wi-Fi icon
|
||||
disp1->set_component_text_printf("home.wifi_icon", "%s",
|
||||
wifi_component->is_connected() ?
|
||||
(api_server->is_connected() ?
|
||||
(blueprint_status->state ? "\uE5A8" : // mdi:wifi - All right!
|
||||
"\uE7CF") : // mdi:home-assistant - Blueprint is out
|
||||
"\uF256") : // mdi:api-off
|
||||
"\uE5A9"); // mdi:wifi-off
|
||||
((blueprint_status->state > 99) ? "\uE5A8" : // mdi:wifi - All right!
|
||||
"\uE7CF") : // mdi:home-assistant - Blueprint is out
|
||||
"\uF256") : // mdi:api-off
|
||||
"\uE5A9"); // mdi:wifi-off
|
||||
}
|
||||
|
||||
- id: relay_settings
|
||||
@@ -3229,13 +3246,12 @@ script:
|
||||
}
|
||||
|
||||
// report API status
|
||||
bool previous_blueprint_status = blueprint_status->state;
|
||||
bool api_connected = api_server->is_connected();
|
||||
if (api_connected) {
|
||||
ESP_LOGI(TAG, "API: Connected");
|
||||
} else {
|
||||
ESP_LOGW(TAG, "API: DISCONNECTED");
|
||||
blueprint_status->publish_state(false);
|
||||
blueprint_status->publish_state(0);
|
||||
if (current_page->state != "blank" and
|
||||
current_page->state != "boot" and
|
||||
current_page->state != "home" and
|
||||
@@ -3247,12 +3263,16 @@ script:
|
||||
}
|
||||
}
|
||||
|
||||
if (!wifi_connected or !api_connected) blueprint_status->publish_state(0);
|
||||
|
||||
// Report blueprint version
|
||||
blueprint_status->publish_state(blueprint_status->state and wifi_connected and api_connected and (not version_blueprint->state.empty()));
|
||||
if (blueprint_status->state)
|
||||
ESP_LOGI(TAG, "Blueprint: %s", version_blueprint->state.c_str());
|
||||
else {
|
||||
ESP_LOGW(TAG, "Blueprint: %s", (wifi_connected and api_connected) ? "Pending" : "DISCONNECTED");
|
||||
ESP_LOGI(TAG, "Blueprint:");
|
||||
if (blueprint_status->state > 99) {
|
||||
ESP_LOGI(TAG, " Version: %s", version_blueprint->state.c_str());
|
||||
ESP_LOGI(TAG, " Init steps: %i (%0.1f%%)", int(blueprint_status->raw_state), blueprint_status->state);
|
||||
} else {
|
||||
ESP_LOGW(TAG, " Init steps: %i (%0.1f%%)", int(blueprint_status->raw_state), blueprint_status->state);
|
||||
ESP_LOGW(TAG, " State: %s", (wifi_connected and api_connected) ? "Pending" : "DISCONNECTED");
|
||||
ESP_LOGI(TAG, "Requesting blueprint settings");
|
||||
auto ha_event = new esphome::api::CustomAPIDevice();
|
||||
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
|
||||
|
||||
Reference in New Issue
Block a user