Fix update of detailed page when other entity got updated

- Solves #1225
- Solves #1235
- Solves #1242
This commit is contained in:
Edward Firmo
2023-11-09 09:59:02 +01:00
parent 44ab4adc43
commit 0db04942d6
3 changed files with 21 additions and 19 deletions

View File

@@ -138,7 +138,7 @@ api:
// Is page Alarm visible?
if (current_page->state == "alarm") // To do: This page constructor should be moved to Blueprint
{ // Update alarm page
detailed_entity_id->publish_state(entity);
detailed_entity->publish_state(entity);
// Alarm page - Header
update_alarm_icon->execute("icon_state", state.c_str());
@@ -418,7 +418,7 @@ api:
back_page: string
then:
- lambda: |-
detailed_entity_id->publish_state(entity);
detailed_entity->publish_state(entity);
std::string cmd_page = std::string("page ") + page.c_str();
disp1->send_command_printf(cmd_page.c_str());
disp1->set_component_text_printf("page_label", "%s", page_label.c_str());
@@ -460,7 +460,7 @@ api:
entity: string
then:
- lambda: |-
if (current_page->state == "climate") detailed_entity_id->publish_state(entity);
if (current_page->state == "climate") detailed_entity->publish_state(entity);
- script.execute:
id: set_climate
@@ -604,7 +604,7 @@ api:
- lambda: |-
if (current_page->state == "media_player")
{
detailed_entity_id->publish_state(entity);
detailed_entity->publish_state(entity);
disp1->set_component_text_printf("page_label", "%s", friendly_name.c_str());
display_wrapped_text->execute("track", media_title.c_str(), id(display_mode) == 2 ? 16 : 27);
display_wrapped_text->execute("artist", media_artist.c_str(), id(display_mode) == 2 ? 26 : 40);
@@ -1288,7 +1288,7 @@ text_sensor:
##### Entity Id of the entity displayed on the detailed pages
- name: ${device_name} Detailed Entity
id: detailed_entity_id
id: detailed_entity
platform: template
icon: mdi:tablet-dashboard
internal: false
@@ -1348,7 +1348,7 @@ text_sensor:
std::string component = doc["component"];
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_id->state.c_str(); //doc["entity"];
std::string entity = detailed_entity->state.c_str(); //doc["entity"];
ESP_LOGE(TAG, "page: %s", page.c_str());
ESP_LOGE(TAG, "component: %s", component.c_str());
ESP_LOGE(TAG, "value: %s", value.c_str());
@@ -1386,7 +1386,7 @@ text_sensor:
std::string component = doc["component"];
std::string key = doc["key"];
std::string value = doc["value"];
std::string entity = detailed_entity_id->state.c_str(); //doc["entity"];
std::string entity = detailed_entity->state.c_str(); //doc["entity"];
int embedded = doc["embedded"];
std::string service = "";
@@ -1397,7 +1397,7 @@ text_sensor:
{
if (page == "home" and component == "climate")
{
detailed_entity_id->publish_state((id(is_embedded_thermostat)) ? "embedded_climate" : "");
detailed_entity->publish_state((id(is_embedded_thermostat)) ? "embedded_climate" : "");
disp1->set_component_value("climate.embedded", (id(is_embedded_thermostat)) ? 1 : 0);
}
disp1->goto_page("climate");
@@ -2070,7 +2070,7 @@ script:
page != "media_player" &&
page != "confirm" &&
page != "keyb_num") {
detailed_entity_id->publish_state("");
detailed_entity->publish_state("");
}
if (page != "media_player") {
id(last_volume_level) = 0;
@@ -2080,7 +2080,7 @@ script:
// Report new page to logs
ESP_LOGD(TAG, "New page: %s", page.c_str());
if (!detailed_entity_id->state.empty()) ESP_LOGD(TAG, "Entity shown: %s", detailed_entity_id->state.c_str());
if (!detailed_entity->state.empty()) ESP_LOGD(TAG, "Entity shown: %s", detailed_entity->state.c_str());
// Reset timers
timer_reset_all->execute(page.c_str());
@@ -2092,12 +2092,12 @@ script:
{
{"type", "page_changed"},
{"page", page.c_str()},
{"entity", detailed_entity_id->state.c_str()}
{"entity", detailed_entity->state.c_str()}
});
// Report new page to add-ons
ESP_LOGV(TAG, "Call add-ons scripts for new page");
addon_climate_set_climate->execute(page == "climate" and detailed_entity_id->state == "embedded_climate");
addon_climate_set_climate->execute(page == "climate" and detailed_entity->state == "embedded_climate");
// Call page constructor
if (page == "boot") page_boot->execute(true);