diff --git a/esphome/nspanel_esphome_addon_upload_tft.yaml b/esphome/nspanel_esphome_addon_upload_tft.yaml index b2c98a0..a39cded 100644 --- a/esphome/nspanel_esphome_addon_upload_tft.yaml +++ b/esphome/nspanel_esphome_addon_upload_tft.yaml @@ -158,7 +158,7 @@ script: message: string then: - lambda: |- - ESP_LOGD("addon_upload_tft.script.report_upload_progress", "%s", message.c_str()); + ESP_LOGD("addon_upload_tft.script.report_upload_progress", message.c_str()); if (id(tft_is_valid)) { if (current_page->state != "confirm") { open_upload_dialog->execute(); diff --git a/esphome/nspanel_esphome_core.yaml b/esphome/nspanel_esphome_core.yaml index c69183e..11ee78d 100644 --- a/esphome/nspanel_esphome_core.yaml +++ b/esphome/nspanel_esphome_core.yaml @@ -208,9 +208,9 @@ api: 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_text_printf((id + "icon").c_str(), "%s", icon.c_str()); + 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_printf((id + "bri").c_str(), "%s", (strcmp(bri.c_str(), "0") == 0) ? " " : bri.c_str()); + disp1->set_component_text((id + "bri").c_str(), (strcmp(bri.c_str(), "0") == 0) ? " " : bri.c_str()); set_component_visibility->execute((id + "pic").c_str(), true); set_component_visibility->execute((id + "icon").c_str(), true); set_component_visibility->execute((id + "text").c_str(), true); @@ -245,7 +245,7 @@ api: then: - lambda: |- if (!id(is_uploading_tft)) - disp1->set_component_text_printf(id.c_str(), "%s", txt.c_str()); + disp1->set_component_text(id.c_str(), txt.c_str()); # Updates the value of a specified component on the display. - service: component_val @@ -312,7 +312,7 @@ api: then: - lambda: |- if (!id(is_uploading_tft) and !id.empty()) { - if (not icon.empty()) disp1->set_component_text_printf(id.c_str(), "%s", icon.c_str()); + 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]))); set_component_visibility->execute(id.c_str(), visible); @@ -474,18 +474,18 @@ api: // QRCode button set_component_visibility->execute("home.bt_qrcode", qrcode); - disp1->set_component_text_printf("home.bt_qrcode", "%s", qrcode_icon.c_str()); + disp1->set_component_text("home.bt_qrcode", qrcode_icon.c_str()); disp1->set_component_font_color("home.bt_qrcode", esphome::display::ColorUtil::color_to_565(esphome::Color(qrcode_icon_color[0], qrcode_icon_color[1], qrcode_icon_color[2]))); // Entities pages button - disp1->set_component_text_printf("home.bt_entities", "%s", entities_pages_icon.c_str()); + disp1->set_component_text("home.bt_entities", entities_pages_icon.c_str()); disp1->set_component_font_color("home.bt_entities", esphome::display::ColorUtil::color_to_565(esphome::Color(entities_pages_icon_color[0], entities_pages_icon_color[1], entities_pages_icon_color[2]))); // Utilities button disp1->send_command_printf("is_utilities=%i", utilities ? 1 : 0); - disp1->set_component_text_printf("home.bt_utilities", "%s", utilities_icon.c_str()); + disp1->set_component_text("home.bt_utilities", utilities_icon.c_str()); disp1->set_component_font_color("home.bt_utilities", esphome::display::ColorUtil::color_to_565(esphome::Color(utilities_icon_color[0], utilities_icon_color[1], utilities_icon_color[2]))); @@ -530,7 +530,7 @@ api: set_component_visibility->execute("home.bt_notific", true); goto_page->execute("notification"); timer_reset_all->execute("notification"); - disp1->set_component_text_printf("notification.notifi_label", "%s", label.c_str()); + disp1->set_component_text("notification.notifi_label", label.c_str()); 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()); @@ -560,8 +560,8 @@ api: if (page_title.find("\\r") != std::string::npos) { page_title = page_title.replace(page_title.find("\\r"), 2, " "); } - disp1->set_component_text_printf("page_label", "%s", page_title.c_str()); - disp1->set_component_text_printf("code_format", "%s", code_format.c_str()); + disp1->set_component_text("page_label", page_title.c_str()); + disp1->set_component_text("code_format", code_format.c_str()); if (code_arm_required) disp1->set_component_text_printf("code_arm_req", "1"); else disp1->set_component_text_printf("code_arm_req", "0"); @@ -682,7 +682,7 @@ api: - lambda: |- if (current_page->state == "media_player" and !id(is_uploading_tft)) { detailed_entity->publish_state(entity); - disp1->set_component_text_printf("page_label", "%s", friendly_name.c_str()); + disp1->set_component_text("page_label", 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); @@ -698,10 +698,10 @@ api: // 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->set_component_text("bt_play_pause", "\uE409"); // mdi:play set_component_visibility->execute("bt_play_pause", true); } else if (supported_features & 1 and state == "playing" ) { //PAUSE - disp1->set_component_text_printf("bt_play_pause", "%s", "\uE3E3"); // mdi:pause + disp1->set_component_text("bt_play_pause", "\uE3E3"); // mdi:pause set_component_visibility->execute("bt_play_pause", true); } else set_component_visibility->execute("bt_play_pause", false); @@ -717,10 +717,10 @@ api: // 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->set_component_text("bt_mute", "\uEE07"); // mdi:volume-variant-off set_component_visibility->execute("bt_mute", true); } else if (supported_features & 8) { // mute - disp1->set_component_text_printf("bt_mute", "%s", "\uE57E"); // mdi:volume-low + disp1->set_component_text("bt_mute", "\uE57E"); // mdi:volume-low set_component_visibility->execute("bt_mute", true); } else set_component_visibility->execute("bt_mute", false); @@ -772,8 +772,8 @@ api: - lambda: |- if (!id(is_uploading_tft)) { set_component_visibility->execute("home.bt_qrcode", !(qrcode.empty())); - disp1->set_component_text_printf("qrcode.qrcode_label", "%s", title.c_str()); - disp1->set_component_text_printf("qrcode.qrcode_value", "%s", qrcode.c_str()); + disp1->set_component_text("qrcode.qrcode_label", title.c_str()); + disp1->set_component_text("qrcode.qrcode_value", qrcode.c_str()); if (show) goto_page->execute("qrcode"); blueprint_status->publish_state(int(blueprint_status->raw_state) | (1 << 2)); } @@ -798,14 +798,14 @@ api: then: - lambda: |- if (!id(is_uploading_tft) and !(id.empty())) { - if (!(icon.empty())) disp1->set_component_text_printf((id + "_icon").c_str(), "%s", icon.c_str()); + 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(), esphome::display::ColorUtil::color_to_565(esphome::Color(icon_color[0], icon_color[1], icon_color[2]))); - if (!(name.empty())) disp1->set_component_text_printf((id + "_label").c_str(), "%s", name.c_str()); - if (!(value.empty())) disp1->set_component_text_printf(id.c_str(), "%s", adjustDecimalSeparator(value, id(mui_decimal_separator)).c_str()); + 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(), esphome::display::ColorUtil::color_to_565(esphome::Color(value_color[0], value_color[1], @@ -1758,11 +1758,11 @@ text_sensor: { goto_page->execute("keyb_num"); disp1->set_component_value("keyb_num.page_id", 23); //Calling from Alarm page - disp1->set_component_text_printf("keyb_num.domain", "%s", page.c_str()); - disp1->set_component_text_printf("keyb_num.key", "%s", key.c_str()); - disp1->set_component_text_printf("keyb_num.value", "%s", value.c_str()); - disp1->set_component_text_printf("keyb_num.entity", "%s", entity.c_str()); - disp1->set_component_text_printf("keyb_num.title", "%s", title.c_str()); + disp1->set_component_text("keyb_num.domain", page.c_str()); + disp1->set_component_text("keyb_num.key", key.c_str()); + disp1->set_component_text("keyb_num.value", value.c_str()); + disp1->set_component_text("keyb_num.entity", entity.c_str()); + disp1->set_component_text("keyb_num.title", title.c_str()); } else service_call_alarm_control_panel->execute(entity.c_str(), key.c_str(), code_format.c_str(), ""); } @@ -1910,7 +1910,7 @@ script: while (text_to_display[startPos] == ' ' and startPos < text_to_display.length()) { startPos++; } } } - disp1->set_component_text_printf(component.c_str(), "%s", wrappedText.c_str()); + disp1->set_component_text(component.c_str(), wrappedText.c_str()); - id: global_settings mode: restart @@ -1928,7 +1928,7 @@ script: if (id(is_uploading_tft)) global_settings->stop(); // Blueprint version nspanel_ha_blueprint::copyStringToCharArray(id(version_blueprint), blueprint_version); - disp1->set_component_text_printf("boot.bluep_version", "%s", blueprint_version.c_str()); + disp1->set_component_text("boot.bluep_version", blueprint_version.c_str()); if (current_page->state == "boot") page_boot->execute(); check_versions->execute(); @@ -1952,7 +1952,7 @@ script: // Update current page page_changed->execute(current_page->state.c_str()); } - disp1->set_component_text_printf("boot.bluep_version", "%s", blueprint_version.c_str()); + disp1->set_component_text("boot.bluep_version", blueprint_version.c_str()); - if: condition: @@ -2281,7 +2281,7 @@ script: mode: restart then: - lambda: |- - disp1->set_component_text_printf("notification.notifi_label", "%s", notification_label->state.c_str()); + disp1->set_component_text("notification.notifi_label", notification_label->state.c_str()); display_wrapped_text->execute("notification.notifi_text01", notification_text->state.c_str(), display_mode->state == 2 ? 23 : 32); - id: page_qrcode @@ -2309,7 +2309,6 @@ script: mode: restart then: - lambda: |- - //disp1->set_component_text_printf("bt_sleep", "%s", (id(sleep_mode).state) ? "\uEA19" : "\uEA18"); //mdi:toggle-switch-outline or mdi:toggle-switch-off-outline set_component_visibility->execute("page_settings.lbl_sleep", false); set_component_visibility->execute("page_settings.bt_sleep", false); @@ -2378,10 +2377,10 @@ script: std::string time_format_str_sleep = time_format_str; if (time_format_str_sleep.find("%p") != std::string::npos) time_format_str_sleep.replace(time_format_str_sleep.find("%p"), sizeof("%p")-1, meridiem_text.c_str()); - disp1->set_component_text_printf("text", "%s", id(time_provider).now().strftime(time_format_str_sleep).c_str()); + disp1->set_component_text("text", id(time_provider).now().strftime(time_format_str_sleep).c_str()); } - disp1->set_component_text_printf("home.meridiem", "%s", (time_format_str.find("%p") != std::string::npos) ? meridiem_text.c_str() : " "); - disp1->set_component_text_printf("home.time", "%s", id(time_provider).now().strftime(time_format_str).c_str()); + disp1->set_component_text("home.meridiem", (time_format_str.find("%p") != std::string::npos) ? meridiem_text.c_str() : " "); + disp1->set_component_text("home.time", id(time_provider).now().strftime(time_format_str).c_str()); - id: refresh_hardware_buttons_bars mode: restart @@ -2434,8 +2433,8 @@ script: then: - lambda: |- // Chips - Relays - disp1->set_component_text_printf("home.chip_relay1", "%s", (relay_1->state) ? id(home_relay1_icon) : "\uFFFF"); - disp1->set_component_text_printf("home.chip_relay2", "%s", (relay_2->state) ? id(home_relay2_icon) : "\uFFFF"); + disp1->set_component_text("home.chip_relay1", (relay_1->state) ? id(home_relay1_icon) : "\uFFFF"); + disp1->set_component_text("home.chip_relay2", (relay_2->state) ? id(home_relay2_icon) : "\uFFFF"); refresh_hardware_buttons_bars->execute(); - id: refresh_wifi_icon @@ -2446,13 +2445,13 @@ script: // Update Wi-Fi icon color 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 > 99) ? "\uE5A8" : // mdi:wifi - All right! - "\uE7CF") : // mdi:home-assistant - Blueprint is out - "\uF256") : // mdi:api-off - "\uE5A9"); // mdi:wifi-off + disp1->set_component_text("home.wifi_icon", + wifi_component->is_connected() ? + (api_server->is_connected() ? + ((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: restore_settings @@ -2959,53 +2958,53 @@ script: switch (mode) // CLIMATE_MODE_OFF = 0, CLIMATE_MODE_HEAT_COOL = 1, CLIMATE_MODE_COOL = 2, CLIMATE_MODE_HEAT = 3, CLIMATE_MODE_FAN_ONLY = 4, CLIMATE_MODE_DRY = 5, CLIMATE_MODE_AUTO = 6 { case 0: //CLIMATE_MODE_OFF - disp1->set_component_text_printf(component.c_str(), "%s", "\uFFFF"); // (E424) Don't show icon when off + disp1->set_component_text(component.c_str(), "\uFFFF"); // (E424) Don't show icon when off disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 1: //CLIMATE_MODE_HEAT_COOL - disp1->set_component_text_printf(component.c_str(), "%s", "\uE069"); // mdi:autorenew + disp1->set_component_text(component.c_str(), "\uE069"); // mdi:autorenew disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 2: //CLIMATE_MODE_COOL - disp1->set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake + disp1->set_component_text(component.c_str(), "\uE716"); // mdi:snowflake disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 3: //CLIMATE_MODE_HEAT - disp1->set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire + disp1->set_component_text(component.c_str(), "\uE237"); // mdi:fire disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 4: //CLIMATE_MODE_FAN_ONLY - disp1->set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan + disp1->set_component_text(component.c_str(), "\uE20F"); // mdi:fan disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 5: //CLIMATE_MODE_DRY - disp1->set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent + disp1->set_component_text(component.c_str(), "\uE58D"); // mdi:water-percent disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 6: //CLIMATE_MODE_AUTO - disp1->set_component_text_printf(component.c_str(), "%s", "\uEE8D"); // mdi:calendar-sync + disp1->set_component_text(component.c_str(), "\uEE8D"); // mdi:calendar-sync disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; } break; case 2: //CLIMATE_ACTION_COOLING - disp1->set_component_text_printf(component.c_str(), "%s", "\uE716"); // mdi:snowflake + disp1->set_component_text(component.c_str(), "\uE716"); // mdi:snowflake disp1->set_component_font_color(component.c_str(), 1055); // blue break; case 3: //CLIMATE_ACTION_HEATING - disp1->set_component_text_printf(component.c_str(), "%s", "\uE237"); // mdi:fire + disp1->set_component_text(component.c_str(), "\uE237"); // mdi:fire disp1->set_component_font_color(component.c_str(), 64164); // deep-orange break; case 4: //CLIMATE_ACTION_IDLE - disp1->set_component_text_printf(component.c_str(), "%s", "\uE50E"); // mdi:thermometer + disp1->set_component_text(component.c_str(), "\uE50E"); // mdi:thermometer disp1->set_component_font_color(component.c_str(), 35921); // grey (off) break; case 5: //CLIMATE_ACTION_DRYING - disp1->set_component_text_printf(component.c_str(), "%s", "\uE58D"); // mdi:water-percent + disp1->set_component_text(component.c_str(), "\uE58D"); // mdi:water-percent disp1->set_component_font_color(component.c_str(), 64704); // orange break; case 6: //CLIMATE_ACTION_FAN - disp1->set_component_text_printf(component.c_str(), "%s", "\uE20F"); // mdi:fan + disp1->set_component_text(component.c_str(), "\uE20F"); // mdi:fan disp1->set_component_font_color(component.c_str(), 1530); // cyan break; } diff --git a/nspanel_blueprint.yaml b/nspanel_blueprint.yaml index c69c0ae..be05c55 100644 --- a/nspanel_blueprint.yaml +++ b/nspanel_blueprint.yaml @@ -8061,37 +8061,32 @@ action: (entity_hvac_action if entity_hvac_action and entity_hvac_action not in enum.states.unknown else entity_state) if entity_domain == "climate" else entity_state }} - - if: - - or: - - and: - - '{{ not repeat.item.inverted }}' - - or: - - '{{ entity_state in enum.states.on }}' - - '{{ entity_domain != "climate" and entity_domain in enum.states and entity_state in enum.states[entity_domain].on }}' - - '{{ entity_domain == "climate" and entity_state in ["heating", "cooling", "drying", "fan_only"] }}' - - and: - - '{{ repeat.item.inverted }}' - - or: - - '{{ entity_state in enum.states.off }}' - - '{{ entity_domain in enum.states and entity_state in enum.states[entity_domain].off }}' - - '{{ entity_domain == "climate" and entity_state not in ["heating", "cooling", "drying", "fan_only"] }}' - then: - - service: '{{ nspanel.service.icon }}' - data: - id: 'home.{{ repeat.item.component }}' - icon: '{{ entity.icon if entity.icon is defined else "" }}' - icon_color: '{{ entity.icon_color if entity.icon_color is defined else [] }}' - visible: true - continue_on_error: true - else: - - &hide-home_page-status_bar_chip - service: '{{ nspanel.service.component.visibility }}' - data: - ids: '{{ [ "home." ~ repeat.item.component ] }}' - visible: false - continue_on_error: true - else: - - *hide-home_page-status_bar_chip + chip_visible: > + {{ + ( + (not repeat.item.inverted) and + ( + (entity_state in enum.states.on) or + (entity_domain != "climate" and entity_domain in enum.states and entity_state in enum.states[entity_domain].on) or + (entity_domain == "climate" and entity_state in ["heating", "cooling", "drying", "fan_only"]) + ) + ) or + ( + (repeat.item.inverted) and + ( + (entity_state in enum.states.off) or + (entity_domain in enum.states and entity_state in enum.states[entity_domain].off) or + (entity_domain == "climate" and entity_state not in ["heating", "cooling", "drying", "fan_only"]) + ) + ) + }} + - service: '{{ nspanel.service.icon }}' + data: + id: 'home.{{ repeat.item.component }}' + icon: '{{ entity.icon if chip_visible and entity.icon is defined else "" }}' + icon_color: '{{ entity.icon_color if chip_visible and entity.icon_color is defined else [] }}' + visible: '{{ chip_visible }}' + continue_on_error: true ##### HOME VALUE 01 - 03 - &variables_home_page_values