Ad sensor detailed_entity_id

This commit is contained in:
Edward Firmo
2023-11-07 21:39:44 +01:00
parent bc93bc523f
commit f0394bb5bc

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
id(entity_id) = entity;
detailed_entity_id->publish_value(entity);
// Alarm page - Header
update_alarm_icon->execute("icon_state", state.c_str());
@@ -418,7 +418,7 @@ api:
back_page: string
then:
- lambda: |-
id(entity_id) = entity;
detailed_entity_id->publish_value(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") id(entity_id) = entity;
if (current_page->state == "climate") detailed_entity_id->publish_value(entity);
- script.execute:
id: set_climate
@@ -609,7 +609,7 @@ api:
- lambda: |-
if (current_page->state == "media_player")
{
id(entity_id) = entity;
detailed_entity_id->publish_value(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);
@@ -757,12 +757,6 @@ globals:
restore_value: true
initial_value: '0'
##### Entity Id of the entity displayed on the detailed pages
- id: entity_id
type: std::string
restore_value: no
initial_value: ''
##### Is embedded thermostat set as main climate entity? #####
- id: is_embedded_thermostat
type: bool
@@ -1297,6 +1291,14 @@ switch:
##### START - TEXT SENSOR CONFIGURATION #####
text_sensor:
##### Entity Id of the entity displayed on the detailed pages
- name: ${device_name} Detailed Entity
id: detailed_entity_id
platform: template
icon: mdi:tablet-dashboard
internal: false
disabled_by_default: false
##### Current page name #####
- name: ${device_name} Current page
id: current_page
@@ -1351,7 +1353,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 = id(entity_id); //doc["entity"];
std::string entity = detailed_entity_id->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());
@@ -1389,7 +1391,7 @@ text_sensor:
std::string component = doc["component"];
std::string key = doc["key"];
std::string value = doc["value"];
std::string entity = id(entity_id); //doc["entity"];
std::string entity = detailed_entity_id->state.c_str(); //doc["entity"];
int embedded = doc["embedded"];
std::string service = "";
@@ -1400,7 +1402,7 @@ text_sensor:
{
if (page == "home" and component == "climate")
{
id(entity_id) = (id(is_embedded_thermostat)) ? "embedded_climate" : "";
detailed_entity_id->publish_value((id(is_embedded_thermostat)) ? "embedded_climate" : "");
disp1->set_component_value("climate.embedded", (id(is_embedded_thermostat)) ? 1 : 0);
}
disp1->goto_page("climate");
@@ -2073,7 +2075,7 @@ script:
page != "media_player" &&
page != "confirm" &&
page != "keyb_num") {
id(entity_id) = "";
detailed_entity_id->publish_value("");
}
if (page != "media_player") {
id(last_volume_level) = 0;
@@ -2083,7 +2085,7 @@ script:
// Report new page to logs
ESP_LOGD(TAG, "New page: %s", page.c_str());
if (!id(entity_id).empty()) ESP_LOGD(TAG, "Entity shown: %s", id(entity_id).c_str());
if (!detailed_entity_id->state.empty()) ESP_LOGD(TAG, "Entity shown: %s", detailed_entity_id->state.c_str());
// Reset timers
timer_reset_all->execute(page.c_str());
@@ -2095,12 +2097,12 @@ script:
{
{"type", "page_changed"},
{"page", page.c_str()},
{"entity", id(entity_id)}
{"entity", detailed_entity_id->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 id(entity_id) == "embedded_climate");
addon_climate_set_climate->execute(page == "climate" and detailed_entity_id->state.c_str() == "embedded_climate");
// Call page constructor
if (page == "boot") page_boot->execute(true);