Clean-up
This commit is contained in:
@@ -19,7 +19,7 @@ external_components:
|
||||
- source:
|
||||
type: git
|
||||
url: https://github.com/Blackymas/NSPanel_HA_Blueprint
|
||||
ref: main
|
||||
# ref: main
|
||||
components:
|
||||
- nspanel_ha_blueprint_upload_tft
|
||||
refresh: 300s
|
||||
|
||||
@@ -27,7 +27,7 @@ external_components:
|
||||
# path: packages/Blackymas/components
|
||||
type: git
|
||||
url: https://github.com/Blackymas/NSPanel_HA_Blueprint
|
||||
ref: dev # To do: change to main for release
|
||||
ref: dev # To do: use tag for release
|
||||
components:
|
||||
- nspanel_ha_blueprint
|
||||
refresh: 3s # To do: change to 300s for release
|
||||
@@ -191,7 +191,7 @@ api:
|
||||
disp1->set_component_font((id + "icon").c_str(), icon_font);
|
||||
disp1->set_component_foreground_color((id + "bri").c_str(), state ? 10597 : 65535);
|
||||
disp1->set_component_foreground_color((id + "text").c_str(), state ? 10597 : 65535);
|
||||
disp1->set_component_font_color((id + "icon").c_str(), esphome::display::ColorUtil::color_to_565(esphome::Color(icon_color[0], icon_color[1], icon_color[2])));
|
||||
disp1->set_component_font_color((id + "icon").c_str(), rgbTo565(icon_color));
|
||||
disp1->set_component_text((id + "icon").c_str(), icon.c_str());
|
||||
display_wrapped_text->execute((id + "text").c_str(), label.c_str(), 10);
|
||||
disp1->set_component_text((id + "bri").c_str(), (strcmp(bri.c_str(), "0") == 0) ? " " : bri.c_str());
|
||||
@@ -219,7 +219,7 @@ api:
|
||||
then:
|
||||
- lambda: |-
|
||||
if (!id(is_uploading_tft))
|
||||
disp1->set_component_font_color(id.c_str(), esphome::display::ColorUtil::color_to_565(esphome::Color(color[0], color[1], color[2])));
|
||||
disp1->set_component_font_color(id.c_str(), rgbTo565(color));
|
||||
|
||||
# Updates the text of a specified component on the display.
|
||||
- service: component_text
|
||||
@@ -305,7 +305,7 @@ api:
|
||||
if (!id(is_uploading_tft) and !id.empty()) {
|
||||
disp1->set_component_text(id.c_str(), visible ? icon.c_str() : "");
|
||||
if (icon_color.size() == 3)
|
||||
disp1->set_component_font_color(id.c_str(), esphome::display::ColorUtil::color_to_565(esphome::Color(icon_color[0], icon_color[1], icon_color[2])));
|
||||
disp1->set_component_font_color(id.c_str(), rgbTo565(icon_color));
|
||||
set_component_visibility->execute(id.c_str(), visible);
|
||||
}
|
||||
|
||||
@@ -383,15 +383,11 @@ api:
|
||||
|
||||
// Relay icon's colors
|
||||
if (relay1_icon_color.size() == 3) {
|
||||
id(home_relay1_icon_color) = ColorUtil::color_to_565(esphome::Color(relay1_icon_color[0],
|
||||
relay1_icon_color[1],
|
||||
relay1_icon_color[2]));
|
||||
id(home_relay1_icon_color) = rgbTo565(relay1_icon_color);
|
||||
disp1->set_component_font_color("home.chip_relay1", id(home_relay1_icon_color));
|
||||
}
|
||||
if (relay2_icon_color.size() == 3) {
|
||||
id(home_relay2_icon_color) = ColorUtil::color_to_565(esphome::Color(relay2_icon_color[0],
|
||||
relay2_icon_color[1],
|
||||
relay2_icon_color[2]));
|
||||
id(home_relay2_icon_color) = rgbTo565(relay2_icon_color);
|
||||
disp1->set_component_font_color("home.chip_relay2", id(home_relay2_icon_color));
|
||||
}
|
||||
|
||||
@@ -401,13 +397,9 @@ api:
|
||||
update_bitwise_setting(id(buttons_settings), button_right, ButtonSettings::ButtonRight_Enabled);
|
||||
|
||||
if (button_bar_color_on.size() == 3)
|
||||
id(buttons_color_on) = ColorUtil::color_to_565(esphome::Color(button_bar_color_on[0],
|
||||
button_bar_color_on[1],
|
||||
button_bar_color_on[2]));
|
||||
id(buttons_color_on) = rgbTo565(button_bar_color_on);
|
||||
if (button_bar_color_off.size() == 3)
|
||||
id(buttons_color_off) = ColorUtil::color_to_565(esphome::Color(button_bar_color_off[0],
|
||||
button_bar_color_off[1],
|
||||
button_bar_color_off[2]));
|
||||
id(buttons_color_off) = rgbTo565(button_bar_color_off);
|
||||
|
||||
// Refresh relays display
|
||||
refresh_relays->execute(3);
|
||||
@@ -445,8 +437,8 @@ api:
|
||||
}
|
||||
|
||||
// Date/Time colors
|
||||
id(home_date_color) = ColorUtil::color_to_565(esphome::Color(date_color[0], date_color[1], date_color[2]));
|
||||
id(home_time_color) = ColorUtil::color_to_565(esphome::Color(time_color[0], time_color[1], time_color[2]));
|
||||
id(home_date_color) = rgbTo565(date_color);
|
||||
id(home_time_color) = rgbTo565(time_color);
|
||||
disp1->set_component_font_color("home.date", id(home_date_color));
|
||||
disp1->set_component_font_color("home.time", id(home_time_color));
|
||||
|
||||
@@ -475,22 +467,16 @@ api:
|
||||
// QRCode button
|
||||
set_component_visibility->execute("home.bt_qrcode", qrcode);
|
||||
disp1->set_component_text("home.bt_qrcode", qrcode_icon.c_str());
|
||||
disp1->set_component_font_color("home.bt_qrcode", ColorUtil::color_to_565(esphome::Color(qrcode_icon_color[0],
|
||||
qrcode_icon_color[1],
|
||||
qrcode_icon_color[2])));
|
||||
disp1->set_component_font_color("home.bt_qrcode", rgbTo565(qrcode_icon_color));
|
||||
|
||||
// Entities pages button
|
||||
disp1->set_component_text("home.bt_entities", entities_pages_icon.c_str());
|
||||
disp1->set_component_font_color("home.bt_entities", ColorUtil::color_to_565(esphome::Color(entities_pages_icon_color[0],
|
||||
entities_pages_icon_color[1],
|
||||
entities_pages_icon_color[2])));
|
||||
disp1->set_component_font_color("home.bt_entities", rgbTo565(entities_pages_icon_color));
|
||||
|
||||
// Utilities button
|
||||
disp1->send_command_printf("is_utilities=%i", utilities ? 1 : 0);
|
||||
disp1->set_component_text("home.bt_utilities", utilities_icon.c_str());
|
||||
disp1->set_component_font_color("home.bt_utilities", ColorUtil::color_to_565(esphome::Color(utilities_icon_color[0],
|
||||
utilities_icon_color[1],
|
||||
utilities_icon_color[2])));
|
||||
disp1->set_component_font_color("home.bt_utilities", rgbTo565(utilities_icon_color));
|
||||
|
||||
blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 1));
|
||||
}
|
||||
@@ -804,16 +790,12 @@ api:
|
||||
using namespace esphome::display;
|
||||
if (!(icon.empty())) disp1->set_component_text((id + "_icon").c_str(), icon.c_str());
|
||||
if (icon_color.size() == 3)
|
||||
disp1->set_component_font_color((id + "_icon").c_str(), ColorUtil::color_to_565(esphome::Color(icon_color[0],
|
||||
icon_color[1],
|
||||
icon_color[2])));
|
||||
disp1->set_component_font_color((id + "_icon").c_str(), rgbTo565(icon_color));
|
||||
|
||||
if (!(name.empty())) disp1->set_component_text((id + "_label").c_str(), name.c_str());
|
||||
if (!(value.empty())) disp1->set_component_text(id.c_str(), adjustDecimalSeparator(value, id(mui_decimal_separator)).c_str());
|
||||
if (value_color.size() == 3)
|
||||
disp1->set_component_font_color(id.c_str(), ColorUtil::color_to_565(esphome::Color(value_color[0],
|
||||
value_color[1],
|
||||
value_color[2])));
|
||||
disp1->set_component_font_color(id.c_str(), rgbTo565(value_color));
|
||||
if (current_page->state.find("entitypage") == 0 and !(value.empty())) { // Adjust value's font on entities pages
|
||||
// Adjusted length starts at 0
|
||||
float adjusted_length = 0.0;
|
||||
@@ -1960,9 +1942,7 @@ script:
|
||||
// Screen saver page (sleep)
|
||||
id(screensaver_display_time) = screensaver_time;
|
||||
id(screensaver_display_time_font) = screensaver_time_font;
|
||||
id(screensaver_display_time_color) = esphome::display::ColorUtil::color_to_565(esphome::Color(screensaver_time_color[0],
|
||||
screensaver_time_color[1],
|
||||
screensaver_time_color[2]));
|
||||
id(screensaver_display_time_color) = rgbTo565(screensaver_time_color);
|
||||
page_screensaver->execute();
|
||||
|
||||
// Entities pages alignment
|
||||
@@ -2613,14 +2593,18 @@ script:
|
||||
parameters:
|
||||
brightness: float
|
||||
then:
|
||||
- lambda: |-
|
||||
if (brightness == display_brightness->state and current_page->state != "boot" and current_page->state != "screensaver")
|
||||
disp1->send_command_printf("wakeup_timer.en=1");
|
||||
else
|
||||
disp1->set_backlight_brightness(brightness / 100.0f);
|
||||
current_brightness->update();
|
||||
- delay: 5s
|
||||
- lambda: current_brightness->update();
|
||||
- if:
|
||||
condition:
|
||||
- lambda: return (!id(is_uploading_tft));
|
||||
then:
|
||||
- lambda: |-
|
||||
if (brightness == display_brightness->state and current_page->state != "boot" and current_page->state != "screensaver")
|
||||
disp1->send_command_printf("wakeup_timer.en=1");
|
||||
else
|
||||
disp1->set_backlight_brightness(brightness / 100.0f);
|
||||
current_brightness->update();
|
||||
- delay: 5s
|
||||
- lambda: current_brightness->update();
|
||||
|
||||
- id: set_climate
|
||||
mode: restart
|
||||
@@ -2637,8 +2621,7 @@ script:
|
||||
embedded_climate: bool
|
||||
then:
|
||||
- lambda: |-
|
||||
if (id(is_uploading_tft)) set_climate->stop();
|
||||
if (current_page->state == "climate") {
|
||||
if (!id(is_uploading_tft) and current_page->state == "climate") {
|
||||
bool useDecimal = (temp_step % 10 != 0);
|
||||
char buffer[15];
|
||||
disp1->send_command_printf("climateslider.maxval=%i", total_steps);
|
||||
@@ -2713,7 +2696,8 @@ script:
|
||||
then:
|
||||
- lambda: |-
|
||||
NextionComponent component = extractNextionComponent(component_id, current_page->state);
|
||||
if (component.is_current_page) disp1->send_command_printf("vis %s,%i", component.component_id.c_str(), show ? 1 : 0);
|
||||
if (component.is_current_page) disp1->send_command_printf("vis %s,%i", component.component_id, show ? 1 : 0);
|
||||
|
||||
|
||||
- id: stop_all
|
||||
mode: restart
|
||||
|
||||
Reference in New Issue
Block a user