Removed ${verbose_log}

Use logger level `VERBOSE` instead
This commit is contained in:
Edward Firmo
2023-08-25 22:19:54 +02:00
parent 8989a65f03
commit 15b453c3ab

View File

@@ -6,12 +6,9 @@
##################################################################################################### #####################################################################################################
substitutions: substitutions:
# Defaults
verbose_log: "false"
##### DON'T CHANGE THIS ##### ##### DON'T CHANGE THIS #####
version: "4.0" version: "4.0"
addon_climate: "false"
############################# #############################
##### WIFI SETUP ##### ##### WIFI SETUP #####
@@ -84,7 +81,7 @@ time:
id: refresh_datetime id: refresh_datetime
on_time_sync: on_time_sync:
then: then:
- logger.log: "Synchronized system clock" - logger.log: "System clock synchronized"
- script.execute: - script.execute:
id: refresh_datetime id: refresh_datetime
@@ -319,16 +316,13 @@ api:
embedded_climate: bool embedded_climate: bool
then: then:
- lambda: |- - lambda: |-
if (${verbose_log}) ESP_LOGV("api.service.set_climate", "climateslider.maxval=%i", total_steps);
{ ESP_LOGV("api.service.set_climate", "temp_offset=%f", temp_offset);
ESP_LOGD("api.service.set_climate", "climateslider.maxval=%i", total_steps); ESP_LOGV("api.service.set_climate", "temp_step=%f", temp_step);
ESP_LOGD("api.service.set_climate", "temp_offset=%f", temp_offset); ESP_LOGV("api.service.set_climate", "current_temp=%f", current_temp);
ESP_LOGD("api.service.set_climate", "temp_step=%f", temp_step); ESP_LOGV("api.service.set_climate", "target_temp=%f", target_temp);
ESP_LOGD("api.service.set_climate", "current_temp=%f", current_temp); ESP_LOGV("api.service.set_climate", "target_icon=%s", climate_icon.c_str());
ESP_LOGD("api.service.set_climate", "target_temp=%f", target_temp); ESP_LOGV("api.service.set_climate", "embedded=%i", (embedded_climate) ? 1 : 0);
ESP_LOGD("api.service.set_climate", "target_icon=%s", climate_icon.c_str());
ESP_LOGD("api.service.set_climate", "embedded=%i", (embedded_climate) ? 1 : 0);
}
- script.execute: - script.execute:
id: set_climate id: set_climate
@@ -356,7 +350,7 @@ api:
- wait_until: - wait_until:
binary_sensor.is_on: nextion_init binary_sensor.is_on: nextion_init
- lambda: |- - lambda: |-
// ESP_LOGD("nextion", "set button %s", btn_id.c_str()); // ESP_LOGV("nextion", "set button %s", btn_id.c_str());
std::string btnicon = btn_id.c_str() + std::string("icon"); std::string btnicon = btn_id.c_str() + std::string("icon");
std::string btntext = btn_id.c_str() + std::string("text"); std::string btntext = btn_id.c_str() + std::string("text");
std::string btnbri = btn_id.c_str() + std::string("bri"); std::string btnbri = btn_id.c_str() + std::string("bri");
@@ -419,7 +413,7 @@ api:
- wait_until: - wait_until:
binary_sensor.is_on: nextion_init binary_sensor.is_on: nextion_init
- lambda: |- - lambda: |-
// ESP_LOGD("nextion", "set entity %s", ent_id.c_str()); // ESP_LOGV("nextion", "set entity %s", ent_id.c_str());
std::string enticon = ent_id.c_str() + std::string("_pic"); std::string enticon = ent_id.c_str() + std::string("_pic");
std::string entlabel = ent_id.c_str() + std::string("_label"); 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(); std::string entxcen = ent_id.c_str() + std::string(".xcen=") + ent_value_xcen.c_str();
@@ -448,26 +442,22 @@ api:
embedded_climate: bool embedded_climate: bool
wakeup_page: int wakeup_page: int
then: then:
## Logs
- lambda: if (${verbose_log}) ESP_LOGD("service.global_settings", "Starting");
- lambda: |- - lambda: |-
if (${verbose_log}) // Logs - Begin
{ ESP_LOGV("service.global_settings", "Starting");
ESP_LOGD("service.global_settings", "relay1_local_control: %i", (relay1_local_control) ? 1 : 0); ESP_LOGV("service.global_settings", "relay1_local_control: %i", (relay1_local_control) ? 1 : 0);
ESP_LOGD("service.global_settings", "relay1_icon: %s", relay1_icon.c_str()); ESP_LOGV("service.global_settings", "relay1_icon: %s", relay1_icon.c_str());
ESP_LOGD("service.global_settings", "relay1_icon_color: %i", relay1_icon_color); ESP_LOGV("service.global_settings", "relay1_icon_color: %i", relay1_icon_color);
ESP_LOGD("service.global_settings", "relay2_local_control: %i", (relay2_local_control) ? 1 : 0); ESP_LOGV("service.global_settings", "relay2_local_control: %i", (relay2_local_control) ? 1 : 0);
ESP_LOGD("service.global_settings", "relay2_icon: %s", relay2_icon.c_str()); ESP_LOGV("service.global_settings", "relay2_icon: %s", relay2_icon.c_str());
ESP_LOGD("service.global_settings", "relay2_icon_color: %i", relay2_icon_color); ESP_LOGV("service.global_settings", "relay2_icon_color: %i", relay2_icon_color);
ESP_LOGD("service.global_settings", "date_color: %i", date_color); ESP_LOGV("service.global_settings", "date_color: %i", date_color);
ESP_LOGD("service.global_settings", "time_format: %s", time_format.c_str()); ESP_LOGV("service.global_settings", "time_format: %s", time_format.c_str());
ESP_LOGD("service.global_settings", "time_color: %i", time_color); ESP_LOGV("service.global_settings", "time_color: %i", time_color);
ESP_LOGD("service.global_settings", "embedded_climate: %i", (embedded_climate) ? 1 : 0); ESP_LOGV("service.global_settings", "embedded_climate: %i", (embedded_climate) ? 1 : 0);
ESP_LOGD("service.global_settings", "wakeup_page: %i", wakeup_page); ESP_LOGV("service.global_settings", "wakeup_page: %i", wakeup_page);
}
## Relays // Relays
- lambda: |-
id(relay1_local).publish_state(relay1_local_control); id(relay1_local).publish_state(relay1_local_control);
id(relay2_local).publish_state(relay2_local_control); id(relay2_local).publish_state(relay2_local_control);
id(home_relay1_icon) = relay1_icon.c_str(); id(home_relay1_icon) = relay1_icon.c_str();
@@ -475,36 +465,30 @@ api:
id(home_relay1_icon_color) = relay1_icon_color; id(home_relay1_icon_color) = relay1_icon_color;
id(home_relay2_icon_color) = relay2_icon_color; id(home_relay2_icon_color) = relay2_icon_color;
## Localization // Localization
- lambda: id(mui_time_format) = time_format; id(mui_time_format) = time_format;
## Date/Time colors // Date/Time colors
- lambda: |-
id(home_date_color) = date_color; id(home_date_color) = date_color;
id(home_time_color) = time_color; id(home_time_color) = time_color;
## Embedded thermostat // Embedded thermostat
- script.execute: id(addon_climate_global_settings)->execute(embedded_climate);
id: addon_climate_global_settings
embedded_climate: !lambda return embedded_climate;
#- lambda: id(is_embedded_thermostat) = embedded_climate;
## Wakeup page // Wakeup page
- lambda: |- ESP_LOGV("service.global_settings", "Wakeup page - Start");
if (${verbose_log}) ESP_LOGD("service.global_settings", "Wakeup page - Start");
id(wakeup_page_id) = wakeup_page; id(wakeup_page_id) = wakeup_page;
## Refresh colors of global components // Refresh colors of global components
#- lambda: if (${verbose_log}) ESP_LOGD("service.global_settings", "Refresh colors of global components"); ESP_LOGV("service.global_settings", "Refresh colors of global components");
#- script.execute: id(refresh_colors).execute;
# id: refresh_colors
## Update home page // Update home page
- lambda: if (${verbose_log}) ESP_LOGD("service.global_settings", "Update home page"); ESP_LOGV("service.global_settings", "Update home page");
- script.execute: id(update_page_home).execute;
id: update_page_home
- lambda: if (${verbose_log}) ESP_LOGD("service.global_settings", "Finished"); // Logs - End
ESP_LOGV("service.global_settings", "Finished");
#### Service to populate the page Home ##### #### Service to populate the page Home #####
- service: page_home_settings - service: page_home_settings
@@ -517,40 +501,36 @@ api:
entities_pages_icon_color: int entities_pages_icon_color: int
alarm_state: string alarm_state: string
then: then:
## Logs
- lambda: if (${verbose_log}) ESP_LOGD("service.page_home_settings", "Starting");
- lambda: |- - lambda: |-
if (${verbose_log}) // Logs - Begin
{ ESP_LOGV("service.page_home_settings", "Starting");
ESP_LOGD("service.page_home_settings", "qrcode: %i", (qrcode) ? 1 : 0); ESP_LOGV("service.page_home_settings", "qrcode: %i", (qrcode) ? 1 : 0);
ESP_LOGD("service.page_home_settings", "qrcode_icon: %s", qrcode_icon.c_str()); ESP_LOGV("service.page_home_settings", "qrcode_icon: %s", qrcode_icon.c_str());
ESP_LOGD("service.page_home_settings", "qrcode_icon_color: %i", qrcode_icon_color); ESP_LOGV("service.page_home_settings", "qrcode_icon_color: %i", qrcode_icon_color);
ESP_LOGD("service.page_home_settings", "entities_pages: %i", (entities_pages) ? 1 : 0); ESP_LOGV("service.page_home_settings", "entities_pages: %i", (entities_pages) ? 1 : 0);
ESP_LOGD("service.page_home_settings", "entities_pages_icon: %s", entities_pages_icon.c_str()); ESP_LOGV("service.page_home_settings", "entities_pages_icon: %s", entities_pages_icon.c_str());
ESP_LOGD("service.page_home_settings", "entities_pages_icon_color: %i", entities_pages_icon_color); ESP_LOGV("service.page_home_settings", "entities_pages_icon_color: %i", entities_pages_icon_color);
ESP_LOGD("service.page_home_settings", "alarm_state: %s", alarm_state.c_str()); ESP_LOGV("service.page_home_settings", "alarm_state: %s", alarm_state.c_str());
}
## QRCode button // QRCode button
- lambda: |- ESP_LOGV("service.page_home_settings", "QRcode button - Start");
if (${verbose_log}) ESP_LOGD("service.page_home_settings", "QRcode button - Start");
id(disp1).send_command_printf("is_qrcode=%i", (qrcode) ? 1 : 0); id(disp1).send_command_printf("is_qrcode=%i", (qrcode) ? 1 : 0);
id(disp1).set_component_text_printf("home.bt_qrcode", "%s", qrcode_icon.c_str()); id(disp1).set_component_text_printf("home.bt_qrcode", "%s", qrcode_icon.c_str());
id(disp1).set_component_font_color("home.bt_qrcode", qrcode_icon_color); id(disp1).set_component_font_color("home.bt_qrcode", qrcode_icon_color);
## Entities pages button // Entities pages button
- lambda: |- ESP_LOGV("service.page_home_settings", "Entities pages button - Start");
if (${verbose_log}) ESP_LOGD("service.page_home_settings", "Entities pages button - Start");
id(disp1).send_command_printf("is_entities=%i", (entities_pages) ? 1 : 0); id(disp1).send_command_printf("is_entities=%i", (entities_pages) ? 1 : 0);
id(disp1).set_component_text_printf("home.bt_entities", "%s", entities_pages_icon.c_str()); id(disp1).set_component_text_printf("home.bt_entities", "%s", entities_pages_icon.c_str());
id(disp1).set_component_font_color("home.bt_entities", entities_pages_icon_color); id(disp1).set_component_font_color("home.bt_entities", entities_pages_icon_color);
## Alarm button // Alarm button
- lambda: |- ESP_LOGV("service.page_home_settings", "Alarm button - Start");
if (${verbose_log}) ESP_LOGD("service.page_home_settings", "Alarm button - Start");
id(disp1).send_command_printf("is_alarm=%i", (alarm_state=="" or alarm_state.empty()) ? 0 : 1); id(disp1).send_command_printf("is_alarm=%i", (alarm_state=="" or alarm_state.empty()) ? 0 : 1);
id(update_alarm_icon)->execute("home.bt_alarm", alarm_state.c_str()); id(update_alarm_icon)->execute("home.bt_alarm", alarm_state.c_str());
- lambda: if (${verbose_log}) ESP_LOGD("service.page_home_settings", "Finished"); // Logs - End
ESP_LOGV("service.page_home_settings", "Finished");
#### Service to populate the alarm settings page ##### #### Service to populate the alarm settings page #####
- service: alarm_settings - service: alarm_settings
@@ -564,32 +544,24 @@ api:
mui_alarm: string[] #std::vector<std::string> #std::map mui_alarm: string[] #std::vector<std::string> #std::map
then: then:
- lambda: |- - lambda: |-
// log // Logs - Begin
if (${verbose_log}) ESP_LOGV("service.alarm_settings", "Starting");
{ ESP_LOGV("service.alarm_settings", "page_title: %s", page_title.c_str());
ESP_LOGD("service.alarm_settings", "Starting"); ESP_LOGV("service.alarm_settings", "state: %s", state.c_str());
ESP_LOGD("service.alarm_settings", "page_title: %s", page_title.c_str()); ESP_LOGV("service.alarm_settings", "supported_features: %i", supported_features);
ESP_LOGD("service.alarm_settings", "state: %s", state.c_str()); ESP_LOGV("service.alarm_settings", "code_format: %s", code_format.c_str());
ESP_LOGD("service.alarm_settings", "supported_features: %i", supported_features); ESP_LOGV("service.alarm_settings", "code_arm_required: %i", (code_arm_required) ? 1 : 0);
ESP_LOGD("service.alarm_settings", "code_format: %s", code_format.c_str()); ESP_LOGV("service.alarm_settings", "entity: %s", entity.c_str());
ESP_LOGD("service.alarm_settings", "code_arm_required: %i", (code_arm_required) ? 1 : 0);
ESP_LOGD("service.alarm_settings", "entity: %s", entity.c_str());
}
// set alarm icon on home page // set alarm icon on home page
if (${verbose_log}) ESP_LOGD("service.alarm_settings", "Updating home page icon"); ESP_LOGV("service.alarm_settings", "Updating home page icon");
id(disp1).send_command_printf("is_alarm=%i", (state=="" or state.empty()) ? 0 : 1); id(disp1).send_command_printf("is_alarm=%i", (state=="" or state.empty()) ? 0 : 1);
id(update_alarm_icon)->execute("home.bt_alarm", state.c_str()); id(update_alarm_icon)->execute("home.bt_alarm", state.c_str());
## Update alarm page // Is page Alarm visible?
- if: if (id(current_page).state=="alarm")
condition: { // Update alarm page
- text_sensor.state: # Is alarm page visible? ESP_LOGV("service.alarm_settings", "Updating alarm page");
id: current_page
state: 'alarm'
then:
- lambda: |-
if (${verbose_log}) ESP_LOGD("service.alarm_settings", "Updating alarm page");
// Alarm page - Header // Alarm page - Header
id(update_alarm_icon)->execute("icon_state", state.c_str()); id(update_alarm_icon)->execute("icon_state", state.c_str());
id(disp1).set_component_text_printf("page_label", "%s", page_title.c_str()); id(disp1).set_component_text_printf("page_label", "%s", page_title.c_str());
@@ -668,7 +640,10 @@ api:
id(disp1).set_component_font_color("bt_disarm_icon", (state=="disarmed") ? 65535 : 0); id(disp1).set_component_font_color("bt_disarm_icon", (state=="disarmed") ? 65535 : 0);
if (state=="disarmed") id(disp1).hide_component("bt_disarm"); else id(disp1).show_component("bt_disarm"); if (state=="disarmed") id(disp1).hide_component("bt_disarm"); else id(disp1).show_component("bt_disarm");
} }
- lambda: if (${verbose_log}) ESP_LOGD("service.alarm_settings", "Finished"); }
// Logs - End
ESP_LOGV("service.alarm_settings", "Finished");
##### START - GLOBALS CONFIGURATION ##### ##### START - GLOBALS CONFIGURATION #####
globals: globals:
@@ -1038,14 +1013,11 @@ text_sensor:
std::string entity = doc["entity"]; std::string entity = doc["entity"];
int embedded = doc["embedded"]; int embedded = doc["embedded"];
std::string service = ""; std::string service = "";
if (${verbose_log}) ESP_LOGV("text_sensor.localevent", "domain=%s", domain.c_str());
{ ESP_LOGV("text_sensor.localevent", "key=%s", key.c_str());
ESP_LOGD("text_sensor.localevent", "domain=%s", domain.c_str()); ESP_LOGV("text_sensor.localevent", "value=%s", value.c_str());
ESP_LOGD("text_sensor.localevent", "key=%s", key.c_str()); ESP_LOGV("text_sensor.localevent", "entity=%s", entity.c_str());
ESP_LOGD("text_sensor.localevent", "value=%s", value.c_str()); ESP_LOGV("text_sensor.localevent", "embedded=%i", embedded);
ESP_LOGD("text_sensor.localevent", "entity=%s", entity.c_str());
ESP_LOGD("text_sensor.localevent", "embedded=%i", embedded);
}
if (domain == "climate") id(service_call_climate)->execute(entity.c_str(), key.c_str(), value.c_str(), (embedded==1)); if (domain == "climate") id(service_call_climate)->execute(entity.c_str(), key.c_str(), value.c_str(), (embedded==1));
else if (domain == "alarm") else if (domain == "alarm")
{ {
@@ -1366,7 +1338,7 @@ script:
parameters: parameters:
delay: int delay: int
then: then:
- lambda: if (${verbose_log}) ESP_LOGD("script.page_timer", "start page-timer delay %i", int(id(page_timeout).state)); - lambda: ESP_LOGV("script.page_timer", "start page-timer delay %i", int(id(page_timeout).state));
- delay: !lambda return delay *1000; - delay: !lambda return delay *1000;
- lambda: |- - lambda: |-
DynamicJsonDocument doc(1024); DynamicJsonDocument doc(1024);
@@ -1374,11 +1346,11 @@ script:
std::string page = doc["page"]; std::string page = doc["page"];
if (page == "home" or page == "screensaver" or page == "boot" or int(id(page_timeout).state) == 0) if (page == "home" or page == "screensaver" or page == "boot" or int(id(page_timeout).state) == 0)
{ {
if (${verbose_log}) ESP_LOGD("script.page_timer", "no page-jump"); ESP_LOGD("script.page_timer", "no page-jump");
} }
else else
{ {
if (${verbose_log}) ESP_LOGD("script.page_timer", "timer->home"); ESP_LOGD("script.page_timer", "timer->home");
id(disp1).send_command_printf("page 0"); id(disp1).send_command_printf("page 0");
} }
@@ -1401,16 +1373,13 @@ script:
state: 'climate' state: 'climate'
then: then:
- lambda: |- - lambda: |-
if (${verbose_log}) ESP_LOGV("script.set_climate", "climateslider.maxval=%i", total_steps);
{ ESP_LOGV("script.set_climate", "temp_offset=%i", temp_offset);
ESP_LOGD("script.set_climate", "climateslider.maxval=%i", total_steps); ESP_LOGV("script.set_climate", "temp_step=%i", temp_step);
ESP_LOGD("script.set_climate", "temp_offset=%i", temp_offset); ESP_LOGV("script.set_climate", "current_temp=%f", current_temp);
ESP_LOGD("script.set_climate", "temp_step=%i", temp_step); ESP_LOGV("script.set_climate", "target_temp=%f", target_temp);
ESP_LOGD("script.set_climate", "current_temp=%f", current_temp); ESP_LOGV("script.set_climate", "target_icon=%s", climate_icon.c_str());
ESP_LOGD("script.set_climate", "target_temp=%f", target_temp); ESP_LOGV("script.set_climate", "embedded=%i", (embedded_climate) ? 1 : 0);
ESP_LOGD("script.set_climate", "target_icon=%s", climate_icon.c_str());
ESP_LOGD("script.set_climate", "embedded=%i", (embedded_climate) ? 1 : 0);
}
id(addon_climate_set_climate).execute(embedded_climate); id(addon_climate_set_climate).execute(embedded_climate);
id(disp1).send_command_printf("climateslider.maxval=%i", total_steps); id(disp1).send_command_printf("climateslider.maxval=%i", total_steps);
id(disp1).set_component_value("temp_offset", temp_offset); id(disp1).set_component_value("temp_offset", temp_offset);
@@ -1421,7 +1390,7 @@ script:
if (target_temp > -999) if (target_temp > -999)
{ {
float slider_val = round(((10*target_temp) - temp_offset) / temp_step); float slider_val = round(((10*target_temp) - temp_offset) / temp_step);
if (${verbose_log}) ESP_LOGD("script.set_climate", "climateslider=%f", slider_val); ESP_LOGV("script.set_climate", "climateslider=%f", slider_val);
id(disp1).set_component_value("climateslider", slider_val); id(disp1).set_component_value("climateslider", slider_val);
id(disp1).set_component_text_printf("target_temp", "%.1f°", target_temp); id(disp1).set_component_text_printf("target_temp", "%.1f°", target_temp);
id(disp1).set_component_text_printf("target_icon", "%s", climate_icon.c_str()); id(disp1).set_component_text_printf("target_icon", "%s", climate_icon.c_str());
@@ -1444,90 +1413,66 @@ script:
- id: refresh_colors ## Refresh colors of global components - id: refresh_colors ## Refresh colors of global components
mode: restart mode: restart
then: then:
- if: - lambda: |-
condition: id(disp1).set_component_font_color("home.date", id(home_date_color));
- binary_sensor.is_on: nextion_init id(disp1).set_component_font_color("home.time", id(home_time_color));
#- text_sensor.state: # Is home page visible? id(disp1).set_component_font_color("home.icon_top_01", id(home_relay1_icon_color));
# id: current_page id(disp1).set_component_font_color("home.icon_top_02", id(home_relay2_icon_color));
# state: 'home'
then:
- lambda: |-
id(disp1).set_component_font_color("home.date", id(home_date_color));
id(disp1).set_component_font_color("home.time", id(home_time_color));
id(disp1).set_component_font_color("home.icon_top_01", id(home_relay1_icon_color));
id(disp1).set_component_font_color("home.icon_top_02", id(home_relay2_icon_color));
- id: refresh_datetime - id: refresh_datetime
mode: restart mode: restart
then: then:
- lambda: if (${verbose_log}) ESP_LOGD("script.refresh_datetime", "Starting"); - lambda: |-
- if: ESP_LOGV("script.refresh_datetime", "Starting");
condition: std::string time_format_str = id(mui_time_format);
- binary_sensor.is_on: nextion_init if (time_format_str.find("%p") != std::string::npos)
#- text_sensor.state: # Is home page visible? {
# id: current_page std::string meridiem_text = id(time_provider).now().strftime("%p");
# state: 'home' id(disp1).set_component_text_printf("home.meridiem", "%s", meridiem_text.c_str());
then: }
- lambda: |- else { id(disp1).set_component_text_printf("home.meridiem", " "); }
std::string time_format_str = id(mui_time_format); if (time_format_str.find("%-H") != std::string::npos) { time_format_str = time_format_str.replace(time_format_str.find("%-H"), sizeof("%-H")-1, to_string((int)(id(time_provider).now().hour))); }
if (time_format_str.find("%p") != std::string::npos) if (time_format_str.find("%-I") != std::string::npos)
{
if (id(time_provider).now().hour>12)
{ {
std::string meridiem_text = id(time_provider).now().strftime("%p"); time_format_str = time_format_str.replace(time_format_str.find("%-I"), sizeof("%-I")-1, to_string((int)(id(time_provider).now().hour-12)));
id(disp1).set_component_text_printf("home.meridiem", "%s", meridiem_text.c_str());
} }
else { id(disp1).set_component_text_printf("home.meridiem", " "); } else if (id(time_provider).now().hour==0)
if (time_format_str.find("%-H") != std::string::npos) { time_format_str = time_format_str.replace(time_format_str.find("%-H"), sizeof("%-H")-1, to_string((int)(id(time_provider).now().hour))); }
if (time_format_str.find("%-I") != std::string::npos)
{ {
if (id(time_provider).now().hour>12) time_format_str = time_format_str.replace(time_format_str.find("%-I"), sizeof("%-I")-1, "12");
{
time_format_str = time_format_str.replace(time_format_str.find("%-I"), sizeof("%-I")-1, to_string((int)(id(time_provider).now().hour-12)));
}
else if (id(time_provider).now().hour==0)
{
time_format_str = time_format_str.replace(time_format_str.find("%-I"), sizeof("%-I")-1, "12");
}
else
{
time_format_str = time_format_str.replace(time_format_str.find("%-I"), sizeof("%-I")-1, to_string((int)(id(time_provider).now().hour)));
}
} }
std::string time_text = id(time_provider).now().strftime(time_format_str); else
id(disp1).set_component_text_printf("home.time", "%s", time_text.c_str()); {
- lambda: if (${verbose_log}) ESP_LOGD("script.refresh_datetime", "Finished"); time_format_str = time_format_str.replace(time_format_str.find("%-I"), sizeof("%-I")-1, to_string((int)(id(time_provider).now().hour)));
}
}
std::string time_text = id(time_provider).now().strftime(time_format_str);
id(disp1).set_component_text_printf("home.time", "%s", time_text.c_str());
ESP_LOGV("script.refresh_datetime", "Finished");
- id: refresh_relays - id: refresh_relays
mode: restart mode: restart
then: then:
- lambda: if (${verbose_log}) ESP_LOGD("script.refresh_relays", "Starting"); - lambda: |-
- if: ESP_LOGV("script.refresh_relays", "Starting");
condition: // Chips - Relays
- binary_sensor.is_on: nextion_init if (id(relay_1).state) id(disp1).set_component_text_printf("home.icon_top_01", "%s", id(home_relay1_icon).c_str());
#- text_sensor.state: # Is home page visible? else id(disp1).set_component_text_printf("icon_top_01", "\uFFFF");
# id: current_page if (id(relay_2).state) id(disp1).set_component_text_printf("home.icon_top_02", "%s", id(home_relay2_icon).c_str());
# state: 'home' else id(disp1).set_component_text_printf("home.icon_top_02", "\uFFFF");
then: // Hardware buttons - Fallback mode
- lambda: |- if (id(relay_1).state and (id(relay1_local).state or (id(relay1_fallback).state and not id(api_status).state))) id(disp1).send_command_printf("home.left_bt_pic.pic=%i", (id(relay_1).state) ? 78 : 77);
// Chips - Relays if (id(relay_2).state and (id(relay2_local).state or (id(relay2_fallback).state and not id(api_status).state))) id(disp1).send_command_printf("home.right_bt_pic.pic=%i", (id(relay_2).state) ? 78 : 77);
if (id(relay_1).state) id(disp1).set_component_text_printf("home.icon_top_01", "%s", id(home_relay1_icon).c_str()); ESP_LOGV("script.refresh_relays", "Finished");
else id(disp1).set_component_text_printf("icon_top_01", "\uFFFF");
if (id(relay_2).state) id(disp1).set_component_text_printf("home.icon_top_02", "%s", id(home_relay2_icon).c_str());
else id(disp1).set_component_text_printf("home.icon_top_02", "\uFFFF");
// Hardware buttons - Fallback mode
if (id(relay_1).state and (id(relay1_local).state or (id(relay1_fallback).state and not id(api_status).state))) id(disp1).send_command_printf("home.left_bt_pic.pic=%i", (id(relay_1).state) ? 78 : 77);
if (id(relay_2).state and (id(relay2_local).state or (id(relay2_fallback).state and not id(api_status).state))) id(disp1).send_command_printf("home.right_bt_pic.pic=%i", (id(relay_2).state) ? 78 : 77);
- lambda: if (${verbose_log}) ESP_LOGD("script.refresh_relays", "Finished");
- id: refresh_wifi_icon - id: refresh_wifi_icon
mode: restart mode: restart
then: then:
- lambda: if (${verbose_log}) ESP_LOGD("script.refresh_wifi_icon", "Starting"); - lambda: ESP_LOGV("script.refresh_wifi_icon", "Starting");
- if: - if:
condition: condition:
- binary_sensor.is_on: nextion_init - binary_sensor.is_on: nextion_init
#- text_sensor.state: # Is home page visible?
# id: current_page
# state: 'home'
then: then:
# Update Wi-Fi icon # Update Wi-Fi icon
- if: - if:
@@ -1549,12 +1494,12 @@ script:
- lambda: id(disp1).send_command_printf("api=0"); - lambda: id(disp1).send_command_printf("api=0");
- lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uE5A9"); - lambda: id(disp1).set_component_text_printf("home.wifi_icon", "%s", "\uE5A9");
- lambda: id(disp1).set_component_font_color("home.wifi_icon", 63488); - lambda: id(disp1).set_component_font_color("home.wifi_icon", 63488);
- lambda: if (${verbose_log}) ESP_LOGD("script.refresh_wifi_icon", "Finished"); - lambda: ESP_LOGV("script.refresh_wifi_icon", "Finished");
- id: update_page_home - id: update_page_home
mode: restart mode: restart
then: then:
- lambda: if (${verbose_log}) ESP_LOGD("script.update_page_home", "Starting"); - lambda: ESP_LOGV("script.update_page_home", "Starting");
- if: - if:
condition: condition:
#- binary_sensor.is_on: nextion_init #- binary_sensor.is_on: nextion_init
@@ -1566,7 +1511,7 @@ script:
- script.execute: refresh_relays - script.execute: refresh_relays
- script.execute: refresh_wifi_icon - script.execute: refresh_wifi_icon
- script.execute: addon_climate_update_page_home - script.execute: addon_climate_update_page_home
- lambda: if (${verbose_log}) ESP_LOGD("script.update_page_home", "Finished"); - lambda: ESP_LOGV("script.update_page_home", "Finished");
- id: service_call_alarm_control_panel - id: service_call_alarm_control_panel
mode: restart mode: restart
@@ -1577,14 +1522,11 @@ script:
pin: string pin: string
then: then:
- lambda: |- - lambda: |-
if (${verbose_log}) ESP_LOGV("service_call_alarm_control_panel", "ESPHome remote service call");
{ ESP_LOGV("service_call_alarm_control_panel", "entity=%s", entity.c_str());
ESP_LOGD("service_call_alarm_control_panel", "ESPHome remote service call"); ESP_LOGV("service_call_alarm_control_panel", "key=%s", key.c_str());
ESP_LOGD("service_call_alarm_control_panel", "entity=%s", entity.c_str()); ESP_LOGV("service_call_alarm_control_panel", "code_format=%s", code_format.c_str());
ESP_LOGD("service_call_alarm_control_panel", "key=%s", key.c_str()); ESP_LOGV("service_call_alarm_control_panel", "pin=%s", entity.c_str());
ESP_LOGD("service_call_alarm_control_panel", "code_format=%s", code_format.c_str());
ESP_LOGD("service_call_alarm_control_panel", "pin=%s", entity.c_str());
}
std::string service = ""; std::string service = "";
if (key=="home") service = "alarm_control_panel.alarm_arm_home"; if (key=="home") service = "alarm_control_panel.alarm_arm_home";
else if (key=="away") service = "alarm_control_panel.alarm_arm_away"; else if (key=="away") service = "alarm_control_panel.alarm_arm_away";
@@ -1592,10 +1534,10 @@ script:
else if (key=="vacation") service = "alarm_control_panel.alarm_arm_vacation"; else if (key=="vacation") service = "alarm_control_panel.alarm_arm_vacation";
else if (key=="bypass") service = "alarm_control_panel.alarm_arm_custom_bypass"; else if (key=="bypass") service = "alarm_control_panel.alarm_arm_custom_bypass";
else if (key=="disarm") service = "alarm_control_panel.alarm_disarm"; else if (key=="disarm") service = "alarm_control_panel.alarm_disarm";
if (${verbose_log}) ESP_LOGD("service_call_alarm_control_panel", "service=%s", service.c_str()); ESP_LOGV("service_call_alarm_control_panel", "service=%s", service.c_str());
if (service != "" and not service.empty()) if (service != "" and not service.empty())
{ {
if (${verbose_log}) ESP_LOGD("service_call_alarm_control_panel", "ESPHome remote service call"); ESP_LOGV("service_call_alarm_control_panel", "ESPHome remote service call");
HomeassistantServiceResponse resp; HomeassistantServiceResponse resp;
HomeassistantServiceMap resp_kv; HomeassistantServiceMap resp_kv;
resp.service = service.c_str(); resp.service = service.c_str();
@@ -1654,8 +1596,8 @@ script:
component: string component: string
state: string state: string
then: then:
- logger.log: "script.update_alarm_icon: Starting"
- lambda: |- - lambda: |-
ESP_LOGV("script.update_alarm_icon", "Starting");
std::string alarm_icon = "\uEECC"; //mdi:shield-alert-outline std::string alarm_icon = "\uEECC"; //mdi:shield-alert-outline
int alarm_color = 65535; int alarm_color = 65535;
// Standard colors: // Standard colors:
@@ -1722,7 +1664,7 @@ script:
} }
id(disp1).set_component_text_printf(component.c_str(), alarm_icon.c_str()); id(disp1).set_component_text_printf(component.c_str(), alarm_icon.c_str());
id(disp1).set_component_font_color(component.c_str(), alarm_color); id(disp1).set_component_font_color(component.c_str(), alarm_color);
- logger.log: "script.update_alarm_icon: Finished" ESP_LOGV("script.update_alarm_icon", "Finished");
##### ADD-ONS ############################################################ ##### ADD-ONS ############################################################
##### Add-on - Climate ##### ##### Add-on - Climate #####
@@ -1733,33 +1675,38 @@ script:
value: string value: string
then: then:
# Reserved for Add-on Climate # Reserved for Add-on Climate
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_service_call", "Starting"); - lambda: |-
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_service_call", "Finished"); ESP_LOGV("script.addon_climate_service_call", "Starting");
ESP_LOGV("script.addon_climate_service_call", "Finished");
- id: addon_climate_update_page_home - id: addon_climate_update_page_home
mode: restart mode: restart
then: then:
# Reserved for Add-on Climate # Reserved for Add-on Climate
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_update_page_home", "Starting"); - lambda: |-
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_update_page_home", "Finished"); ESP_LOGV("script.addon_climate_update_page_home", "Starting");
ESP_LOGV("script.addon_climate_update_page_home", "Finished");
- id: addon_climate_set_climate - id: addon_climate_set_climate
mode: restart mode: restart
parameters: parameters:
embedded_climate: bool embedded_climate: bool
then: then:
# Reserved for Add-on Climate # Reserved for Add-on Climate
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_set_climate", "Starting"); - lambda: |-
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_set_climate", "Finished"); ESP_LOGV("script.addon_climate_set_climate", "Starting");
ESP_LOGV("script.addon_climate_set_climate", "Finished");
- id: addon_climate_global_settings - id: addon_climate_global_settings
mode: restart mode: restart
parameters: parameters:
embedded_climate: bool embedded_climate: bool
then: then:
# Reserved for Add-on Climate # Reserved for Add-on Climate
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_global_settings", "Starting"); - lambda: |-
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_global_settings", "Finished"); ESP_LOGV("script.addon_climate_global_settings", "Starting");
ESP_LOGV("script.addon_climate_global_settings", "Finished");
- id: addon_climate_update_page_climate - id: addon_climate_update_page_climate
mode: restart mode: restart
then: then:
# Reserved for Add-on Climate # Reserved for Add-on Climate
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_update_page_climate", "Starting"); - lambda: |-
- lambda: if (${verbose_log}) ESP_LOGD("script.addon_climate_update_page_climate", "Finished"); ESP_LOGV("script.addon_climate_update_page_climate", "Starting");
ESP_LOGV("script.addon_climate_update_page_climate", "Finished");