|
|
|
|
@@ -150,7 +150,9 @@ api:
|
|
|
|
|
variables:
|
|
|
|
|
cmd: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: 'disp1->send_command_printf("%s", cmd.c_str());'
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (!id(is_uploading_tft))
|
|
|
|
|
disp1->send_command_printf("%s", cmd.c_str());
|
|
|
|
|
|
|
|
|
|
##### Service to send a command "text_printf" directly to the display #####
|
|
|
|
|
- service: send_command_text_printf
|
|
|
|
|
@@ -158,7 +160,9 @@ api:
|
|
|
|
|
component: string
|
|
|
|
|
message: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: 'disp1->set_component_text_printf(component.c_str(), "%s", message.c_str());'
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (!id(is_uploading_tft))
|
|
|
|
|
disp1->set_component_text_printf(component.c_str(), "%s", message.c_str());
|
|
|
|
|
|
|
|
|
|
##### Service to send a command "component_value (Dualstate Button)" directly to the display #####
|
|
|
|
|
- service: send_command_value
|
|
|
|
|
@@ -167,21 +171,26 @@ api:
|
|
|
|
|
val: int
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
disp1->set_component_value(component.c_str(), val);
|
|
|
|
|
if (!id(is_uploading_tft))
|
|
|
|
|
disp1->set_component_value(component.c_str(), val);
|
|
|
|
|
|
|
|
|
|
##### Service to send a command "hide componente" directly to the display #####
|
|
|
|
|
- service: send_command_hide
|
|
|
|
|
variables:
|
|
|
|
|
component: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: 'disp1->hide_component(component.c_str());'
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (!id(is_uploading_tft))
|
|
|
|
|
disp1->hide_component(component.c_str());
|
|
|
|
|
|
|
|
|
|
##### Service to send a command "show componente" directly to the display #####
|
|
|
|
|
- service: send_command_show
|
|
|
|
|
variables:
|
|
|
|
|
component: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: 'disp1->show_component(component.c_str());'
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (!id(is_uploading_tft))
|
|
|
|
|
disp1->show_component(component.c_str());
|
|
|
|
|
|
|
|
|
|
##### Service to send a command "font color" directly to the display #####
|
|
|
|
|
- service: set_component_color
|
|
|
|
|
@@ -189,7 +198,9 @@ api:
|
|
|
|
|
component: string
|
|
|
|
|
foreground: int[]
|
|
|
|
|
then:
|
|
|
|
|
- lambda: set_component_color->execute(component, foreground);
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (!id(is_uploading_tft))
|
|
|
|
|
set_component_color->execute(component, foreground);
|
|
|
|
|
|
|
|
|
|
##### Service to play a rtttl tones #####
|
|
|
|
|
# Example tones : https://codebender.cc/sketch:109888#RTTTL%20Songs.ino
|
|
|
|
|
@@ -213,7 +224,7 @@ api:
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
// Is page Alarm visible?
|
|
|
|
|
if (current_page->state == "alarm") // To do: This page constructor should be moved to Blueprint
|
|
|
|
|
if (current_page->state == "alarm" and not id(is_uploading_tft)) // To do: This page constructor should be moved to Blueprint
|
|
|
|
|
{ // Update alarm page
|
|
|
|
|
detailed_entity->publish_state(entity);
|
|
|
|
|
|
|
|
|
|
@@ -347,19 +358,21 @@ api:
|
|
|
|
|
message: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
ESP_LOGV("service.notification_show", "Starting");
|
|
|
|
|
if (!id(is_uploading_tft)) {
|
|
|
|
|
ESP_LOGV("service.notification_show", "Starting");
|
|
|
|
|
|
|
|
|
|
disp1->goto_page("notification");
|
|
|
|
|
disp1->set_component_text_printf("notification.notifi_label", "%s", label.c_str());
|
|
|
|
|
disp1->goto_page("notification");
|
|
|
|
|
disp1->set_component_text_printf("notification.notifi_label", "%s", label.c_str());
|
|
|
|
|
|
|
|
|
|
display_wrapped_text->execute("notification.notifi_text01", message.c_str(), display_mode->state == 2 ? 23 : 32);
|
|
|
|
|
display_wrapped_text->execute("notification.notifi_text01", message.c_str(), display_mode->state == 2 ? 23 : 32);
|
|
|
|
|
|
|
|
|
|
notification_label->publish_state(label.c_str());
|
|
|
|
|
notification_text->publish_state(message.c_str());
|
|
|
|
|
timer_reset_all->execute(current_page->state.c_str());
|
|
|
|
|
refresh_notification->execute();
|
|
|
|
|
notification_unread->turn_on();
|
|
|
|
|
if (notification_sound->state) buzzer->play("two short:d=4,o=5,b=100:16e6,16e6");
|
|
|
|
|
notification_label->publish_state(label.c_str());
|
|
|
|
|
notification_text->publish_state(message.c_str());
|
|
|
|
|
timer_reset_all->execute(current_page->state.c_str());
|
|
|
|
|
refresh_notification->execute();
|
|
|
|
|
notification_unread->turn_on();
|
|
|
|
|
if (notification_sound->state) buzzer->play("two short:d=4,o=5,b=100:16e6,16e6");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
##### Service to clear the notification #####
|
|
|
|
|
- service: notification_clear
|
|
|
|
|
@@ -393,9 +406,11 @@ api:
|
|
|
|
|
show: bool
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
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");
|
|
|
|
|
if (!id(is_uploading_tft)) {
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#### Service to set climate state ####
|
|
|
|
|
- service: set_climate
|
|
|
|
|
@@ -412,20 +427,24 @@ api:
|
|
|
|
|
embedded_climate: bool
|
|
|
|
|
entity: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (current_page->state == "climate") detailed_entity->publish_state(entity);
|
|
|
|
|
- script.execute:
|
|
|
|
|
id: set_climate
|
|
|
|
|
current_temp: !lambda "return current_temp;"
|
|
|
|
|
supported_features: !lambda "return supported_features;"
|
|
|
|
|
target_temp: !lambda "return target_temp;"
|
|
|
|
|
target_temp_high: !lambda "return target_temp_high;"
|
|
|
|
|
target_temp_low: !lambda "return target_temp_low;"
|
|
|
|
|
temp_step: !lambda "return temp_step;"
|
|
|
|
|
total_steps: !lambda "return total_steps;"
|
|
|
|
|
temp_offset: !lambda "return temp_offset;"
|
|
|
|
|
climate_icon: !lambda "return climate_icon;"
|
|
|
|
|
embedded_climate: !lambda "return embedded_climate;"
|
|
|
|
|
- if:
|
|
|
|
|
condition:
|
|
|
|
|
lambda: 'return not id(is_uploading_tft);'
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (current_page->state == "climate") detailed_entity->publish_state(entity);
|
|
|
|
|
- script.execute:
|
|
|
|
|
id: set_climate
|
|
|
|
|
current_temp: !lambda "return current_temp;"
|
|
|
|
|
supported_features: !lambda "return supported_features;"
|
|
|
|
|
target_temp: !lambda "return target_temp;"
|
|
|
|
|
target_temp_high: !lambda "return target_temp_high;"
|
|
|
|
|
target_temp_low: !lambda "return target_temp_low;"
|
|
|
|
|
temp_step: !lambda "return temp_step;"
|
|
|
|
|
total_steps: !lambda "return total_steps;"
|
|
|
|
|
temp_offset: !lambda "return temp_offset;"
|
|
|
|
|
climate_icon: !lambda "return climate_icon;"
|
|
|
|
|
embedded_climate: !lambda "return embedded_climate;"
|
|
|
|
|
|
|
|
|
|
#### Service to set the buttons ####
|
|
|
|
|
- service: set_button
|
|
|
|
|
@@ -440,11 +459,11 @@ api:
|
|
|
|
|
label: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
static const char *const TAG = "service.set_button";
|
|
|
|
|
if (page == current_page->state) {
|
|
|
|
|
if (page == current_page->state and not id(is_uploading_tft)) {
|
|
|
|
|
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");
|
|
|
|
|
std::string btnpic = id.c_str() + std::string("pic");
|
|
|
|
|
uint8_t bg_pic = state ? 47 : 46;
|
|
|
|
|
uint16_t txt_color = state ? 10597 : 65535;
|
|
|
|
|
disp1->send_command_printf("%spic.picc=%u", id.c_str(), bg_pic);
|
|
|
|
|
@@ -461,8 +480,13 @@ api:
|
|
|
|
|
disp1->set_component_text_printf(btnbri.c_str(), "%s", bri.c_str());
|
|
|
|
|
else
|
|
|
|
|
disp1->set_component_text_printf(btnbri.c_str(), " ");
|
|
|
|
|
disp1->show_component(btnpic.c_str());
|
|
|
|
|
disp1->show_component(btnicon.c_str());
|
|
|
|
|
disp1->show_component(btntext.c_str());
|
|
|
|
|
disp1->show_component(btnbri.c_str());
|
|
|
|
|
disp1->show_component(id.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());
|
|
|
|
|
ESP_LOGW("service.set_button", "Skipping button `%s.%s` update.", page.c_str(), id.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
##### SERVICE TO WAKE UP THE DISPLAY #####
|
|
|
|
|
@@ -471,12 +495,14 @@ api:
|
|
|
|
|
reset_timer: bool
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (current_page->state == "screensaver") disp1->goto_page(wakeup_page_name->state.c_str());
|
|
|
|
|
if (reset_timer)
|
|
|
|
|
timer_reset_all->execute(wakeup_page_name->state.c_str());
|
|
|
|
|
else {
|
|
|
|
|
timer_sleep->execute(wakeup_page_name->state.c_str(), int(timeout_sleep->state));
|
|
|
|
|
timer_dim->execute(wakeup_page_name->state.c_str(), int(timeout_dim->state));
|
|
|
|
|
if (not id(is_uploading_tft)) {
|
|
|
|
|
if (current_page->state == "screensaver") disp1->goto_page(wakeup_page_name->state.c_str());
|
|
|
|
|
if (reset_timer)
|
|
|
|
|
timer_reset_all->execute(wakeup_page_name->state.c_str());
|
|
|
|
|
else {
|
|
|
|
|
timer_sleep->execute(wakeup_page_name->state.c_str(), int(timeout_sleep->state));
|
|
|
|
|
timer_dim->execute(wakeup_page_name->state.c_str(), int(timeout_dim->state));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#### Service to set the entities ####
|
|
|
|
|
@@ -489,14 +515,16 @@ api:
|
|
|
|
|
ent_value_xcen: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
std::string enticon = ent_id.c_str() + std::string("_pic");
|
|
|
|
|
std::string entlabel = ent_id.c_str() + std::string("_label");
|
|
|
|
|
std::string entxcen = ent_id.c_str() + std::string(".xcen=") + ent_value_xcen.c_str();
|
|
|
|
|
disp1->set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
|
|
|
|
|
if (strcmp(ent_icon.c_str(), "0") != 0) disp1->set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
|
|
|
|
|
disp1->set_component_text_printf(entlabel.c_str(), "%s", ent_label.c_str());
|
|
|
|
|
disp1->set_component_text_printf(ent_id.c_str(), "%s", ent_value.c_str());
|
|
|
|
|
if (strcmp(ent_value_xcen.c_str(), "0") != 0) disp1->send_command_printf("%s", entxcen.c_str());
|
|
|
|
|
if (not id(is_uploading_tft)) {
|
|
|
|
|
std::string enticon = ent_id.c_str() + std::string("_pic");
|
|
|
|
|
std::string entlabel = ent_id.c_str() + std::string("_label");
|
|
|
|
|
std::string entxcen = ent_id.c_str() + std::string(".xcen=") + ent_value_xcen.c_str();
|
|
|
|
|
disp1->set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
|
|
|
|
|
if (strcmp(ent_icon.c_str(), "0") != 0) disp1->set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
|
|
|
|
|
disp1->set_component_text_printf(entlabel.c_str(), "%s", ent_label.c_str());
|
|
|
|
|
disp1->set_component_text_printf(ent_id.c_str(), "%s", ent_value.c_str());
|
|
|
|
|
if (strcmp(ent_value_xcen.c_str(), "0") != 0) disp1->send_command_printf("%s", entxcen.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#### Service to populate the page Home #####
|
|
|
|
|
- service: page_home
|
|
|
|
|
@@ -518,73 +546,75 @@ api:
|
|
|
|
|
entities_pages_icon_color: int[]
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
static const char *const TAG = "service.page_home";
|
|
|
|
|
ESP_LOGV(TAG, "date_color: %" PRIi32, date_color);
|
|
|
|
|
ESP_LOGV(TAG, "time_format: %s", time_format.c_str());
|
|
|
|
|
ESP_LOGV(TAG, "time_color: %" PRIi32, time_color);
|
|
|
|
|
ESP_LOGV(TAG, "meridiem: %i", meridiem.size());
|
|
|
|
|
ESP_LOGV(TAG, "chip_font_size: %" PRIi32, chip_font_size);
|
|
|
|
|
ESP_LOGV(TAG, "custom_buttons_font_size: %" PRIi32, custom_buttons_font_size);
|
|
|
|
|
ESP_LOGV(TAG, "notification_icon: %s", notification_icon.c_str());
|
|
|
|
|
ESP_LOGV(TAG, "notification_icon_color_normal: %i", notification_icon_color_normal.size());
|
|
|
|
|
ESP_LOGV(TAG, "notification_icon_color_unread: %i", notification_icon_color_unread.size());
|
|
|
|
|
ESP_LOGV(TAG, "qrcode: %s", qrcode ? "True" : "False");
|
|
|
|
|
ESP_LOGV(TAG, "qrcode_icon: %s", qrcode_icon.c_str());
|
|
|
|
|
ESP_LOGV(TAG, "qrcode_icon_color: %i", qrcode_icon_color.size());
|
|
|
|
|
ESP_LOGV(TAG, "entities_pages: %s", entities_pages ? "True" : "False");
|
|
|
|
|
ESP_LOGV(TAG, "entities_pages_icon: %s", entities_pages_icon.c_str());
|
|
|
|
|
ESP_LOGV(TAG, "entities_pages_icon_color: %i", entities_pages_icon_color.size());
|
|
|
|
|
if (not id(is_uploading_tft)) {
|
|
|
|
|
static const char *const TAG = "service.page_home";
|
|
|
|
|
ESP_LOGV(TAG, "date_color: %" PRIi32, date_color);
|
|
|
|
|
ESP_LOGV(TAG, "time_format: %s", time_format.c_str());
|
|
|
|
|
ESP_LOGV(TAG, "time_color: %" PRIi32, time_color);
|
|
|
|
|
ESP_LOGV(TAG, "meridiem: %i", meridiem.size());
|
|
|
|
|
ESP_LOGV(TAG, "chip_font_size: %" PRIi32, chip_font_size);
|
|
|
|
|
ESP_LOGV(TAG, "custom_buttons_font_size: %" PRIi32, custom_buttons_font_size);
|
|
|
|
|
ESP_LOGV(TAG, "notification_icon: %s", notification_icon.c_str());
|
|
|
|
|
ESP_LOGV(TAG, "notification_icon_color_normal: %i", notification_icon_color_normal.size());
|
|
|
|
|
ESP_LOGV(TAG, "notification_icon_color_unread: %i", notification_icon_color_unread.size());
|
|
|
|
|
ESP_LOGV(TAG, "qrcode: %s", qrcode ? "True" : "False");
|
|
|
|
|
ESP_LOGV(TAG, "qrcode_icon: %s", qrcode_icon.c_str());
|
|
|
|
|
ESP_LOGV(TAG, "qrcode_icon_color: %i", qrcode_icon_color.size());
|
|
|
|
|
ESP_LOGV(TAG, "entities_pages: %s", entities_pages ? "True" : "False");
|
|
|
|
|
ESP_LOGV(TAG, "entities_pages_icon: %s", entities_pages_icon.c_str());
|
|
|
|
|
ESP_LOGV(TAG, "entities_pages_icon_color: %i", entities_pages_icon_color.size());
|
|
|
|
|
|
|
|
|
|
// Localization
|
|
|
|
|
ESP_LOGV(TAG, "Load localization");
|
|
|
|
|
id(mui_time_format) = time_format;
|
|
|
|
|
id(mui_meridiem) = meridiem;
|
|
|
|
|
// Localization
|
|
|
|
|
ESP_LOGV(TAG, "Load localization");
|
|
|
|
|
id(mui_time_format) = time_format;
|
|
|
|
|
id(mui_meridiem) = meridiem;
|
|
|
|
|
|
|
|
|
|
// Date/Time colors
|
|
|
|
|
ESP_LOGV(TAG, "Load date/time colors");
|
|
|
|
|
disp1->set_component_font_color("home.date", date_color);
|
|
|
|
|
disp1->set_component_font_color("home.time", time_color);
|
|
|
|
|
id(home_date_color) = date_color;
|
|
|
|
|
id(home_time_color) = time_color;
|
|
|
|
|
// Date/Time colors
|
|
|
|
|
ESP_LOGV(TAG, "Load date/time colors");
|
|
|
|
|
disp1->set_component_font_color("home.date", date_color);
|
|
|
|
|
disp1->set_component_font_color("home.time", time_color);
|
|
|
|
|
id(home_date_color) = date_color;
|
|
|
|
|
id(home_time_color) = time_color;
|
|
|
|
|
|
|
|
|
|
// Chips icon size
|
|
|
|
|
ESP_LOGV(TAG, "Chips size");
|
|
|
|
|
for (int i = 1; i <= 10; ++i) {
|
|
|
|
|
disp1->send_command_printf("home.icon_top_%02d.font=%" PRIu32, i, chip_font_size);
|
|
|
|
|
// Chips icon size
|
|
|
|
|
ESP_LOGV(TAG, "Chips size");
|
|
|
|
|
for (int i = 1; i <= 10; ++i) {
|
|
|
|
|
disp1->send_command_printf("home.icon_top_%02d.font=%" PRIu32, i, chip_font_size);
|
|
|
|
|
}
|
|
|
|
|
disp1->send_command_printf("home.wifi_icon.font=%" PRIu32, chip_font_size);
|
|
|
|
|
id(home_chip_font_size) = chip_font_size;
|
|
|
|
|
|
|
|
|
|
// Custom buttons icon size
|
|
|
|
|
ESP_LOGV(TAG, "Custom buttons sizes");
|
|
|
|
|
id(home_custom_buttons_font_size) = custom_buttons_font_size;
|
|
|
|
|
for (int i = 1; i <= 7; ++i) {
|
|
|
|
|
disp1->send_command_printf("home.button%02d.font=%i", i, id(home_custom_buttons_font_size));
|
|
|
|
|
}
|
|
|
|
|
disp1->send_command_printf("home.bt_notific.font=%i", id(home_custom_buttons_font_size));
|
|
|
|
|
disp1->send_command_printf("home.bt_qrcode.font=%i", id(home_custom_buttons_font_size));
|
|
|
|
|
disp1->send_command_printf("home.bt_entities.font=%i", id(home_custom_buttons_font_size));
|
|
|
|
|
|
|
|
|
|
// Notification button
|
|
|
|
|
ESP_LOGV(TAG, "Set Notification button");
|
|
|
|
|
disp1->send_command_printf("is_notification=%i", (notification_text->state.empty() and notification_label->state.empty()) ? 0 : 1);
|
|
|
|
|
disp1->set_component_text_printf("home.bt_notific", "%s", notification_icon.c_str());
|
|
|
|
|
set_component_color->execute("home.bt_notific", notification_unread->state ? notification_icon_color_unread : notification_icon_color_normal);
|
|
|
|
|
id(home_notify_icon_color_normal) = notification_icon_color_normal;
|
|
|
|
|
id(home_notify_icon_color_unread) = notification_icon_color_unread;
|
|
|
|
|
|
|
|
|
|
// QRCode button
|
|
|
|
|
ESP_LOGV(TAG, "Set QRCode button");
|
|
|
|
|
disp1->send_command_printf("is_qrcode=%i", qrcode ? 1 : 0);
|
|
|
|
|
disp1->set_component_text_printf("home.bt_qrcode", "%s", qrcode_icon.c_str());
|
|
|
|
|
set_component_color->execute("home.bt_qrcode", qrcode_icon_color);
|
|
|
|
|
|
|
|
|
|
// Entities pages button
|
|
|
|
|
ESP_LOGV(TAG, "Set Entities button");
|
|
|
|
|
disp1->send_command_printf("is_entities=%i", entities_pages ? 1 : 0);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
disp1->send_command_printf("home.wifi_icon.font=%" PRIu32, chip_font_size);
|
|
|
|
|
id(home_chip_font_size) = chip_font_size;
|
|
|
|
|
|
|
|
|
|
// Custom buttons icon size
|
|
|
|
|
ESP_LOGV(TAG, "Custom buttons sizes");
|
|
|
|
|
id(home_custom_buttons_font_size) = custom_buttons_font_size;
|
|
|
|
|
for (int i = 1; i <= 7; ++i) {
|
|
|
|
|
disp1->send_command_printf("home.button%02d.font=%i", i, id(home_custom_buttons_font_size));
|
|
|
|
|
}
|
|
|
|
|
disp1->send_command_printf("home.bt_notific.font=%i", id(home_custom_buttons_font_size));
|
|
|
|
|
disp1->send_command_printf("home.bt_qrcode.font=%i", id(home_custom_buttons_font_size));
|
|
|
|
|
disp1->send_command_printf("home.bt_entities.font=%i", id(home_custom_buttons_font_size));
|
|
|
|
|
|
|
|
|
|
// Notification button
|
|
|
|
|
ESP_LOGV(TAG, "Set Notification button");
|
|
|
|
|
disp1->send_command_printf("is_notification=%i", (notification_text->state.empty() and notification_label->state.empty()) ? 0 : 1);
|
|
|
|
|
disp1->set_component_text_printf("home.bt_notific", "%s", notification_icon.c_str());
|
|
|
|
|
set_component_color->execute("home.bt_notific", notification_unread->state ? notification_icon_color_unread : notification_icon_color_normal);
|
|
|
|
|
id(home_notify_icon_color_normal) = notification_icon_color_normal;
|
|
|
|
|
id(home_notify_icon_color_unread) = notification_icon_color_unread;
|
|
|
|
|
|
|
|
|
|
// QRCode button
|
|
|
|
|
ESP_LOGV(TAG, "Set QRCode button");
|
|
|
|
|
disp1->send_command_printf("is_qrcode=%i", qrcode ? 1 : 0);
|
|
|
|
|
disp1->set_component_text_printf("home.bt_qrcode", "%s", qrcode_icon.c_str());
|
|
|
|
|
set_component_color->execute("home.bt_qrcode", qrcode_icon_color);
|
|
|
|
|
|
|
|
|
|
// Entities pages button
|
|
|
|
|
ESP_LOGV(TAG, "Set Entities button");
|
|
|
|
|
disp1->send_command_printf("is_entities=%i", entities_pages ? 1 : 0);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
#### Service to populate the page Settings #####
|
|
|
|
|
- service: page_settings
|
|
|
|
|
@@ -595,10 +625,12 @@ api:
|
|
|
|
|
dim: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (not reboot.empty()) disp1->set_component_text_printf("settings.lbl_reboot", " %s", reboot.c_str());
|
|
|
|
|
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);
|
|
|
|
|
if (not id(is_uploading_tft)) {
|
|
|
|
|
if (not reboot.empty()) disp1->set_component_text_printf("settings.lbl_reboot", " %s", reboot.c_str());
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#### Service to populate the media player page #####
|
|
|
|
|
- service: media_player
|
|
|
|
|
@@ -616,106 +648,85 @@ api:
|
|
|
|
|
supported_features: int
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (current_page->state == "media_player")
|
|
|
|
|
{
|
|
|
|
|
detailed_entity->publish_state(entity);
|
|
|
|
|
disp1->set_component_text_printf("page_label", "%s", friendly_name.c_str());
|
|
|
|
|
display_wrapped_text->execute("track", media_title.c_str(), display_mode->state == 2 ? 16 : 27);
|
|
|
|
|
display_wrapped_text->execute("artist", media_artist.c_str(), display_mode->state == 2 ? 26 : 40);
|
|
|
|
|
if (current_page->state == "media_player" and not id(is_uploading_tft)) {
|
|
|
|
|
detailed_entity->publish_state(entity);
|
|
|
|
|
disp1->set_component_text_printf("page_label", "%s", friendly_name.c_str());
|
|
|
|
|
display_wrapped_text->execute("track", media_title.c_str(), display_mode->state == 2 ? 16 : 27);
|
|
|
|
|
display_wrapped_text->execute("artist", media_artist.c_str(), display_mode->state == 2 ? 26 : 40);
|
|
|
|
|
|
|
|
|
|
// on/off button
|
|
|
|
|
if (supported_features & 128 and state == "off") //TURN_ON
|
|
|
|
|
{
|
|
|
|
|
disp1->set_component_foreground_color("bt_on_off", 65535);
|
|
|
|
|
disp1->show_component("bt_on_off");
|
|
|
|
|
}
|
|
|
|
|
else if (supported_features & 256 and state != "off") //TURN_OFF
|
|
|
|
|
{
|
|
|
|
|
disp1->set_component_foreground_color("bt_on_off", 10597);
|
|
|
|
|
disp1->show_component("bt_on_off");
|
|
|
|
|
}
|
|
|
|
|
else disp1->hide_component("bt_on_off");
|
|
|
|
|
// on/off button
|
|
|
|
|
if (supported_features & 128 and state == "off") { //TURN_ON
|
|
|
|
|
disp1->set_component_foreground_color("bt_on_off", 65535);
|
|
|
|
|
disp1->show_component("bt_on_off");
|
|
|
|
|
} else if (supported_features & 256 and state != "off") { //TURN_OFF
|
|
|
|
|
disp1->set_component_foreground_color("bt_on_off", 10597);
|
|
|
|
|
disp1->show_component("bt_on_off");
|
|
|
|
|
} else disp1->hide_component("bt_on_off");
|
|
|
|
|
|
|
|
|
|
// play/pause button
|
|
|
|
|
if ((supported_features & 512 or supported_features & 16384) and state != "playing" and state != "off") //PLAY_MEDIA+PLAY
|
|
|
|
|
{
|
|
|
|
|
disp1->set_component_text_printf("bt_play_pause", "%s", "\uE409"); // mdi:play
|
|
|
|
|
disp1->show_component("bt_play_pause");
|
|
|
|
|
}
|
|
|
|
|
else if (supported_features & 1 and state == "playing" ) //PAUSE
|
|
|
|
|
{
|
|
|
|
|
disp1->set_component_text_printf("bt_play_pause", "%s", "\uE3E3"); // mdi:pause
|
|
|
|
|
disp1->show_component("bt_play_pause");
|
|
|
|
|
}
|
|
|
|
|
else disp1->hide_component("bt_play_pause");
|
|
|
|
|
// play/pause button
|
|
|
|
|
if ((supported_features & 512 or supported_features & 16384) and state != "playing" and state != "off") { //PLAY_MEDIA+PLAY
|
|
|
|
|
disp1->set_component_text_printf("bt_play_pause", "%s", "\uE409"); // mdi:play
|
|
|
|
|
disp1->show_component("bt_play_pause");
|
|
|
|
|
} else if (supported_features & 1 and state == "playing" ) { //PAUSE
|
|
|
|
|
disp1->set_component_text_printf("bt_play_pause", "%s", "\uE3E3"); // mdi:pause
|
|
|
|
|
disp1->show_component("bt_play_pause");
|
|
|
|
|
} else disp1->hide_component("bt_play_pause");
|
|
|
|
|
|
|
|
|
|
// bt_prev button - PREVIOUS_TRACK
|
|
|
|
|
if (supported_features & 16 and state != "off") disp1->show_component("bt_prev"); else disp1->hide_component("bt_prev");
|
|
|
|
|
// bt_next button - NEXT_TRACK
|
|
|
|
|
if (supported_features & 32 and state != "off") disp1->show_component("bt_next"); else disp1->hide_component("bt_next");
|
|
|
|
|
// bt_prev button - PREVIOUS_TRACK
|
|
|
|
|
if (supported_features & 16 and state != "off") disp1->show_component("bt_prev"); else disp1->hide_component("bt_prev");
|
|
|
|
|
// bt_next button - NEXT_TRACK
|
|
|
|
|
if (supported_features & 32 and state != "off") disp1->show_component("bt_next"); else disp1->hide_component("bt_next");
|
|
|
|
|
|
|
|
|
|
// Stop button - STOP
|
|
|
|
|
//if (supported_features & 4096 and (state == "playing" or state == "paused")) disp1->show_component("bt_stop"); else disp1->hide_component("bt_stop");
|
|
|
|
|
// Stop button - STOP
|
|
|
|
|
//if (supported_features & 4096 and (state == "playing" or state == "paused")) disp1->show_component("bt_stop"); else disp1->hide_component("bt_stop");
|
|
|
|
|
|
|
|
|
|
// mute/unmute button - VOLUME_MUTE
|
|
|
|
|
disp1->set_component_value("is_muted", is_volume_muted ? 1 : 0);
|
|
|
|
|
if (supported_features & 8 and is_volume_muted) // unmute
|
|
|
|
|
{
|
|
|
|
|
disp1->set_component_text_printf("bt_mute", "%s", "\uEE07"); // mdi:volume-variant-off
|
|
|
|
|
disp1->show_component("bt_mute");
|
|
|
|
|
}
|
|
|
|
|
else if (supported_features & 8) // mute
|
|
|
|
|
{
|
|
|
|
|
disp1->set_component_text_printf("bt_mute", "%s", "\uE57E"); // mdi:volume-low
|
|
|
|
|
disp1->show_component("bt_mute");
|
|
|
|
|
}
|
|
|
|
|
else disp1->hide_component("bt_mute");
|
|
|
|
|
// mute/unmute button - VOLUME_MUTE
|
|
|
|
|
disp1->set_component_value("is_muted", is_volume_muted ? 1 : 0);
|
|
|
|
|
if (supported_features & 8 and is_volume_muted) { // unmute
|
|
|
|
|
disp1->set_component_text_printf("bt_mute", "%s", "\uEE07"); // mdi:volume-variant-off
|
|
|
|
|
disp1->show_component("bt_mute");
|
|
|
|
|
} else if (supported_features & 8) { // mute
|
|
|
|
|
disp1->set_component_text_printf("bt_mute", "%s", "\uE57E"); // mdi:volume-low
|
|
|
|
|
disp1->show_component("bt_mute");
|
|
|
|
|
} else disp1->hide_component("bt_mute");
|
|
|
|
|
|
|
|
|
|
// VOLUME_SET
|
|
|
|
|
if (supported_features & 4)
|
|
|
|
|
{
|
|
|
|
|
if (volume_level != id(last_volume_level))
|
|
|
|
|
{
|
|
|
|
|
id(last_volume_level) = volume_level;
|
|
|
|
|
disp1->set_component_text_printf("vol_text", "%" PRIu32 "%%", volume_level);
|
|
|
|
|
disp1->set_component_value("vol_slider", volume_level);
|
|
|
|
|
}
|
|
|
|
|
disp1->show_component("vol_slider");
|
|
|
|
|
disp1->show_component("bt_vol_down");
|
|
|
|
|
disp1->show_component("bt_vol_up");
|
|
|
|
|
disp1->show_component("vol_text");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
disp1->hide_component("vol_slider");
|
|
|
|
|
disp1->hide_component("bt_vol_down");
|
|
|
|
|
disp1->hide_component("bt_vol_up");
|
|
|
|
|
disp1->hide_component("vol_text");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (media_duration > 0)
|
|
|
|
|
{
|
|
|
|
|
if (media_duration != id(last_media_duration) or media_position != id(last_media_position))
|
|
|
|
|
{
|
|
|
|
|
id(last_media_duration) = media_duration;
|
|
|
|
|
id(last_media_position) = media_position;
|
|
|
|
|
disp1->set_component_value("prg_current", int(round(min(media_position + media_position_delta, media_duration))));
|
|
|
|
|
}
|
|
|
|
|
disp1->set_component_value("prg_total", int(round(media_duration)));
|
|
|
|
|
disp1->send_command_printf("prg_timer.en=%i", (state == "playing") ? 1 : 0);
|
|
|
|
|
disp1->show_component("time_current");
|
|
|
|
|
disp1->show_component("time_total");
|
|
|
|
|
disp1->show_component("time_progress");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
disp1->send_command_printf("prg_timer.en=0");
|
|
|
|
|
disp1->hide_component("time_current");
|
|
|
|
|
disp1->hide_component("time_total");
|
|
|
|
|
disp1->hide_component("time_progress");
|
|
|
|
|
}
|
|
|
|
|
// VOLUME_SET
|
|
|
|
|
if (supported_features & 4) {
|
|
|
|
|
if (volume_level != id(last_volume_level)) {
|
|
|
|
|
id(last_volume_level) = volume_level;
|
|
|
|
|
disp1->set_component_text_printf("vol_text", "%" PRIu32 "%%", volume_level);
|
|
|
|
|
disp1->set_component_value("vol_slider", volume_level);
|
|
|
|
|
}
|
|
|
|
|
disp1->show_component("vol_slider");
|
|
|
|
|
disp1->show_component("bt_vol_down");
|
|
|
|
|
disp1->show_component("bt_vol_up");
|
|
|
|
|
disp1->show_component("vol_text");
|
|
|
|
|
} else {
|
|
|
|
|
disp1->hide_component("vol_slider");
|
|
|
|
|
disp1->hide_component("bt_vol_down");
|
|
|
|
|
disp1->hide_component("bt_vol_up");
|
|
|
|
|
disp1->hide_component("vol_text");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (media_duration > 0) {
|
|
|
|
|
if (media_duration != id(last_media_duration) or media_position != id(last_media_position)) {
|
|
|
|
|
id(last_media_duration) = media_duration;
|
|
|
|
|
id(last_media_position) = media_position;
|
|
|
|
|
disp1->set_component_value("prg_current", int(round(min(media_position + media_position_delta, media_duration))));
|
|
|
|
|
}
|
|
|
|
|
disp1->set_component_value("prg_total", int(round(media_duration)));
|
|
|
|
|
disp1->send_command_printf("prg_timer.en=%i", (state == "playing") ? 1 : 0);
|
|
|
|
|
disp1->show_component("time_current");
|
|
|
|
|
disp1->show_component("time_total");
|
|
|
|
|
disp1->show_component("time_progress");
|
|
|
|
|
} else {
|
|
|
|
|
disp1->send_command_printf("prg_timer.en=0");
|
|
|
|
|
disp1->hide_component("time_current");
|
|
|
|
|
disp1->hide_component("time_total");
|
|
|
|
|
disp1->hide_component("time_progress");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
##### START - DISPLAY START CONFIGURATION #####
|
|
|
|
|
display:
|
|
|
|
|
- id: disp1
|
|
|
|
|
@@ -1804,6 +1815,7 @@ script:
|
|
|
|
|
value: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (id(is_uploading_tft)) change_climate_state->stop();
|
|
|
|
|
if (!embedded) {
|
|
|
|
|
if (key == "temperature" or key == "target_temp_high" or key == "target_temp_low")
|
|
|
|
|
ha_call_service->execute("climate.set_temperature", key.c_str(), to_string(stof(value) / 10), detailed_entity->state.c_str());
|
|
|
|
|
@@ -1830,6 +1842,7 @@ script:
|
|
|
|
|
return (compareVersions("${version}", version_tft->state.c_str()) and compareVersions("${version}", version_blueprint->state.c_str()));
|
|
|
|
|
timeout: 60s
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (id(is_uploading_tft)) check_versions->stop();
|
|
|
|
|
static const char *const TAG = "script.check_versions";
|
|
|
|
|
auto compareVersions = [](const char* version1, const char* version2) -> bool
|
|
|
|
|
{
|
|
|
|
|
@@ -1917,6 +1930,7 @@ script:
|
|
|
|
|
screensaver_time_color: int32_t[]
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (id(is_uploading_tft)) global_settings->stop();
|
|
|
|
|
static const char *const TAG = "script.global_settings";
|
|
|
|
|
// Blueprint version
|
|
|
|
|
ESP_LOGV(TAG, "Check Blueprint version");
|
|
|
|
|
@@ -1999,6 +2013,7 @@ script:
|
|
|
|
|
command: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (id(is_uploading_tft)) ha_button->stop();
|
|
|
|
|
timer_reset_all->execute(page.c_str());
|
|
|
|
|
auto ha_event = new esphome::api::CustomAPIDevice();
|
|
|
|
|
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
|
|
|
|
|
@@ -2018,6 +2033,7 @@ script:
|
|
|
|
|
entity: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (id(is_uploading_tft)) ha_call_service->stop();
|
|
|
|
|
static const char *const TAG = "script.ha_call_service";
|
|
|
|
|
ESP_LOGV(TAG, "Calling Home Assisant service");
|
|
|
|
|
ESP_LOGV(TAG, " Type: service_call");
|
|
|
|
|
@@ -2053,11 +2069,13 @@ script:
|
|
|
|
|
mode: restart
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
notification_label->publish_state("");
|
|
|
|
|
notification_text->publish_state("");
|
|
|
|
|
notification_unread->turn_off();
|
|
|
|
|
refresh_notification->execute();
|
|
|
|
|
if (current_page->state == "notification") disp1->goto_page("home");
|
|
|
|
|
if (not id(is_uploading_tft)) {
|
|
|
|
|
notification_label->publish_state("");
|
|
|
|
|
notification_text->publish_state("");
|
|
|
|
|
notification_unread->turn_off();
|
|
|
|
|
refresh_notification->execute();
|
|
|
|
|
if (current_page->state == "notification") disp1->goto_page("home");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- id: open_entity_settings_page
|
|
|
|
|
mode: restart
|
|
|
|
|
@@ -2070,22 +2088,24 @@ script:
|
|
|
|
|
back_page: string
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
detailed_entity->publish_state(entity);
|
|
|
|
|
if (page == "alarm_control_panel") page = "alarm";
|
|
|
|
|
std::string cmd_page = std::string("page ") + page.c_str();
|
|
|
|
|
disp1->send_command_printf(cmd_page.c_str());
|
|
|
|
|
if (page_label.find("\\r") != std::string::npos)
|
|
|
|
|
page_label = page_label.replace(page_label.find("\\r"), 2, " ");
|
|
|
|
|
disp1->set_component_text_printf("page_label", "%s", page_label.c_str());
|
|
|
|
|
set_page_id->execute("back_page_id", back_page.c_str());
|
|
|
|
|
if (page == "climate")
|
|
|
|
|
disp1->set_component_value("embedded", (entity == "embedded_climate") ? 1 : 0);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ((page_icon != std::string()) and (page_icon != ""))
|
|
|
|
|
disp1->set_component_text_printf("icon_state", "%s", page_icon.c_str());
|
|
|
|
|
set_component_color->execute("icon_state", page_icon_color);
|
|
|
|
|
}
|
|
|
|
|
if (not id(is_uploading_tft)) {
|
|
|
|
|
detailed_entity->publish_state(entity);
|
|
|
|
|
if (page == "alarm_control_panel") page = "alarm";
|
|
|
|
|
std::string cmd_page = std::string("page ") + page.c_str();
|
|
|
|
|
disp1->send_command_printf(cmd_page.c_str());
|
|
|
|
|
if (page_label.find("\\r") != std::string::npos)
|
|
|
|
|
page_label = page_label.replace(page_label.find("\\r"), 2, " ");
|
|
|
|
|
disp1->set_component_text_printf("page_label", "%s", page_label.c_str());
|
|
|
|
|
set_page_id->execute("back_page_id", back_page.c_str());
|
|
|
|
|
if (page == "climate")
|
|
|
|
|
disp1->set_component_value("embedded", (entity == "embedded_climate") ? 1 : 0);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ((page_icon != std::string()) and (page_icon != ""))
|
|
|
|
|
disp1->set_component_text_printf("icon_state", "%s", page_icon.c_str());
|
|
|
|
|
set_component_color->execute("icon_state", page_icon_color);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- id: page_alarm
|
|
|
|
|
mode: restart
|
|
|
|
|
@@ -2461,6 +2481,11 @@ script:
|
|
|
|
|
relay2_icon_color: int
|
|
|
|
|
relay2_fallback: bool
|
|
|
|
|
then:
|
|
|
|
|
- if:
|
|
|
|
|
condition:
|
|
|
|
|
lambda: 'return id(is_uploading_tft);'
|
|
|
|
|
then:
|
|
|
|
|
- script.stop: relay_settings
|
|
|
|
|
- lambda: |-
|
|
|
|
|
static const char *const TAG = "script.relay_settings";
|
|
|
|
|
// Relays
|
|
|
|
|
@@ -2684,6 +2709,7 @@ script:
|
|
|
|
|
foreground: int32_t[]
|
|
|
|
|
then:
|
|
|
|
|
- lambda: |-
|
|
|
|
|
if (id(is_uploading_tft)) set_component_color->stop();
|
|
|
|
|
static const char *const TAG = "script.set_component_color";
|
|
|
|
|
ESP_LOGVV(TAG, "Starting:");
|
|
|
|
|
ESP_LOGVV(TAG, " Component: %s", component.c_str());
|
|
|
|
|
|