Fix icon font sizes 10 and 64

Solves https://github.com/Blackymas/NSPanel_HA_Blueprint/issues/960#issuecomment-1701903604

And also remove all the unnecessary `wait_until`
This commit is contained in:
Edward Firmo
2023-09-01 05:02:23 +02:00
parent ba5db23ae6
commit 836cd1a047
8 changed files with 29 additions and 74 deletions

3
.gitignore vendored
View File

@@ -2,4 +2,5 @@
.DS_Store
**/.DS_Store
Nextion2Text.*
*.cmd
*.bat

View File

@@ -164,8 +164,6 @@ api:
component: string
message: string
then:
- wait_until:
binary_sensor.is_on: nextion_init
- lambda: 'id(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 #####
@@ -174,8 +172,6 @@ api:
component: string
message: int
then:
- wait_until:
binary_sensor.is_on: nextion_init
- lambda: 'id(disp1).set_component_value(component.c_str(), message);'
##### Service to send a command "hide componente" directly to the display #####
@@ -183,8 +179,6 @@ api:
variables:
component: string
then:
- wait_until:
binary_sensor.is_on: nextion_init
- lambda: 'id(disp1).hide_component(component.c_str());'
##### Service to send a command "show componente" directly to the display #####
@@ -192,15 +186,11 @@ api:
variables:
component: string
then:
- wait_until:
binary_sensor.is_on: nextion_init
- lambda: 'id(disp1).show_component(component.c_str());'
##### Service to send a command "show ALL componente" directly to the display #####
- service: send_command_show_all ### unused ###
then:
- wait_until:
binary_sensor.is_on: nextion_init
- lambda: id(disp1).show_component("255");
##### Service to send a command "font color" directly to the display #####
@@ -209,8 +199,6 @@ api:
component: string
message: int
then:
- wait_until:
binary_sensor.is_on: nextion_init
- lambda: 'id(disp1).set_component_font_color(component.c_str(), message);'
##### Service to send a command "background color" directly to the display #####
@@ -219,8 +207,6 @@ api:
component: string
message: int
then:
- wait_until:
binary_sensor.is_on: nextion_init
- lambda: 'id(disp1).set_component_background_color(component.c_str(), message);'
##### Service to show a notification-message on the screen #####
@@ -230,8 +216,6 @@ api:
text: string
then:
- logger.log: "Service: notification_show"
- wait_until:
binary_sensor.is_on: nextion_init
- lambda: |-
id(disp1).send_command_printf("is_notification=1");
id(disp1).send_command_printf("page notification");
@@ -250,8 +234,6 @@ api:
- service: notification_clear
then:
- logger.log: "Service: notification_clear"
- wait_until:
binary_sensor.is_on: nextion_init
- lambda: |-
id(disp1).send_command_printf("is_notification=0");
id(notification_label).publish_state("");
@@ -268,8 +250,6 @@ api:
entity: string
back_page: string
then:
#- wait_until:
# binary_sensor.is_on: nextion_init
- lambda: |-
ESP_LOGV("api.service.open_entity_settings_page", "Starting");
ESP_LOGV("api.service.open_entity_settings_page", "page: %s", page.c_str());
@@ -357,8 +337,6 @@ api:
btn_label: string
btn_bri_txt: string
then:
- wait_until:
binary_sensor.is_on: nextion_init
- lambda: |-
// ESP_LOGV("nextion", "set button %s", btn_id.c_str());
std::string btnicon = btn_id.c_str() + std::string("icon");
@@ -404,22 +382,16 @@ api:
ent_value: string
ent_value_xcen: string
then:
- wait_until:
binary_sensor.is_on: nextion_init
- lambda: |-
// ESP_LOGV("nextion", "set entity %s", ent_id.c_str());
ESP_LOGV("service.set_entity", "entity: %s", ent_id.c_str());
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();
id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
if (strcmp(ent_icon.c_str(), "0") != 0) {
id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
}
if (strcmp(ent_icon.c_str(), "0") != 0) id(disp1).set_component_text_printf(enticon.c_str(), "%s", ent_icon.c_str());
id(disp1).set_component_text_printf(entlabel.c_str(), "%s", ent_label.c_str());
id(disp1).set_component_text_printf(ent_id.c_str(), "%s", ent_value.c_str());
if (strcmp(ent_value_xcen.c_str(), "0") != 0) {
id(disp1).send_command_printf("%s", entxcen.c_str());
}
if (strcmp(ent_value_xcen.c_str(), "0") != 0) id(disp1).send_command_printf("%s", entxcen.c_str());
##### Service for transferring global settings from the blueprint to ESPHome #####
- service: global_settings
@@ -909,12 +881,15 @@ sensor:
reference_resistance: 10kOhm
filters:
- lambda: return x + id(temperature_correction_global);
#on_value:
# then:
# - wait_until:
# binary_sensor.is_on: nextion_init
# - lambda: id(disp1).set_component_text_printf("home.current_temp", "%.1f°", id(temp_nspanel).state); # onboard temp (thermostat temp) to home page.
# - lambda: id(disp1).set_component_text_printf("climate.current_temp", "%.1f", id(temp_nspanel).state);
on_value:
then:
# Show panel's temperature if API is out
- if:
condition:
- not:
api.connected:
then:
- lambda: id(disp1).set_component_text_printf("home.current_temp", "%.1f°", id(temp_nspanel).state);
###### Display Brightness GET VALUE FROM NSPanel SLIDER #####
- name: ${device_name} brightness Slider
@@ -924,8 +899,6 @@ sensor:
internal: true
on_value:
then:
- wait_until:
binary_sensor.is_on: nextion_init
- number.set:
id: display_brightness
value: !lambda 'return int(x);'
@@ -940,8 +913,6 @@ sensor:
internal: true
on_value:
then:
- wait_until:
binary_sensor.is_on: nextion_init
- number.set:
id: display_dim_brightness
value: !lambda 'return int(x);'
@@ -1392,12 +1363,13 @@ display:
- logger.log: "NEXTION PAGE CHANGED"
on_setup:
then:
- lambda: id(disp1).send_command_printf("page 8");
- lambda: id(disp1).set_component_text_printf("boot.esph_version", "%s", "${version}"); ### esphome-version ###
- lambda: |-
id(disp1).send_command_printf("page 8");
id(disp1).set_component_text_printf("boot.esph_version", "%s", "${version}"); // ### esphome-version ###
- wait_until:
api.connected
- lambda: id(disp1).set_component_text_printf("boot.ip_addr", "%s", id(ip_address).state.c_str());
- lambda: |-
id(disp1).set_component_text_printf("boot.ip_addr", "%s", id(ip_address).state.c_str());
auto ha_event = new esphome::api::CustomAPIDevice();
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{
@@ -1405,36 +1377,29 @@ display:
{"step", "start"}
});
- delay: 1s
- number.set:
id: display_brightness
value: !lambda 'return id(display_brightness_global);'
- number.set:
id: display_dim_brightness
value: !lambda 'return id(display_dim_brightness_global);'
- lambda: id(disp1).set_component_text_printf("settings.a03", "%i", id(display_brightness_global));
- lambda: id(disp1).set_component_text_printf("settings.a04", "%i", id(display_dim_brightness_global));
- lambda: id(disp1).send_command_printf("settings.brightslider.val=%i", id(display_brightness_global));
- lambda: id(disp1).send_command_printf("settings.dimslider.val=%i", id(display_dim_brightness_global));
- lambda: |-
id(display_brightness).publish_state(id(display_brightness_global));
id(display_dim_brightness).publish_state(id(display_dim_brightness_global));
id(disp1).set_component_text_printf("settings.a03", "%i", id(display_brightness_global));
id(disp1).set_component_text_printf("settings.a04", "%i", id(display_dim_brightness_global));
id(disp1).send_command_printf("settings.brightslider.val=%i", id(display_brightness_global));
id(disp1).send_command_printf("settings.dimslider.val=%i", id(display_dim_brightness_global));
- if:
condition:
switch.is_off: sleep_mode
then: *sleep_mode-turn_off
else: *sleep_mode-turn_on
- delay: 1s
- binary_sensor.template.publish:
id: nextion_init
state: true
- lambda: |-
id(nextion_init).publish_state(true);
auto ha_event = new esphome::api::CustomAPIDevice();
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{
{"type", "boot"},
{"step", "nextion_init"}
});
#- script.execute:
# id: refresh_colors
- lambda: id(home_relay1_icon) = "\uE3A5";
- lambda: id(home_relay1_icon) = "\uE3A8";
id(home_relay1_icon) = "\uE3A5";
id(home_relay1_icon) = "\uE3A8";
- logger.log: "Nextion start - Done!"
### Script for page_timer
@@ -1451,9 +1416,7 @@ script:
deserializeJson(doc, id(disp1_nspanel_event).state);
std::string page = doc["page"];
if (page == "home" or page == "screensaver" or page == "boot" or int(id(page_timeout).state) == 0)
{
ESP_LOGD("script.page_timer", "no page-jump");
}
ESP_LOGD("script.page_timer", "no page-jump");
else
{
ESP_LOGD("script.page_timer", "timer->home");
@@ -1474,7 +1437,6 @@ script:
- lambda: ESP_LOGV("script.set_climate", "Starting");
- if:
condition:
- binary_sensor.is_on: nextion_init
- text_sensor.state: # Is climate page visible?
id: current_page
state: 'climate'
@@ -1610,7 +1572,6 @@ script:
- lambda: ESP_LOGV("script.update_page_home", "Starting");
- if:
condition:
#- binary_sensor.is_on: nextion_init
- text_sensor.state: # Is home page visible?
id: current_page
state: 'home'
@@ -1619,13 +1580,6 @@ script:
- script.execute: refresh_relays
- script.execute: refresh_wifi_icon
- script.execute: addon_climate_update_page_home
# Show panel's temperature if API is out
- if:
condition:
- not:
api.connected:
then:
- lambda: id(disp1).set_component_text_printf("home.current_temp", "%.1f°", id(temp_nspanel).state);
- lambda: ESP_LOGV("script.update_page_home", "Finished");

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.