Update home page when notification changes

Solves #1136
This commit is contained in:
Edward Firmo
2023-10-03 14:37:46 +02:00
parent b6a5ea76c0
commit 742e2a243d

View File

@@ -242,6 +242,7 @@ api:
ESP_LOGV("service.notification_show", "Starting");
id(disp1).send_command_printf("is_notification=1");
if (id(current_page).state.c_str() == "home") id(disp1).show_component("bt_notific");
id(disp1).goto_page("notification");
id(disp1).set_component_text_printf("notification.notifi_label", "%s", label.c_str());
@@ -264,6 +265,7 @@ api:
- &notification_clear
lambda: |-
id(disp1).send_command_printf("is_notification=0");
if (id(current_page).state.c_str() == "home") id(disp1).hide_component("bt_notific");
id(notification_label).publish_state("");
id(notification_text).publish_state("");
- switch.turn_off: notification_unread
@@ -330,7 +332,7 @@ api:
entity: string
then:
- lambda: |-
if (id(current_page).state == "climate") id(entity_id) = entity;
if (id(current_page).state.c_str() == "climate") id(entity_id) = entity;
- script.execute:
id: set_climate
@@ -376,7 +378,7 @@ api:
reset_timer: bool
then:
- lambda: |-
if (id(current_page).state == "screensaver") id(disp1).goto_page(id(wakeup_page_name).state.c_str());
if (id(current_page).state.c_str() == "screensaver") id(disp1).goto_page(id(wakeup_page_name).state.c_str());
if (reset_timer)
id(timer_reset_all).execute(id(wakeup_page_name).state.c_str());
else
@@ -531,7 +533,7 @@ api:
id(set_component_color).execute("home.bt_entities", entities_pages_icon_color, {});
// Alarm button
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());
#### Service to populate the page Settings #####
@@ -562,11 +564,11 @@ api:
then:
- lambda: |-
// set alarm icon on home page
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());
// Is page Alarm visible?
if (id(current_page).state=="alarm")
if (id(current_page).state.c_str() == "alarm")
{ // Update alarm page
id(entity_id) = entity;
@@ -595,57 +597,57 @@ api:
// Alarm page - Buttons
if (supported_features & 1) // Alarm - Button - Home
{
id(disp1).send_command_printf("bt_home_pic.pic=%i", (state=="armed_home") ? 43 : 42);
id(disp1).set_component_background_color("bt_home_text", (state=="armed_home") ? 19818 : 52857);
id(disp1).set_component_background_color("bt_home_icon", (state=="armed_home") ? 19818 : 52857);
id(disp1).set_component_font_color("bt_home_text", (state=="armed_home") ? 65535 : 0);
id(disp1).set_component_font_color("bt_home_icon", (state=="armed_home") ? 65535 : 0);
if (state=="armed_home") id(disp1).hide_component("bt_home"); else id(disp1).show_component("bt_home");
id(disp1).send_command_printf("bt_home_pic.pic=%i", (state == "armed_home") ? 43 : 42);
id(disp1).set_component_background_color("bt_home_text", (state == "armed_home") ? 19818 : 52857);
id(disp1).set_component_background_color("bt_home_icon", (state == "armed_home") ? 19818 : 52857);
id(disp1).set_component_font_color("bt_home_text", (state == "armed_home") ? 65535 : 0);
id(disp1).set_component_font_color("bt_home_icon", (state == "armed_home") ? 65535 : 0);
if (state == "armed_home") id(disp1).hide_component("bt_home"); else id(disp1).show_component("bt_home");
}
if (supported_features & 2) // Alarm - Button - Away
{
id(disp1).send_command_printf("bt_away_pic.pic=%i", (state=="armed_away") ? 43 : 42);
id(disp1).set_component_background_color("bt_away_text", (state=="armed_away") ? 19818 : 52857);
id(disp1).set_component_background_color("bt_away_icon", (state=="armed_away") ? 19818 : 52857);
id(disp1).set_component_font_color("bt_away_text", (state=="armed_away") ? 65535 : 0);
id(disp1).set_component_font_color("bt_away_icon", (state=="armed_away") ? 65535 : 0);
if (state=="armed_away") id(disp1).hide_component("bt_away"); else id(disp1).show_component("bt_away");
id(disp1).send_command_printf("bt_away_pic.pic=%i", (state == "armed_away") ? 43 : 42);
id(disp1).set_component_background_color("bt_away_text", (state == "armed_away") ? 19818 : 52857);
id(disp1).set_component_background_color("bt_away_icon", (state == "armed_away") ? 19818 : 52857);
id(disp1).set_component_font_color("bt_away_text", (state == "armed_away") ? 65535 : 0);
id(disp1).set_component_font_color("bt_away_icon", (state == "armed_away") ? 65535 : 0);
if (state == "armed_away") id(disp1).hide_component("bt_away"); else id(disp1).show_component("bt_away");
}
if (supported_features & 4) // Alarm - Button - Night
{
id(disp1).send_command_printf("bt_night_pic.pic=%i", (state=="armed_night") ? 43 : 42);
id(disp1).set_component_background_color("bt_night_text", (state=="armed_night") ? 19818 : 52857);
id(disp1).set_component_background_color("bt_night_icon", (state=="armed_night") ? 19818 : 52857);
id(disp1).set_component_font_color("bt_night_text", (state=="armed_night") ? 65535 : 0);
id(disp1).set_component_font_color("bt_night_icon", (state=="armed_night") ? 65535 : 0);
if (state=="armed_night") id(disp1).hide_component("bt_night"); else id(disp1).show_component("bt_night");
id(disp1).send_command_printf("bt_night_pic.pic=%i", (state == "armed_night") ? 43 : 42);
id(disp1).set_component_background_color("bt_night_text", (state == "armed_night") ? 19818 : 52857);
id(disp1).set_component_background_color("bt_night_icon", (state == "armed_night") ? 19818 : 52857);
id(disp1).set_component_font_color("bt_night_text", (state == "armed_night") ? 65535 : 0);
id(disp1).set_component_font_color("bt_night_icon", (state == "armed_night") ? 65535 : 0);
if (state == "armed_night") id(disp1).hide_component("bt_night"); else id(disp1).show_component("bt_night");
}
if (supported_features & 32) // Alarm - Button - Vacation
{
id(disp1).send_command_printf("bt_vacat_pic.pic=%i", (state=="armed_vacation") ? 43 : 42);
id(disp1).set_component_background_color("bt_vacat_text", (state=="armed_vacation") ? 19818 : 52857);
id(disp1).set_component_background_color("bt_vacat_icon", (state=="armed_vacation") ? 19818 : 52857);
id(disp1).set_component_font_color("bt_vacat_text", (state=="armed_vacation") ? 65535 : 0);
id(disp1).set_component_font_color("bt_vacat_icon", (state=="armed_vacation") ? 65535 : 0);
if (state=="armed_vacation") id(disp1).hide_component("bt_vacat"); else id(disp1).show_component("bt_vacat");
id(disp1).send_command_printf("bt_vacat_pic.pic=%i", (state == "armed_vacation") ? 43 : 42);
id(disp1).set_component_background_color("bt_vacat_text", (state == "armed_vacation") ? 19818 : 52857);
id(disp1).set_component_background_color("bt_vacat_icon", (state == "armed_vacation") ? 19818 : 52857);
id(disp1).set_component_font_color("bt_vacat_text", (state == "armed_vacation") ? 65535 : 0);
id(disp1).set_component_font_color("bt_vacat_icon", (state == "armed_vacation") ? 65535 : 0);
if (state == "armed_vacation") id(disp1).hide_component("bt_vacat"); else id(disp1).show_component("bt_vacat");
}
if (supported_features & 16) // Alarm - Button - Custom bypass
{
id(disp1).send_command_printf("bt_bypass_pic.pic=%i", (state=="armed_bypass") ? 43 : 42);
id(disp1).set_component_background_color("bt_bypass_text", (state=="armed_bypass") ? 19818 : 52857);
id(disp1).set_component_background_color("bt_bypass_icon", (state=="armed_bypass") ? 19818 : 52857);
id(disp1).set_component_font_color("bt_bypass_text", (state=="armed_bypass") ? 65535 : 0);
id(disp1).set_component_font_color("bt_bypass_icon", (state=="armed_bypass") ? 65535 : 0);
if (state=="armed_bypass") id(disp1).hide_component("bt_bypass"); else id(disp1).show_component("bt_bypass");
id(disp1).send_command_printf("bt_bypass_pic.pic=%i", (state == "armed_bypass") ? 43 : 42);
id(disp1).set_component_background_color("bt_bypass_text", (state == "armed_bypass") ? 19818 : 52857);
id(disp1).set_component_background_color("bt_bypass_icon", (state == "armed_bypass") ? 19818 : 52857);
id(disp1).set_component_font_color("bt_bypass_text", (state == "armed_bypass") ? 65535 : 0);
id(disp1).set_component_font_color("bt_bypass_icon", (state == "armed_bypass") ? 65535 : 0);
if (state == "armed_bypass") id(disp1).hide_component("bt_bypass"); else id(disp1).show_component("bt_bypass");
}
if ( true ) // Alarm - Button - Disarm
{
id(disp1).send_command_printf("bt_disarm_pic.pic=%i", (state=="disarmed") ? 43 : 42);
id(disp1).set_component_background_color("bt_disarm_text", (state=="disarmed") ? 19818 : 52857);
id(disp1).set_component_background_color("bt_disarm_icon", (state=="disarmed") ? 19818 : 52857);
id(disp1).set_component_font_color("bt_disarm_text", (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");
id(disp1).send_command_printf("bt_disarm_pic.pic=%i", (state == "disarmed") ? 43 : 42);
id(disp1).set_component_background_color("bt_disarm_text", (state == "disarmed") ? 19818 : 52857);
id(disp1).set_component_background_color("bt_disarm_icon", (state == "disarmed") ? 19818 : 52857);
id(disp1).set_component_font_color("bt_disarm_text", (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");
}
}
@@ -665,7 +667,7 @@ api:
supported_features: int
then:
- lambda: |-
if (id(current_page).state == "media_player")
if (id(current_page).state.c_str() == "media_player")
{
id(entity_id) = entity;
id(disp1).set_component_text_printf("page_label", "%s", friendly_name.c_str());
@@ -919,7 +921,7 @@ binary_sensor:
- logger.log: "Left button - Long click"
- script.execute:
id: ha_button
page: !lambda return id(current_page).state;
page: !lambda return id(current_page).state.c_str();
component: "hw_bt_left"
command: "long_click"
- timing: &short_click-timing
@@ -941,7 +943,7 @@ binary_sensor:
- switch.toggle: relay_1
- script.execute:
id: ha_button
page: !lambda return id(current_page).state;
page: !lambda return id(current_page).state.c_str();
component: "hw_bt_left"
command: "short_click"
@@ -958,7 +960,7 @@ binary_sensor:
- logger.log: "Right button - Long click"
- script.execute:
id: ha_button
page: !lambda return id(current_page).state;
page: !lambda return id(current_page).state.c_str();
component: "hw_bt_right"
command: "long_click"
- timing: *short_click-timing
@@ -979,7 +981,7 @@ binary_sensor:
- switch.toggle: relay_2
- script.execute:
id: ha_button
page: !lambda return id(current_page).state;
page: !lambda return id(current_page).state.c_str();
component: "hw_bt_right"
command: "short_click"
@@ -1169,21 +1171,21 @@ text_sensor:
// Report new page to add-ons
ESP_LOGV("text_sensor.localevent", "Call add-ons scripts for new page");
id(addon_climate_set_climate).execute(x=="climate" and id(entity_id) == "embedded_climate");
id(addon_climate_set_climate).execute(x == "climate" and id(entity_id) == "embedded_climate");
// Construct new page
ESP_LOGV("text_sensor.localevent", "Construct new page");
if (x=="home")
if (x == "home")
{
ESP_LOGV("text_sensor.nspanelevent", "Construct home page");
id(update_page_home).execute();
}
else if (x=="screensaver")
else if (x == "screensaver")
{
ESP_LOGV("text_sensor.nspanelevent", "Construct screensaver page");
id(update_page_screensaver).execute();
}
else if (x=="climate")
else if (x == "climate")
{
ESP_LOGV("text_sensor.nspanelevent", "Construct climate page");
id(disp1).set_component_text_printf("climate.button01_icon", "%s", "\uEE8D"); //mdi:calendar-sync
@@ -1195,7 +1197,7 @@ text_sensor:
id(disp1).set_component_text_printf("climate.button07_icon", "%s", "\uE424"); //mdi:power
id(addon_climate_update_page_climate).execute();
}
else if (x=="cover") // To do: Should be moved to Blueprint
else if (x == "cover") // To do: Should be moved to Blueprint
{
ESP_LOGV("text_sensor.nspanelevent", "Construct cover page");
id(disp1).set_component_text_printf("cover.cover_stop", "%s", "\uE666"); //mdi:stop-circle-outline
@@ -1203,7 +1205,7 @@ text_sensor:
id(disp1).set_component_text_printf("cover.cover_open", "%s", "\uF11D"); //mdi:window-shutter-open
id(disp1).set_component_text_printf("cover.cover_close", "%s", "\uF11B"); //mdi:window-shutter
}
else if (x=="fan") // To do: Should be moved to Blueprint
else if (x == "fan") // To do: Should be moved to Blueprint
{
ESP_LOGV("text_sensor.nspanelevent", "Construct fan page");
id(disp1).set_component_text_printf("fan.button_on", "%s", "\uE20F"); //mdi:fan
@@ -1211,7 +1213,7 @@ text_sensor:
id(disp1).set_component_text_printf("fan.button_up", "%s", "\uF46D"); //mdi:fan-chevron-up
id(disp1).set_component_text_printf("fan.button_down", "%s", "\uF46C"); //mdi:fan-chevron-down
}
else if (x=="keyb_num")
else if (x == "keyb_num")
{
ESP_LOGV("text_sensor.nspanelevent", "Construct keyb_num page");
id(disp1).set_component_text_printf("keyb_num.bview", "%s", "\uE207"); //mdi:eye
@@ -1219,27 +1221,27 @@ text_sensor:
id(disp1).set_component_text_printf("keyb_num.bclear", "%s", "\uE641"); //mdi:eraser-variant
id(disp1).set_component_text_printf("keyb_num.benter", "%s", "\uE12B"); //mdi:check
}
else if (x=="weather01") id(disp1).set_component_text_printf("page_index", "%s", "●○○○○"); // 1/5 // To do: Should be moved to Blueprint
else if (x=="weather02") id(disp1).set_component_text_printf("page_index", "%s", "○●○○○"); // 2/5 // To do: Should be moved to Blueprint
else if (x=="weather03") id(disp1).set_component_text_printf("page_index", "%s", "○○●○○"); // 3/5 // To do: Should be moved to Blueprint
else if (x=="weather04") id(disp1).set_component_text_printf("page_index", "%s", "○○○●○"); // 4/5 // To do: Should be moved to Blueprint
else if (x=="weather05") id(disp1).set_component_text_printf("page_index", "%s", "○○○○●"); // 5/5 // To do: Should be moved to Blueprint
else if (x=="buttonpage01" or x=="entitypage01") id(disp1).set_component_text_printf("page_index", "%s", "●○○○"); // 1/4 // To do: Should be moved to Blueprint
else if (x=="buttonpage02" or x=="entitypage02") id(disp1).set_component_text_printf("page_index", "%s", "○●○○"); // 2/4 // To do: Should be moved to Blueprint
else if (x=="buttonpage03" or x=="entitypage03") id(disp1).set_component_text_printf("page_index", "%s", "○○●○"); // 3/4 // To do: Should be moved to Blueprint
else if (x=="buttonpage04" or x=="entitypage04") id(disp1).set_component_text_printf("page_index", "%s", "○○○●"); // 4/4 // To do: Should be moved to Blueprint
else if (x=="settings") // To do: Add timers on TFT?
else if (x == "weather01") id(disp1).set_component_text_printf("page_index", "%s", "●○○○○"); // 1/5 // To do: Should be moved to Blueprint
else if (x == "weather02") id(disp1).set_component_text_printf("page_index", "%s", "○●○○○"); // 2/5 // To do: Should be moved to Blueprint
else if (x == "weather03") id(disp1).set_component_text_printf("page_index", "%s", "○○●○○"); // 3/5 // To do: Should be moved to Blueprint
else if (x == "weather04") id(disp1).set_component_text_printf("page_index", "%s", "○○○●○"); // 4/5 // To do: Should be moved to Blueprint
else if (x == "weather05") id(disp1).set_component_text_printf("page_index", "%s", "○○○○●"); // 5/5 // To do: Should be moved to Blueprint
else if (x == "buttonpage01" or x == "entitypage01") id(disp1).set_component_text_printf("page_index", "%s", "●○○○"); // 1/4 // To do: Should be moved to Blueprint
else if (x == "buttonpage02" or x == "entitypage02") id(disp1).set_component_text_printf("page_index", "%s", "○●○○"); // 2/4 // To do: Should be moved to Blueprint
else if (x == "buttonpage03" or x == "entitypage03") id(disp1).set_component_text_printf("page_index", "%s", "○○●○"); // 3/4 // To do: Should be moved to Blueprint
else if (x == "buttonpage04" or x == "entitypage04") id(disp1).set_component_text_printf("page_index", "%s", "○○○●"); // 4/4 // To do: Should be moved to Blueprint
else if (x == "settings") // To do: Add timers on TFT?
{
//id(disp1).set_component_text_printf("bt_sleep", "%s", (id(sleep_mode).state) ? "\uEA19" : "\uEA18"); //mdi:toggle-switch-outline or mdi:toggle-switch-off-outline
id(disp1).hide_component("lbl_sleep");
id(disp1).hide_component("bt_sleep");
}
else if (x=="notification")
else if (x == "notification")
{
id(disp1).set_component_text_printf("notification.notifi_label", "%s", id(notification_label).state.c_str());
id(display_wrapped_text).execute("notification.notifi_text01", id(notification_text).state.c_str(), id(display_mode) == 2 ? 23 : 32);
}
else if (x=="media_player") // To do: Should be moved to Blueprint
else if (x == "media_player") // To do: Should be moved to Blueprint
{
ESP_LOGV("text_sensor.nspanelevent", "Construct media_player page");
id(disp1).set_component_text_printf("bt_on_off", "%s", "\uE424"); //mdi:power
@@ -1342,8 +1344,8 @@ text_sensor:
// send event to Home Assistant
auto ha_event = new esphome::api::CustomAPIDevice();
if (event=="short_click" or event=="long_click") id(ha_button).execute(page.c_str(), component.c_str(), event.c_str());
else if (event=="click")
if (event == "short_click" or event == "long_click") id(ha_button).execute(page.c_str(), component.c_str(), event.c_str());
else if (event == "click")
{
if (page == "home" and component == "climate")
{
@@ -1370,7 +1372,7 @@ text_sensor:
std::string code_format = doc["code_format"];
std::string code_arm_req = doc["code_arm_req"];
std::string title = doc["mui"];
if (code_format=="number" and (key=="disarm" or code_arm_req=="1"))
if (code_format == "number" and (key == "disarm" or code_arm_req == "1"))
{
id(disp1).goto_page("keyb_num");
id(disp1).set_component_value("keyb_num.page_id", 23); //Calling from Alarm page
@@ -1382,7 +1384,7 @@ text_sensor:
}
else id(service_call_alarm_control_panel).execute(entity.c_str(), key.c_str(), code_format.c_str(), "");
}
else if (page=="boot")
else if (page == "boot")
{
// Detect display mode
if (doc.containsKey("display_mode"))
@@ -1402,7 +1404,7 @@ text_sensor:
id(check_versions).execute();
// Detect timeout
if (event=="timeout")
if (event == "timeout")
{
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{
@@ -1554,12 +1556,12 @@ number:
id(display_brightness_global) = int(x);
id(disp1).send_command_printf("brightness=%i", int(x));
id(disp1).send_command_printf("settings.brightslider.val=%i", int(x));
if (id(current_page).state != "screensaver")
if (id(current_page).state.c_str() != "screensaver")
{
id(disp1).set_backlight_brightness(x/100);
id(timer_dim).execute(id(current_page).state.c_str(), int(id(timeout_dim).state));
id(timer_sleep).execute(id(current_page).state.c_str(), int(id(timeout_sleep).state));
if (id(current_page).state == "settings") id(disp1).set_component_text_printf("bright_text", "%i%%", int(x));
if (id(current_page).state.c_str() == "settings") id(disp1).set_component_text_printf("bright_text", "%i%%", int(x));
}
##### SCREEN BRIGHTNESS DIMMED DOWN #####
@@ -1579,11 +1581,11 @@ number:
id(display_dim_brightness_global) = int(x);
id(disp1).send_command_printf("brightness_dim=%i", int(x));
id(disp1).send_command_printf("settings.dimslider.val=%i", int(x));
if (id(current_page).state != "screensaver" and id(is_dim_brightness))
if (id(current_page).state.c_str() != "screensaver" and id(is_dim_brightness))
{
id(disp1).set_backlight_brightness(x/100);
id(timer_sleep).execute(id(current_page).state.c_str(), int(id(timeout_sleep).state));
if (id(current_page).state == "settings") id(disp1).set_component_text_printf("dim_text", "%i%%", int(x));
if (id(current_page).state.c_str() == "settings") id(disp1).set_component_text_printf("dim_text", "%i%%", int(x));
}
##### Temperature Correction #####
@@ -1757,7 +1759,7 @@ script:
- delay: !lambda return (timeout *1000);
- lambda: |-
ESP_LOGD("script.timer_page", "Timed out on page: %s", id(current_page).state.c_str());
if (id(current_page).state != "screensaver" and id(current_page).state != "boot" and id(current_page).state != "home" and timeout >= 1)
if (id(current_page).state.c_str() != "screensaver" and id(current_page).state.c_str() != "boot" and id(current_page).state.c_str() != "home" and timeout >= 1)
{
ESP_LOGD("script.timer_page", "Fallback to page Home");
id(disp1).goto_page("home");
@@ -1785,7 +1787,7 @@ script:
then:
- delay: !lambda return (timeout *1000);
- lambda: |-
if (id(current_page).state != "screensaver" and id(current_page).state != "blank-screensaver" and id(current_page).state != "boot" and timeout >= 1)
if (id(current_page).state.c_str() != "screensaver" and id(current_page).state.c_str() != "blank-screensaver" and id(current_page).state.c_str() != "boot" and timeout >= 1)
{
ESP_LOGD("script.timer_dim", "Dimming the display to %i%%", id(display_dim_brightness_global));
id(disp1).send_command_printf("dim=%i", id(display_dim_brightness_global));
@@ -1805,7 +1807,7 @@ script:
then:
- delay: !lambda return (timeout *1000);
- lambda: |-
if (id(current_page).state != "screensaver" and id(current_page).state != "boot" and timeout >= 1)
if (id(current_page).state.c_str() != "screensaver" and id(current_page).state.c_str() != "boot" and timeout >= 1)
{
ESP_LOGD("script.timer_sleep", "Going to sleep from page %s", id(current_page).state.c_str());
id(disp1).goto_page("screensaver");
@@ -1957,12 +1959,12 @@ script:
then:
- lambda: |-
std::string service = "";
if (key=="home") service = "alarm_control_panel.alarm_arm_home";
else if (key=="away") service = "alarm_control_panel.alarm_arm_away";
else if (key=="night") service = "alarm_control_panel.alarm_arm_night";
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=="disarm") service = "alarm_control_panel.alarm_disarm";
if (key == "home") service = "alarm_control_panel.alarm_arm_home";
else if (key == "away") service = "alarm_control_panel.alarm_arm_away";
else if (key == "night") service = "alarm_control_panel.alarm_arm_night";
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 == "disarm") service = "alarm_control_panel.alarm_disarm";
if (service != "" and not service.empty())
{
HomeassistantServiceResponse resp;
@@ -2312,20 +2314,6 @@ script:
int content_length_ = 0;
int tft_size_ = 0;
int tranfer_size_ = 0;
unsigned long starting_timestamp = 0;
auto remaining_time = [starting_timestamp, tranfer_size_, content_length_]() -> std::string
{
if (content_length_ > tranfer_size_) return "unknown";
long remaining_millis = int(round((millis() - starting_timestamp) * content_length_ / (tranfer_size_ - content_length_)));
int hours = remaining_millis / (1000 * 60 * 60);
int minutes = (remaining_millis / (1000 * 60)) % 60;
int seconds = (remaining_millis / 1000) % 60;
char resp[9];
sprintf(resp, "%02i:%02i:%02i", hours, minutes, seconds);
return std::string(resp);
};
auto power_cycle_display = []()
{
@@ -2662,9 +2650,6 @@ script:
ESP_LOGD("script.upload_tft.upload_tft", "Updating tft from \"%s\" with a file size of %d using %zu chunksize, Heap Size %d",
url.c_str(), content_length_, transfer_buffer_size_, ESP.getFreeHeap());
starting_timestamp = millis();
tranfer_size_ = content_length_;
int result = 0;
while (content_length_ > 0) {
result = upload_by_chunks_(&http, url, result);