From 57fee3c1c643e92b778f9ff4d8f35cf861c2dc19 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Thu, 14 Mar 2024 00:23:48 +0100 Subject: [PATCH] Rebuild esphome::api::CustomAPIDevice declarations To reduce chances of a memory leak --- esphome/nspanel_esphome_core.yaml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/esphome/nspanel_esphome_core.yaml b/esphome/nspanel_esphome_core.yaml index c8019ec..abc0db0 100644 --- a/esphome/nspanel_esphome_core.yaml +++ b/esphome/nspanel_esphome_core.yaml @@ -1702,8 +1702,8 @@ text_sensor: if (not (component == "currentpage" and (page == "screensaver" or page == "home"))) timer_reset_all->execute(page.c_str()); std::string value = doc["value"]; std::string entity = detailed_entity->state.c_str(); // doc["entity"]; - auto ha_event = new esphome::api::CustomAPIDevice(); - ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + esphome::api::CustomAPIDevice ha_event; + ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"type", "generic"}, {"page", page}, @@ -1861,8 +1861,8 @@ script: if (not compare_versions("${version}", id(version_blueprint))) ESP_LOGE("script.check_versions", "Blueprint version mismatch!"); - auto ha_event = new esphome::api::CustomAPIDevice(); - ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + esphome::api::CustomAPIDevice ha_event; + ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"type", "version"}, {"tft", version_tft->state.c_str()}, @@ -2019,8 +2019,8 @@ script: - lambda: |- if (id(is_uploading_tft)) ha_button->stop(); timer_reset_all->execute(page.c_str()); - auto ha_event = new esphome::api::CustomAPIDevice(); - ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + esphome::api::CustomAPIDevice ha_event; + ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"type", "button_click"}, {"page", page}, @@ -2039,8 +2039,8 @@ script: - lambda: |- if (!id(is_uploading_tft)) { if (service != "" and not service.empty()) { - auto ha_event = new esphome::api::CustomAPIDevice(); - ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + esphome::api::CustomAPIDevice ha_event; + ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"type", "service_call"}, {"service", service}, @@ -2166,8 +2166,8 @@ script: timer_reset_all->execute(page.c_str()); // Report new page to Home Assistant - auto ha_event = new esphome::api::CustomAPIDevice(); - ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + esphome::api::CustomAPIDevice ha_event; + ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"type", "page_changed"}, {"page", page.c_str()}, @@ -2693,8 +2693,8 @@ script: - lambda: !lambda return (api_server->is_connected()); then: # API connected - lambda: |- - auto ha_event = new esphome::api::CustomAPIDevice(); - ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + esphome::api::CustomAPIDevice ha_event; + ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"type", "boot"}, {"step", "start"} @@ -2712,8 +2712,8 @@ script: disp1->send_command_printf("brightness_sleep=%i", int(display_sleep_brightness->state)); nextion_init->publish_state(disp1->is_setup()); if (api_server->is_connected() and disp1->is_setup()) { - auto ha_event = new esphome::api::CustomAPIDevice(); - ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", + esphome::api::CustomAPIDevice ha_event; + ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", { {"type", "boot"}, {"step", "nextion_init"}