Rebuild esphome::api::CustomAPIDevice declarations

To reduce chances of a memory leak
This commit is contained in:
Edward Firmo
2024-03-14 00:23:48 +01:00
parent 82341613df
commit 57fee3c1c6

View File

@@ -1702,8 +1702,8 @@ text_sensor:
if (not (component == "currentpage" and (page == "screensaver" or page == "home"))) timer_reset_all->execute(page.c_str()); if (not (component == "currentpage" and (page == "screensaver" or page == "home"))) timer_reset_all->execute(page.c_str());
std::string value = doc["value"]; std::string value = doc["value"];
std::string entity = detailed_entity->state.c_str(); // doc["entity"]; std::string entity = detailed_entity->state.c_str(); // doc["entity"];
auto ha_event = new esphome::api::CustomAPIDevice(); esphome::api::CustomAPIDevice ha_event;
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{ {
{"type", "generic"}, {"type", "generic"},
{"page", page}, {"page", page},
@@ -1861,8 +1861,8 @@ script:
if (not compare_versions("${version}", id(version_blueprint))) if (not compare_versions("${version}", id(version_blueprint)))
ESP_LOGE("script.check_versions", "Blueprint version mismatch!"); ESP_LOGE("script.check_versions", "Blueprint version mismatch!");
auto ha_event = new esphome::api::CustomAPIDevice(); esphome::api::CustomAPIDevice ha_event;
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{ {
{"type", "version"}, {"type", "version"},
{"tft", version_tft->state.c_str()}, {"tft", version_tft->state.c_str()},
@@ -2019,8 +2019,8 @@ script:
- lambda: |- - lambda: |-
if (id(is_uploading_tft)) ha_button->stop(); if (id(is_uploading_tft)) ha_button->stop();
timer_reset_all->execute(page.c_str()); timer_reset_all->execute(page.c_str());
auto ha_event = new esphome::api::CustomAPIDevice(); esphome::api::CustomAPIDevice ha_event;
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{ {
{"type", "button_click"}, {"type", "button_click"},
{"page", page}, {"page", page},
@@ -2039,8 +2039,8 @@ script:
- lambda: |- - lambda: |-
if (!id(is_uploading_tft)) { if (!id(is_uploading_tft)) {
if (service != "" and not service.empty()) { if (service != "" and not service.empty()) {
auto ha_event = new esphome::api::CustomAPIDevice(); esphome::api::CustomAPIDevice ha_event;
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{ {
{"type", "service_call"}, {"type", "service_call"},
{"service", service}, {"service", service},
@@ -2166,8 +2166,8 @@ script:
timer_reset_all->execute(page.c_str()); timer_reset_all->execute(page.c_str());
// Report new page to Home Assistant // Report new page to Home Assistant
auto ha_event = new esphome::api::CustomAPIDevice(); esphome::api::CustomAPIDevice ha_event;
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{ {
{"type", "page_changed"}, {"type", "page_changed"},
{"page", page.c_str()}, {"page", page.c_str()},
@@ -2693,8 +2693,8 @@ script:
- lambda: !lambda return (api_server->is_connected()); - lambda: !lambda return (api_server->is_connected());
then: # API connected then: # API connected
- lambda: |- - lambda: |-
auto ha_event = new esphome::api::CustomAPIDevice(); esphome::api::CustomAPIDevice ha_event;
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{ {
{"type", "boot"}, {"type", "boot"},
{"step", "start"} {"step", "start"}
@@ -2712,8 +2712,8 @@ script:
disp1->send_command_printf("brightness_sleep=%i", int(display_sleep_brightness->state)); disp1->send_command_printf("brightness_sleep=%i", int(display_sleep_brightness->state));
nextion_init->publish_state(disp1->is_setup()); nextion_init->publish_state(disp1->is_setup());
if (api_server->is_connected() and disp1->is_setup()) { if (api_server->is_connected() and disp1->is_setup()) {
auto ha_event = new esphome::api::CustomAPIDevice(); esphome::api::CustomAPIDevice ha_event;
ha_event->fire_homeassistant_event("esphome.nspanel_ha_blueprint", ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{ {
{"type", "boot"}, {"type", "boot"},
{"step", "nextion_init"} {"step", "nextion_init"}