Utilities page caching

Helps with #1977
This commit is contained in:
Edward Firmo
2024-03-26 18:58:58 +01:00
parent 53781082e6
commit ccecd91f6f
11 changed files with 162 additions and 158 deletions

View File

@@ -54,6 +54,12 @@ esphome:
platformio_options:
build_flags:
- -Wno-missing-field-initializers
# - -fdata-sections
# - -ffunction-sections
# - -Wl,--gc-sections
# - -Os
# - -flto
on_boot:
- priority: 600.0 # This is where most sensors are set up.
then:
@@ -98,9 +104,12 @@ esp32:
CONFIG_D0WD_PSRAM_CLK_IO: "5"
CONFIG_D0WD_PSRAM_CS_IO: "18"
CONFIG_ESP32_REV_MIN_3: "y"
CONFIG_SPIRAM_SUPPORT: "y"
psram:
id: ext_ram
mode: quad
speed: 80MHz
##### WIFI SETUP #####
wifi:
@@ -790,7 +799,29 @@ api:
value2: string
direction: int
then:
# Do nothing for now
- lambda: |-
if (!id(is_uploading_tft) and !group_id.empty()) {
uint8_t id = findUtilitiesGroupIndex(group_id.c_str());
if (id != UINT8_MAX) {
// Update Value 1
if (!value1.empty() and strcmp(value1.c_str(), UtilitiesGroups[id].value1) != 0) {
copyStringToCharArray(UtilitiesGroups[id].value1, value1);
disp1->set_component_text(group_id.c_str(), value1.c_str());
}
// Update Value 2
if (!value2.empty() and strcmp(value2.c_str(), UtilitiesGroups[id].value2) != 0) {
copyStringToCharArray(UtilitiesGroups[id].value2, value2);
disp1->set_component_text((group_id + "b").c_str(), value2.c_str());
}
// Update direction
if (group_id != "grid" and !isnan(direction) and direction != UtilitiesGroups[id].direction) {
UtilitiesGroups[id].direction = direction;
disp1->set_component_value((group_id + "_line_d").c_str(), direction);
}
}
}
# Updates an entity to display specific values with dynamic icons, names, and color codes.
- service: value
@@ -2016,19 +2047,17 @@ script:
entity: string
then:
- lambda: |-
if (!id(is_uploading_tft)) {
if (service != "" and not service.empty()) {
esphome::api::CustomAPIDevice ha_event;
ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{
{"device_name", device_name->state.c_str()},
{"type", "service_call"},
{"service", service},
{"key", key},
{"value", value},
{"entity", entity}
});
}
if (!id(is_uploading_tft) and !service.empty()) {
esphome::api::CustomAPIDevice ha_event;
ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint",
{
{"device_name", device_name->state.c_str()},
{"type", "service_call"},
{"service", service},
{"key", key},
{"value", value},
{"entity", entity}
});
}
- id: init_hardware_climate
@@ -2561,7 +2590,7 @@ script:
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())
if (not service.empty())
{
HomeassistantServiceResponse resp;
HomeassistantServiceMap resp_kv;
@@ -2569,7 +2598,7 @@ script:
resp_kv.key = "entity_id";
resp_kv.value = entity.c_str();
resp.data.push_back(resp_kv);
if (pin != "" and not pin.empty())
if (not pin.empty())
{
resp_kv.key = "code";
resp_kv.value = pin.c_str();