This commit is contained in:
Edward Firmo
2023-12-07 01:37:57 +01:00
98 changed files with 442 additions and 883 deletions

View File

@@ -7,13 +7,14 @@
substitutions:
##### DON'T CHANGE THIS #####
version: "4.1.4"
version: "4.2dev"
#############################
#external_components:
# - source: github://pr#5825 # Remove this when that pr is merged and released
# components:
# - nextion
external_components:
- source: github://pr#5825 #5683 # Remove this when that pr is merged and released
components:
- nextion
refresh: 1s
##### ESPHOME CONFIGURATION #####
esphome:
@@ -32,8 +33,8 @@ esphome:
timeout: 60s
- wait_until:
condition:
- lambda: !lambda return disp1->is_setup();
timeout: 20s
- lambda: !lambda return disp1->is_detected();
timeout: 45s
- script.execute: exit_reparse
- wait_until:
condition:
@@ -190,9 +191,8 @@ api:
variables:
component: string
foreground: int[]
background: int[]
then:
- lambda: set_component_color->execute(component, foreground, background);
- lambda: set_component_color->execute(component, foreground, {});
##### Service to play a rtttl tones #####
# Example tones : https://codebender.cc/sketch:109888#RTTTL%20Songs.ino
@@ -492,30 +492,37 @@ api:
#### Service to set the buttons ####
- service: set_button
variables:
btn_id: string
btn_pic: int
btn_bg: int[]
btn_icon_font: int[]
btn_txt_font: int[]
btn_bri_font: int[]
btn_icon: string
btn_label: string
btn_bri_txt: string
page: string
id: string
pic: int
bg: int[]
icon: string
icon_color: int[]
bri: string
bri_color: int[]
label: string
label_color: int[]
then:
- lambda: |-
std::string btnicon = btn_id.c_str() + std::string("icon");
std::string btntext = btn_id.c_str() + std::string("text");
std::string btnbri = btn_id.c_str() + std::string("bri");
disp1->send_command_printf("%spic.pic=%" PRIu32, btn_id.c_str(), btn_pic);
set_component_color->execute(btnicon.c_str(), btn_icon_font, btn_bg);
set_component_color->execute(btntext.c_str(), btn_txt_font, btn_bg);
set_component_color->execute(btnbri.c_str(), btn_bri_font, btn_bg);
disp1->set_component_text_printf(btnicon.c_str(), "%s", btn_icon.c_str());
display_wrapped_text->execute(btntext.c_str(), btn_label.c_str(), 10);
if (strcmp(btn_bri_txt.c_str(), "0") != 0)
disp1->set_component_text_printf(btnbri.c_str(), "%s", btn_bri_txt.c_str());
else
disp1->set_component_text_printf(btnbri.c_str(), " ");
static const char *const TAG = "service.set_button";
if (page == current_page->state) {
std::string btnicon = id.c_str() + std::string("icon");
std::string btntext = id.c_str() + std::string("text");
std::string btnbri = id.c_str() + std::string("bri");
disp1->send_command_printf("%spic.pic=%" PRIu32, id.c_str(), pic);
set_component_color->execute(btnicon.c_str(), icon_color, bg);
set_component_color->execute(btntext.c_str(), label_color, bg);
set_component_color->execute(btnbri.c_str(), bri_color, bg);
disp1->set_component_text_printf(btnicon.c_str(), "%s", icon.c_str());
display_wrapped_text->execute(btntext.c_str(), label.c_str(), 10);
if (strcmp(bri.c_str(), "0") != 0)
disp1->set_component_text_printf(btnbri.c_str(), "%s", bri.c_str());
else
disp1->set_component_text_printf(btnbri.c_str(), " ");
} else {
ESP_LOGW(TAG, "Skipping button `%s.%s` as page has changed to %s.", page.c_str(), id.c_str(), current_page->state.c_str());
}
##### SERVICE TO WAKE UP THE DISPLAY #####
- service: wake_up
@@ -753,11 +760,14 @@ display:
platform: nextion
uart_id: tf_uart
start_up_page: 8
on_page: # This requires `sendme` to be executed on Nextion side
on_page:
lambda: |-
static const char *const TAG = "display.disp1.on_page";
ESP_LOGD(TAG, "Nextion page changed");
ESP_LOGD(TAG, "New page: %s (%i)" , id(page_names)[x].c_str(), x);
current_page->publish_state(id(page_names)[x].c_str());
page_changed->execute(id(page_names)[x].c_str());
on_setup:
- script.execute: boot_sequence
@@ -1403,25 +1413,25 @@ text_sensor:
##### Current page name #####
- name: ${device_name} Current page
id: current_page
#platform: template
platform: nextion
nextion_id: disp1
component_name: currentpage
platform: template
#platform: nextion
#nextion_id: disp1
#component_name: currentpage
icon: mdi:tablet-dashboard
internal: false
disabled_by_default: false
filters:
- lambda: |-
x = x.c_str();
x.shrink_to_fit();
return x;
on_value:
then:
- lambda: |-
static const char *const TAG = "text_sensor.current_page";
// Construct new page
ESP_LOGV(TAG, "Construct new page");
page_changed->execute(x.c_str());
#filters:
# - lambda: |-
# x = x.c_str();
# x.shrink_to_fit();
# return x;
#on_value:
# then:
# - lambda: |-
# static const char *const TAG = "text_sensor.current_page";
# // Construct new page
# ESP_LOGV(TAG, "Construct new page");
# page_changed->execute(x.c_str());
- name: ${device_name} Notification Label
platform: template