Manage indoor temp and weather icon as buttons

Solves #2056
This commit is contained in:
Edward Firmo
2024-04-24 15:46:11 +02:00
parent 72d4cd4b01
commit c4b91b8ea0
10 changed files with 157 additions and 23 deletions

View File

@@ -988,18 +988,6 @@ display:
break;
}
break;
case 1: // Home
switch (component_id) {
case 4: // indr_temp
case 27: // indr_temp_icon
if (id(is_climate) and !touch_event) { // Release
detailed_entity->publish_state((id(is_embedded_thermostat)) ? "embedded_climate" : "");
disp1->set_component_value("climate.embedded", id(is_embedded_thermostat) ? 1 : 0);
goto_page->execute("climate");
}
break;
}
break;
case 8: // Settings
switch (component_id) {
case 9: // Reboot button
@@ -1903,7 +1891,15 @@ text_sensor:
esphome::api::CustomAPIDevice ha_event;
// Send event to Home Assistant
if (event == "short_click" or event == "long_click") {
ha_button->execute(page.c_str(), component.c_str(), event.c_str());
if (api_server->is_connected() and page == "home" and component == "weather") {
goto_page->execute("weather01");
} else if (id(is_climate) and page == "home" and (component == "indr_temp" or component == "indr_temp_icon")) {
detailed_entity->publish_state((id(is_embedded_thermostat)) ? "embedded_climate" : "");
disp1->set_component_value("climate.embedded", id(is_embedded_thermostat) ? 1 : 0);
goto_page->execute("climate");
} else {
ha_button->execute(page.c_str(), component.c_str(), event.c_str());
}
} else if (page == "light" or page == "climate") { // Generic event
ha_event.fire_homeassistant_event("esphome.nspanel_ha_blueprint", {
{"device_name", device_name->state.c_str()},
@@ -2374,10 +2370,7 @@ script:
parameters:
page: string
then:
- lambda: |-
if (current_page->state != page) {
disp1->goto_page(page.c_str());
}
- lambda: if (current_page->state != page) disp1->goto_page(page.c_str());
- id: ha_button
mode: parallel

View File

@@ -83,6 +83,24 @@ Text indr_temp
Text :
Max. Text Size : 8
Events
Touch Press Event
click_comp.txt="indr_temp"
click_timer.en=1
Touch Release Event
if(click_timer.en==1)
{
click_timer.en=0
lastclick.txt="{\"page\": \"home\", \"event\": \"short_click\", \"component\": \""+click_comp.txt+"\"}"
printh 92
prints "localevent",0
printh 00
prints lastclick.txt,0
printh 00
printh FF FF FF
}
Text outdoor_temp
Attributes
ID : 5
@@ -317,6 +335,24 @@ Text indr_temp_icon
Text :
Max. Text Size : 3
Events
Touch Press Event
click_comp.txt="indr_temp_icon"
click_timer.en=1
Touch Release Event
if(click_timer.en==1)
{
click_timer.en=0
lastclick.txt="{\"page\": \"home\", \"event\": \"short_click\", \"component\": \""+click_comp.txt+"\"}"
printh 92
prints "localevent",0
printh 00
prints lastclick.txt,0
printh 00
printh FF FF FF
}
Text bt_notific
Attributes
ID : 28
@@ -659,9 +695,20 @@ Picture weather
Events
Touch Press Event
if(api==1)
click_comp.txt="indr_temp_icon"
click_timer.en=1
Touch Release Event
if(click_timer.en==1)
{
page weather01
click_timer.en=0
lastclick.txt="{\"page\": \"home\", \"event\": \"short_click\", \"component\": \""+click_comp.txt+"\"}"
printh 92
prints "localevent",0
printh 00
prints lastclick.txt,0
printh 00
printh FF FF FF
}
Timer swipestore

View File

@@ -83,6 +83,24 @@ Text indr_temp
Text :
Max. Text Size : 8
Events
Touch Press Event
click_comp.txt="indr_temp"
click_timer.en=1
Touch Release Event
if(click_timer.en==1)
{
click_timer.en=0
lastclick.txt="{\"page\": \"home\", \"event\": \"short_click\", \"component\": \""+click_comp.txt+"\"}"
printh 92
prints "localevent",0
printh 00
prints lastclick.txt,0
printh 00
printh FF FF FF
}
Text outdoor_temp
Attributes
ID : 5
@@ -317,6 +335,24 @@ Text indr_temp_icon
Text :
Max. Text Size : 3
Events
Touch Press Event
click_comp.txt="indr_temp_icon"
click_timer.en=1
Touch Release Event
if(click_timer.en==1)
{
click_timer.en=0
lastclick.txt="{\"page\": \"home\", \"event\": \"short_click\", \"component\": \""+click_comp.txt+"\"}"
printh 92
prints "localevent",0
printh 00
prints lastclick.txt,0
printh 00
printh FF FF FF
}
Text bt_notific
Attributes
ID : 28
@@ -659,9 +695,20 @@ Picture weather
Events
Touch Press Event
if(api==1)
click_comp.txt="weather"
click_timer.en=1
Touch Release Event
if(click_timer.en==1)
{
page weather01
click_timer.en=0
lastclick.txt="{\"page\": \"home\", \"event\": \"short_click\", \"component\": \""+click_comp.txt+"\"}"
printh 92
prints "localevent",0
printh 00
prints lastclick.txt,0
printh 00
printh FF FF FF
}
Timer swipestore

View File

@@ -83,6 +83,24 @@ Text indr_temp
Text :
Max. Text Size : 8
Events
Touch Press Event
click_comp.txt="indr_temp"
click_timer.en=1
Touch Release Event
if(click_timer.en==1)
{
click_timer.en=0
lastclick.txt="{\"page\": \"home\", \"event\": \"short_click\", \"component\": \""+click_comp.txt+"\"}"
printh 92
prints "localevent",0
printh 00
prints lastclick.txt,0
printh 00
printh FF FF FF
}
Text outdoor_temp
Attributes
ID : 5
@@ -317,6 +335,24 @@ Text indr_temp_icon
Text :
Max. Text Size : 3
Events
Touch Press Event
click_comp.txt="indr_temp_icon"
click_timer.en=1
Touch Release Event
if(click_timer.en==1)
{
click_timer.en=0
lastclick.txt="{\"page\": \"home\", \"event\": \"short_click\", \"component\": \""+click_comp.txt+"\"}"
printh 92
prints "localevent",0
printh 00
prints lastclick.txt,0
printh 00
printh FF FF FF
}
Text bt_notific
Attributes
ID : 28
@@ -659,9 +695,20 @@ Picture weather
Events
Touch Press Event
if(api==1)
click_comp.txt="indr_temp_icon"
click_timer.en=1
Touch Release Event
if(click_timer.en==1)
{
page weather01
click_timer.en=0
lastclick.txt="{\"page\": \"home\", \"event\": \"short_click\", \"component\": \""+click_comp.txt+"\"}"
printh 92
prints "localevent",0
printh 00
prints lastclick.txt,0
printh 00
printh FF FF FF
}
Timer swipestore

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.