Edit esp-reterminal-e1001.yaml
This commit is contained in:
@@ -831,8 +831,8 @@ display:
|
|||||||
|
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
# DISPLAY CHANGE DETECTION:
|
# DISPLAY CHANGE DETECTION:
|
||||||
# Builds a signature from only the content that is currently visible. The display is not
|
# Builds a signature from the visible Jobs content. The display is not physically refreshed
|
||||||
# physically refreshed when the visible wording, style and eye indicator would remain unchanged.
|
# when the visible wording, style and eye indicator would remain unchanged.
|
||||||
# https://esphome.io/components/script.html
|
# https://esphome.io/components/script.html
|
||||||
#:########################################################################################:#
|
#:########################################################################################:#
|
||||||
script:
|
script:
|
||||||
@@ -841,16 +841,14 @@ script:
|
|||||||
parameters:
|
parameters:
|
||||||
force: bool
|
force: bool
|
||||||
then:
|
then:
|
||||||
# Debounce bursts of Home Assistant state restoration and page changes.
|
# Debounce bursts of Home Assistant state restoration.
|
||||||
- delay: 750ms
|
- delay: 750ms
|
||||||
|
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
const auto now = id(homeassistant_time).now();
|
const auto now = id(homeassistant_time).now();
|
||||||
const int64_t now_ts = now.is_valid() ? now.timestamp : 0;
|
const int64_t now_ts = now.is_valid() ? now.timestamp : 0;
|
||||||
const int hour_limit = ${job_hours_display_limit};
|
const int hour_limit = ${job_hours_display_limit};
|
||||||
const int finished_seconds = ${finished_highlight_seconds};
|
std::string signature = "jobs-v0.8.0";
|
||||||
|
|
||||||
std::string signature = id(current_page) == 0 ? "jobs" : "appliances";
|
|
||||||
|
|
||||||
auto append_text = [&](const std::string &value) {
|
auto append_text = [&](const std::string &value) {
|
||||||
signature += "|";
|
signature += "|";
|
||||||
@@ -873,7 +871,6 @@ script:
|
|||||||
append_text("no_time");
|
append_text("no_time");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id(current_page) == 0) {
|
|
||||||
auto append_job = [&](const std::string &state, float due_ts,
|
auto append_job = [&](const std::string &state, float due_ts,
|
||||||
const std::string &completed_time) {
|
const std::string &completed_time) {
|
||||||
append_text(state);
|
append_text(state);
|
||||||
@@ -929,130 +926,30 @@ script:
|
|||||||
id(job_water_table_pot_plant_due_ts).state,
|
id(job_water_table_pot_plant_due_ts).state,
|
||||||
id(job_water_table_pot_plant_completed_time).state
|
id(job_water_table_pot_plant_completed_time).state
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
auto append_appliance = [&](const std::string &state,
|
|
||||||
float stop_ts,
|
|
||||||
float duration_seconds,
|
|
||||||
const std::string &stop_local) {
|
|
||||||
const bool valid_cycle =
|
|
||||||
!isnan(stop_ts) && stop_ts > 0 &&
|
|
||||||
!isnan(duration_seconds) && duration_seconds > 0;
|
|
||||||
|
|
||||||
if (state == "Operating") {
|
// Persistent 32-bit FNV-1a hash for the Jobs page.
|
||||||
append_text("OPERATING");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (valid_cycle) {
|
|
||||||
bool recent_finish = false;
|
|
||||||
if (now_ts > 0) {
|
|
||||||
const int64_t age = now_ts - static_cast<int64_t>(stop_ts);
|
|
||||||
recent_finish = age >= 0 && age < finished_seconds;
|
|
||||||
}
|
|
||||||
|
|
||||||
append_text(recent_finish ? "FINISHED" : "COMPLETED");
|
|
||||||
append_text(stop_local);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
append_text(state);
|
|
||||||
};
|
|
||||||
|
|
||||||
append_appliance(
|
|
||||||
id(appliance_washing_state).state,
|
|
||||||
id(appliance_washing_stop_ts).state,
|
|
||||||
id(appliance_washing_duration).state,
|
|
||||||
id(appliance_washing_stop_local).state
|
|
||||||
);
|
|
||||||
append_appliance(
|
|
||||||
id(appliance_dryer_state).state,
|
|
||||||
id(appliance_dryer_stop_ts).state,
|
|
||||||
id(appliance_dryer_duration).state,
|
|
||||||
id(appliance_dryer_stop_local).state
|
|
||||||
);
|
|
||||||
append_appliance(
|
|
||||||
id(appliance_main_dishwasher_state).state,
|
|
||||||
id(appliance_main_dishwasher_stop_ts).state,
|
|
||||||
id(appliance_main_dishwasher_duration).state,
|
|
||||||
id(appliance_main_dishwasher_stop_local).state
|
|
||||||
);
|
|
||||||
append_appliance(
|
|
||||||
id(appliance_downstairs_dishwasher_state).state,
|
|
||||||
id(appliance_downstairs_dishwasher_stop_ts).state,
|
|
||||||
id(appliance_downstairs_dishwasher_duration).state,
|
|
||||||
id(appliance_downstairs_dishwasher_stop_local).state
|
|
||||||
);
|
|
||||||
append_appliance(
|
|
||||||
id(appliance_evcharger_32a_state).state,
|
|
||||||
id(appliance_evcharger_32a_stop_ts).state,
|
|
||||||
id(appliance_evcharger_32a_duration).state,
|
|
||||||
id(appliance_evcharger_32a_stop_local).state
|
|
||||||
);
|
|
||||||
append_appliance(
|
|
||||||
id(appliance_evcharger_16a_state).state,
|
|
||||||
id(appliance_evcharger_16a_stop_ts).state,
|
|
||||||
id(appliance_evcharger_16a_duration).state,
|
|
||||||
id(appliance_evcharger_16a_stop_local).state
|
|
||||||
);
|
|
||||||
append_appliance(
|
|
||||||
id(appliance_ryobi_left_state).state,
|
|
||||||
id(appliance_ryobi_left_stop_ts).state,
|
|
||||||
id(appliance_ryobi_left_duration).state,
|
|
||||||
id(appliance_ryobi_left_stop_local).state
|
|
||||||
);
|
|
||||||
append_appliance(
|
|
||||||
id(appliance_ryobi_right_state).state,
|
|
||||||
id(appliance_ryobi_right_stop_ts).state,
|
|
||||||
id(appliance_ryobi_right_duration).state,
|
|
||||||
id(appliance_ryobi_right_stop_local).state
|
|
||||||
);
|
|
||||||
append_appliance(
|
|
||||||
id(appliance_pool_pump_state).state,
|
|
||||||
id(appliance_pool_pump_stop_ts).state,
|
|
||||||
id(appliance_pool_pump_duration).state,
|
|
||||||
id(appliance_pool_pump_stop_local).state
|
|
||||||
);
|
|
||||||
append_appliance(
|
|
||||||
id(appliance_3d_printer_state).state,
|
|
||||||
id(appliance_3d_printer_stop_ts).state,
|
|
||||||
id(appliance_3d_printer_duration).state,
|
|
||||||
id(appliance_3d_printer_stop_local).state
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Persistent 32-bit FNV-1a hash. A separate value is retained for each page.
|
|
||||||
uint32_t signature_hash = 2166136261UL;
|
uint32_t signature_hash = 2166136261UL;
|
||||||
for (const unsigned char character : signature) {
|
for (const unsigned char character : signature) {
|
||||||
signature_hash ^= static_cast<uint32_t>(character);
|
signature_hash ^= static_cast<uint32_t>(character);
|
||||||
signature_hash *= 16777619UL;
|
signature_hash *= 16777619UL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint32_t previous_hash =
|
|
||||||
id(current_page) == 0
|
|
||||||
? id(last_jobs_signature_hash)
|
|
||||||
: id(last_appliances_signature_hash);
|
|
||||||
|
|
||||||
id(display_update_required) =
|
id(display_update_required) =
|
||||||
force || previous_hash == 0 || signature_hash != previous_hash;
|
force || id(last_jobs_signature_hash) == 0 ||
|
||||||
|
signature_hash != id(last_jobs_signature_hash);
|
||||||
|
|
||||||
if (id(display_update_required)) {
|
if (id(display_update_required)) {
|
||||||
if (id(current_page) == 0) {
|
|
||||||
id(last_jobs_signature_hash) = signature_hash;
|
id(last_jobs_signature_hash) = signature_hash;
|
||||||
} else {
|
|
||||||
id(last_appliances_signature_hash) = signature_hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_LOGI(
|
ESP_LOGI(
|
||||||
"display",
|
"display",
|
||||||
"Visible content changed or page selected; refreshing page %d (hash 0x%08lX)",
|
"Visible Jobs content changed; refreshing display (hash 0x%08lX)",
|
||||||
id(current_page) + 1,
|
|
||||||
static_cast<unsigned long>(signature_hash)
|
static_cast<unsigned long>(signature_hash)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGI(
|
ESP_LOGI(
|
||||||
"display",
|
"display",
|
||||||
"Page %d content unchanged (hash 0x%08lX); e-paper refresh skipped",
|
"Jobs content unchanged (hash 0x%08lX); e-paper refresh skipped",
|
||||||
id(current_page) + 1,
|
|
||||||
static_cast<unsigned long>(signature_hash)
|
static_cast<unsigned long>(signature_hash)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user