component_visibility replaces component_hide and component_show services
Optimization
This commit is contained in:
@@ -307,56 +307,6 @@ api:
|
||||
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])));
|
||||
|
||||
|
||||
# Component Hide Service
|
||||
# Allows for dynamic interface changes by hiding specified components on the display.
|
||||
#
|
||||
# Usage: Ideal for interactive user interfaces that need to adapt by hiding elements based on user actions, conditions, or events.
|
||||
#
|
||||
# Parameters:
|
||||
# - id (string): Identifier of the component to be hidden. Ensure this matches the component's ID in your display layout.
|
||||
#
|
||||
# Example service call:
|
||||
# service: esphome.<your_panel_name>_component_hide
|
||||
# data:
|
||||
# id: "date" # Example: Hides the date display on the Home page.
|
||||
#
|
||||
# NOTE: Replace <your_panel_name> with the specific panel name in your Home Assistant setup to ensure correct service execution.
|
||||
# Ensure the 'id' matches the component on your display you wish to hide.
|
||||
#
|
||||
# IMPORTANT: This service functions only when the target page is visible. The component id should not include the page id.
|
||||
# If the component being hidden is not on the current page, the command will fail, and an error message will be logged.
|
||||
- service: component_hide
|
||||
variables:
|
||||
id: string
|
||||
then:
|
||||
- lambda: |-
|
||||
if (!id(is_uploading_tft))
|
||||
set_component_visibility->execute(id.c_str(), false);
|
||||
|
||||
# Component Show Service
|
||||
# Enables dynamic interface changes by making specified components visible on the display again.
|
||||
#
|
||||
# Usage: Perfect for interactive user interfaces that adapt by showing elements based on user actions, conditions, or events.
|
||||
#
|
||||
# Parameters:
|
||||
# - id (string): The component's identifier to be made visible. This must match your display's component ID accurately.
|
||||
#
|
||||
# Example service call:
|
||||
# service: esphome.<your_panel_name>_component_show
|
||||
# data:
|
||||
# id: "date" # Example: Makes the date display visible on the Home page if previously hidden.
|
||||
#
|
||||
# NOTE: Replace <your_panel_name> with the specific panel name in your Home Assistant setup to ensure correct service execution.
|
||||
# Confirm the 'id' correctly targets the component you wish to show for effective interface adaptation.
|
||||
- service: component_show
|
||||
variables:
|
||||
id: string
|
||||
then:
|
||||
- lambda: |-
|
||||
if (!id(is_uploading_tft))
|
||||
set_component_visibility->execute(id.c_str(), true);
|
||||
|
||||
# Component Text Service
|
||||
# Updates text content for a specified component on the display, ideal for dynamic updates.
|
||||
#
|
||||
@@ -410,7 +360,36 @@ api:
|
||||
if (!id(is_uploading_tft))
|
||||
disp1->set_component_value(id.c_str(), val);
|
||||
|
||||
# entity_details_show Service - PENDING FULL IMPLEMENTATION
|
||||
# Component Visibility Service
|
||||
# Allows for dynamic interface changes by hiding or showing specified components on the display.
|
||||
#
|
||||
# Usage: Ideal for interactive user interfaces that need to adapt by hiding or showing elements based on user actions, conditions, or events.
|
||||
#
|
||||
# Parameters:
|
||||
# - id (string): Identifier of the component to be hidden/shown. Ensure this matches the component's ID in your display layout.
|
||||
# - visible (boolean): Set to true to show the component, or false to hide it.
|
||||
#
|
||||
# Example service call:
|
||||
# service: esphome.<your_panel_name>_component_hide
|
||||
# data:
|
||||
# id: "date" # Example: Hides the date display on the Home page.
|
||||
# visible: false # Set to true to show the component, or false to hide it.
|
||||
#
|
||||
# NOTE: Replace <your_panel_name> with the specific panel name in your Home Assistant setup to ensure correct service execution.
|
||||
# Ensure the 'id' matches the component on your display you wish to hide/show.
|
||||
#
|
||||
# IMPORTANT: This service functions only when the target page is visible.
|
||||
# If the component being hidden/shown is not on the current page, the command will fail, and an error message will be logged.
|
||||
- service: component_visibility
|
||||
variables:
|
||||
id: string
|
||||
visible: bool
|
||||
then:
|
||||
- lambda: |-
|
||||
if (!id(is_uploading_tft))
|
||||
set_component_visibility->execute(id.c_str(), visible);
|
||||
|
||||
# entity_details_show Service
|
||||
# Enables navigation to a page displaying detailed information about a specific entity and defines a clear path for returning to a previous page,
|
||||
# enhancing user interaction within the interface.
|
||||
#
|
||||
@@ -634,13 +613,13 @@ api:
|
||||
|
||||
// Chips icon size
|
||||
ESP_LOGV(TAG, "Chips size");
|
||||
disp1->send_command_printf("home.chip_relay1.font=%" PRIu8, chip_font);
|
||||
disp1->send_command_printf("home.chip_relay2.font=%" PRIu8, chip_font);
|
||||
disp1->send_command_printf("home.chip_climate.font=%" PRIu8, chip_font);
|
||||
disp1->send_command_printf("home.chip_relay1.font=%" PRIi32, chip_font);
|
||||
disp1->send_command_printf("home.chip_relay2.font=%" PRIi32, chip_font);
|
||||
disp1->send_command_printf("home.chip_climate.font=%" PRIi32, chip_font);
|
||||
for (int i = 1; i <= 7; ++i) {
|
||||
disp1->send_command_printf("home.chip%02d.font=%" PRIu8, i, chip_font);
|
||||
disp1->send_command_printf("home.chip%02d.font=%" PRIi32, i, chip_font);
|
||||
}
|
||||
disp1->send_command_printf("home.wifi_icon.font=%" PRIu8, chip_font);
|
||||
disp1->send_command_printf("home.wifi_icon.font=%" PRIi32, chip_font);
|
||||
id(home_chip_font_id) = chip_font;
|
||||
|
||||
// Custom buttons icon size
|
||||
@@ -1257,7 +1236,7 @@ api:
|
||||
- rtttl.play:
|
||||
rtttl: !lambda 'return tone;'
|
||||
|
||||
# Value Service ## PENDING FULL IMPLEMENTATION
|
||||
# Value Service
|
||||
# Updates an entity to display specific values with dynamic icons, names, and color codes.
|
||||
#
|
||||
# Usage: Perfect for entities requiring dynamic information display like sensor readings or state values.
|
||||
@@ -1340,30 +1319,8 @@ api:
|
||||
}
|
||||
}
|
||||
|
||||
#### DEPRECATED Service to set the entities #### USE SERVICE VALUE INSTEAD - MUST FIND A WAY TO HANDLE ALIGNMENT ON INIT
|
||||
- service: set_entity
|
||||
variables:
|
||||
ent_id: string
|
||||
ent_icon: string
|
||||
ent_label: string
|
||||
ent_value: string
|
||||
ent_value_xcen: string
|
||||
then:
|
||||
- lambda: |-
|
||||
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());
|
||||
}
|
||||
# yamllint enable rule:comments-indentation
|
||||
|
||||
debug:
|
||||
|
||||
##### START - DISPLAY START CONFIGURATION #####
|
||||
display:
|
||||
- id: disp1
|
||||
@@ -1891,10 +1848,6 @@ select:
|
||||
|
||||
##### START - SENSOR CONFIGURATION #####
|
||||
sensor:
|
||||
- platform: debug
|
||||
free:
|
||||
name: "Heap Free"
|
||||
|
||||
##### Blueprint status #####
|
||||
# Bit # Settings step #
|
||||
# 0 # reserved #
|
||||
|
||||
Reference in New Issue
Block a user