|
|
|
|
@@ -24,11 +24,11 @@ substitutions:
|
|
|
|
|
##### External components #####
|
|
|
|
|
external_components:
|
|
|
|
|
- source:
|
|
|
|
|
type: local
|
|
|
|
|
path: /Blackymas/esphome/components/nspanel_ha_blueprint
|
|
|
|
|
#type: git
|
|
|
|
|
#url: https://github.com/Blackymas/NSPanel_HA_Blueprint
|
|
|
|
|
#ref: dev # To do: Change it for releasing
|
|
|
|
|
#type: local
|
|
|
|
|
#path: packages/Blackymas/components
|
|
|
|
|
type: git
|
|
|
|
|
url: https://github.com/Blackymas/NSPanel_HA_Blueprint
|
|
|
|
|
ref: dev # To do: Change it for releasing
|
|
|
|
|
components:
|
|
|
|
|
- nspanel_ha_blueprint
|
|
|
|
|
refresh: 3s # To do: Change it for releasing
|
|
|
|
|
@@ -109,12 +109,6 @@ wifi:
|
|
|
|
|
ap:
|
|
|
|
|
ssid: "${name}"
|
|
|
|
|
password: ${ap_password}
|
|
|
|
|
on_connect:
|
|
|
|
|
then:
|
|
|
|
|
- script.execute: watchdog
|
|
|
|
|
on_disconnect:
|
|
|
|
|
then:
|
|
|
|
|
- script.execute: watchdog
|
|
|
|
|
|
|
|
|
|
##### OTA PASSWORD #####
|
|
|
|
|
ota:
|
|
|
|
|
@@ -164,8 +158,6 @@ time:
|
|
|
|
|
then:
|
|
|
|
|
- script.execute: refresh_datetime
|
|
|
|
|
- seconds: 30
|
|
|
|
|
then:
|
|
|
|
|
- script.execute: watchdog
|
|
|
|
|
|
|
|
|
|
on_time_sync:
|
|
|
|
|
then:
|
|
|
|
|
@@ -176,10 +168,6 @@ time:
|
|
|
|
|
api:
|
|
|
|
|
id: api_server
|
|
|
|
|
reboot_timeout: 60min
|
|
|
|
|
on_client_connected:
|
|
|
|
|
- script.execute: watchdog
|
|
|
|
|
on_client_disconnected:
|
|
|
|
|
- script.execute: watchdog
|
|
|
|
|
services:
|
|
|
|
|
# Dynamically configures button properties on a specified page, enhancing UI interactivity by allowing updates to button appearance and behavior based on given parameters.
|
|
|
|
|
- service: button # yamllint disable-line rule:indentation
|
|
|
|
|
@@ -1170,14 +1158,6 @@ binary_sensor:
|
|
|
|
|
lambda: |-
|
|
|
|
|
return disp1->is_setup();
|
|
|
|
|
|
|
|
|
|
##### API connection status
|
|
|
|
|
- name: Status
|
|
|
|
|
platform: status
|
|
|
|
|
id: api_status
|
|
|
|
|
on_state:
|
|
|
|
|
then:
|
|
|
|
|
- script.execute: watchdog
|
|
|
|
|
|
|
|
|
|
##### START - BUTTON CONFIGURATION #####
|
|
|
|
|
button:
|
|
|
|
|
###### Factory Reset button #####
|
|
|
|
|
@@ -2413,22 +2393,22 @@ script:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (not id(is_uploading_tft)) {
|
|
|
|
|
if (display_mode->state == 3) { // US Landscape model
|
|
|
|
|
if (id(button_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonLeft_Enabled) { // Left button
|
|
|
|
|
disp1->fill_area(467, 174, 3, 118, (id(button_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
disp1->fill_area(468, 173, 1, 120, (id(button_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
if (id(buttons_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonLeft_Enabled) { // Left button
|
|
|
|
|
disp1->fill_area(467, 174, 3, 118, (id(buttons_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
disp1->fill_area(468, 173, 1, 120, (id(buttons_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
}
|
|
|
|
|
if (id(button_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonRight_Enabled) { // Right button
|
|
|
|
|
disp1->fill_area(467, 28, 3, 118, (id(button_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
disp1->fill_area(468, 27, 1, 120, (id(button_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
if (id(buttons_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonRight_Enabled) { // Right button
|
|
|
|
|
disp1->fill_area(467, 28, 3, 118, (id(buttons_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
disp1->fill_area(468, 27, 1, 120, (id(buttons_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
}
|
|
|
|
|
} else { // US Portrait and EU models
|
|
|
|
|
if (id(button_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonLeft_Enabled) { // Left button
|
|
|
|
|
disp1->fill_area(48, 307, 118, 3, (id(button_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
disp1->fill_area(47, 308, 120, 1, (id(button_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
if (id(buttons_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonLeft_Enabled) { // Left button
|
|
|
|
|
disp1->fill_area(48, 307, 118, 3, (id(buttons_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
disp1->fill_area(47, 308, 120, 1, (id(buttons_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
}
|
|
|
|
|
if (id(button_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonRight_Enabled) { // Right button
|
|
|
|
|
disp1->fill_area(289, 307, 118, 3, (id(button_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
disp1->fill_area(288, 308, 120, 1, (id(button_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
if (id(buttons_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonRight_Enabled) { // Right button
|
|
|
|
|
disp1->fill_area(289, 307, 118, 3, (id(buttons_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
disp1->fill_area(288, 308, 120, 1, (id(buttons_settings) & nspanel_ha_blueprint::ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -2887,7 +2867,6 @@ script:
|
|
|
|
|
timer_sleep->stop();
|
|
|
|
|
update_alarm_icon->stop();
|
|
|
|
|
update_climate_icon->stop();
|
|
|
|
|
watchdog->stop();
|
|
|
|
|
ESP_LOGD(TAG, "Finished");
|
|
|
|
|
|
|
|
|
|
###### Timers ######
|
|
|
|
|
@@ -3103,113 +3082,4 @@ script:
|
|
|
|
|
disp1->set_component_font_color(component.c_str(), 1530); // cyan
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- id: watchdog
|
|
|
|
|
mode: restart
|
|
|
|
|
then:
|
|
|
|
|
- script.execute: refresh_relays
|
|
|
|
|
- lambda: |-
|
|
|
|
|
static const char *const TAG = "script.watchdog";
|
|
|
|
|
ESP_LOGV(TAG, "Starting");
|
|
|
|
|
if (id(is_uploading_tft)) {
|
|
|
|
|
ESP_LOGW(TAG, "TFT upload in progress");
|
|
|
|
|
} else {
|
|
|
|
|
// report Wi-Fi status
|
|
|
|
|
bool wifi_connected = wifi_component->is_connected();
|
|
|
|
|
if (wifi_connected) {
|
|
|
|
|
float rssi = wifi_rssi->state;
|
|
|
|
|
std::string rssi_status = "Unknown";
|
|
|
|
|
if (rssi > -50) rssi_status = "Excellent";
|
|
|
|
|
else if (rssi > -60) rssi_status = "Good";
|
|
|
|
|
else if (rssi > -70) rssi_status = "Fair";
|
|
|
|
|
else if (rssi > -80) rssi_status = "Weak";
|
|
|
|
|
else rssi_status = "Poor";
|
|
|
|
|
if (rssi > -70) ESP_LOGI(TAG, "Wi-Fi: %s (%.0f dBm)", rssi_status.c_str(), rssi);
|
|
|
|
|
else if (rssi > -80) ESP_LOGW(TAG, "Wi-Fi: %s (%.0f dBm)", rssi_status.c_str(), rssi);
|
|
|
|
|
else ESP_LOGE(TAG, "Wi-Fi: %s (%.0f dBm)", rssi_status.c_str(), rssi);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
ESP_LOGE(TAG, "Wi-Fi: DISCONNECTED");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// report API status
|
|
|
|
|
bool api_connected = api_server->is_connected();
|
|
|
|
|
if (api_connected) {
|
|
|
|
|
ESP_LOGI(TAG, "API: Connected");
|
|
|
|
|
} else {
|
|
|
|
|
ESP_LOGE(TAG, "API: DISCONNECTED");
|
|
|
|
|
blueprint_status->publish_state(0);
|
|
|
|
|
if (current_page->state != "blank" and
|
|
|
|
|
current_page->state != "boot" and
|
|
|
|
|
current_page->state != "home" and
|
|
|
|
|
current_page->state != "screensaver" and
|
|
|
|
|
current_page->state != "settings" and
|
|
|
|
|
current_page->state != "qrcode") {
|
|
|
|
|
ESP_LOGI(TAG, "Fallback to page Home");
|
|
|
|
|
goto_page->execute("home");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!wifi_connected or !api_connected) blueprint_status->publish_state(0);
|
|
|
|
|
|
|
|
|
|
// Report blueprint version
|
|
|
|
|
ESP_LOGI(TAG, "Blueprint:");
|
|
|
|
|
if (blueprint_status->state > 99) {
|
|
|
|
|
ESP_LOGI(TAG, " Version: %s", id(version_blueprint));
|
|
|
|
|
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",
|
|
|
|
|
{
|
|
|
|
|
{"type", "boot"},
|
|
|
|
|
{"step", "timeout"}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Report ESPHome
|
|
|
|
|
ESP_LOGI(TAG, "ESPHome:");
|
|
|
|
|
ESP_LOGI(TAG, " Version: ${version}");
|
|
|
|
|
// Report framework
|
|
|
|
|
#ifdef ARDUINO
|
|
|
|
|
ESP_LOGI(TAG, " Framework: Arduino");
|
|
|
|
|
size_t total_heap_size = ESP.getHeapSize();
|
|
|
|
|
size_t free_heap_size = ESP.getFreeHeap();
|
|
|
|
|
#elif defined(USE_ESP_IDF)
|
|
|
|
|
ESP_LOGI(TAG, " Framework: ESP-IDF");
|
|
|
|
|
size_t total_heap_size = heap_caps_get_total_size(MALLOC_CAP_DEFAULT);
|
|
|
|
|
size_t free_heap_size = esp_get_free_heap_size();
|
|
|
|
|
#endif
|
|
|
|
|
if (total_heap_size != 0)
|
|
|
|
|
ESP_LOGI(TAG, " Heap: %zu bytes (%d%%)", free_heap_size,
|
|
|
|
|
int(round(((float)free_heap_size / total_heap_size) * 100.0f)));
|
|
|
|
|
|
|
|
|
|
// Report UART
|
|
|
|
|
ESP_LOGI(TAG, "UART:");
|
|
|
|
|
ESP_LOGI(TAG, " Baud rate: %" PRIu32 " bps", tf_uart->get_baud_rate());
|
|
|
|
|
ESP_LOGI(TAG, " Queue size: %d", tf_uart->available());
|
|
|
|
|
|
|
|
|
|
// Report Nextion status
|
|
|
|
|
nextion_init->publish_state(nextion_init->state and disp1->is_setup());
|
|
|
|
|
ESP_LOGI(TAG, "Nextion:");
|
|
|
|
|
ESP_LOGI(TAG, " Queue size: %d", disp1->queue_size());
|
|
|
|
|
if (disp1->is_setup())
|
|
|
|
|
ESP_LOGI(TAG, " Is setup: True");
|
|
|
|
|
else {
|
|
|
|
|
ESP_LOGW(TAG, " Is setup: False");
|
|
|
|
|
ESP_LOGW(TAG, " Is detected: %s", YESNO(disp1->is_detected()));
|
|
|
|
|
}
|
|
|
|
|
if (nextion_init->state) {
|
|
|
|
|
ESP_LOGI(TAG, " Init: True");
|
|
|
|
|
} else
|
|
|
|
|
ESP_LOGW(TAG, " Init: False");
|
|
|
|
|
if (version_tft->state.empty())
|
|
|
|
|
ESP_LOGW(TAG, " TFT: UNKNOWN");
|
|
|
|
|
else
|
|
|
|
|
ESP_LOGI(TAG, " TFT: %s", version_tft->state.c_str());
|
|
|
|
|
}
|
|
|
|
|
refresh_wifi_icon->execute();
|
|
|
|
|
ESP_LOGV(TAG, "Finished");
|
|
|
|
|
...
|
|
|
|
|
|