Show alarm state even when action is not supported
There are "read only" alarms with 0 as supported features but users still wanna see the current state. Probably solves #1146
This commit is contained in:
@@ -146,14 +146,6 @@ api:
|
||||
disp1->set_component_text_printf("code_format", "%s", code_format.c_str());
|
||||
if (code_arm_required) disp1->set_component_text_printf("code_arm_req", "1"); else disp1->set_component_text_printf("code_arm_req", "0");
|
||||
|
||||
// Alarm page - Button's icons
|
||||
disp1->set_component_text_printf("bt_home_icon", "\uE689"); //mdi:shield-home
|
||||
disp1->set_component_text_printf("bt_away_icon", "\uE99C"); //mdi:shield-lock
|
||||
disp1->set_component_text_printf("bt_night_icon", "\uF827"); //mdi:shield-moon
|
||||
disp1->set_component_text_printf("bt_vacat_icon", "\uE6BA"); //mdi:shield-airplane
|
||||
disp1->set_component_text_printf("bt_bypass_icon", "\uE77F"); //mdi:shield-half-full
|
||||
disp1->set_component_text_printf("bt_disarm_icon", "\uE99D"); //mdi:shield-off
|
||||
|
||||
// Alarm page - Button's text
|
||||
display_wrapped_text->execute("bt_home_text", mui_alarm[0].c_str(), 10);
|
||||
display_wrapped_text->execute("bt_away_text", mui_alarm[1].c_str(), 10);
|
||||
@@ -163,7 +155,7 @@ api:
|
||||
display_wrapped_text->execute("bt_disarm_text", mui_alarm[5].c_str(), 10);
|
||||
|
||||
// Alarm page - Buttons
|
||||
if (supported_features & 1) // Alarm - Button - Home
|
||||
if (supported_features & 1 or state == "armed_home") // Alarm - Button - Home
|
||||
{
|
||||
disp1->send_command_printf("bt_home_pic.pic=%i", (state == "armed_home") ? 43 : 42);
|
||||
disp1->set_component_background_color("bt_home_text", (state == "armed_home") ? 19818 : 52857);
|
||||
@@ -172,7 +164,7 @@ api:
|
||||
disp1->set_component_font_color("bt_home_icon", (state == "armed_home") ? 65535 : 0);
|
||||
if (state == "armed_home") disp1->hide_component("bt_home"); else disp1->show_component("bt_home");
|
||||
}
|
||||
if (supported_features & 2) // Alarm - Button - Away
|
||||
if (supported_features & 2 or state == "armed_away") // Alarm - Button - Away
|
||||
{
|
||||
disp1->send_command_printf("bt_away_pic.pic=%i", (state == "armed_away") ? 43 : 42);
|
||||
disp1->set_component_background_color("bt_away_text", (state == "armed_away") ? 19818 : 52857);
|
||||
@@ -181,7 +173,7 @@ api:
|
||||
disp1->set_component_font_color("bt_away_icon", (state == "armed_away") ? 65535 : 0);
|
||||
if (state == "armed_away") disp1->hide_component("bt_away"); else disp1->show_component("bt_away");
|
||||
}
|
||||
if (supported_features & 4) // Alarm - Button - Night
|
||||
if (supported_features & 4 or state == "armed_night") // Alarm - Button - Night
|
||||
{
|
||||
disp1->send_command_printf("bt_night_pic.pic=%i", (state == "armed_night") ? 43 : 42);
|
||||
disp1->set_component_background_color("bt_night_text", (state == "armed_night") ? 19818 : 52857);
|
||||
@@ -190,7 +182,7 @@ api:
|
||||
disp1->set_component_font_color("bt_night_icon", (state == "armed_night") ? 65535 : 0);
|
||||
if (state == "armed_night") disp1->hide_component("bt_night"); else disp1->show_component("bt_night");
|
||||
}
|
||||
if (supported_features & 32) // Alarm - Button - Vacation
|
||||
if (supported_features & 32 or state == "armed_vacation") // Alarm - Button - Vacation
|
||||
{
|
||||
disp1->send_command_printf("bt_vacat_pic.pic=%i", (state == "armed_vacation") ? 43 : 42);
|
||||
disp1->set_component_background_color("bt_vacat_text", (state == "armed_vacation") ? 19818 : 52857);
|
||||
@@ -199,7 +191,7 @@ api:
|
||||
disp1->set_component_font_color("bt_vacat_icon", (state == "armed_vacation") ? 65535 : 0);
|
||||
if (state == "armed_vacation") disp1->hide_component("bt_vacat"); else disp1->show_component("bt_vacat");
|
||||
}
|
||||
if (supported_features & 16) // Alarm - Button - Custom bypass
|
||||
if (supported_features & 16 or state == "armed_bypass") // Alarm - Button - Custom bypass
|
||||
{
|
||||
disp1->send_command_printf("bt_bypass_pic.pic=%i", (state == "armed_bypass") ? 43 : 42);
|
||||
disp1->set_component_background_color("bt_bypass_text", (state == "armed_bypass") ? 19818 : 52857);
|
||||
@@ -2104,7 +2096,8 @@ script:
|
||||
addon_climate_set_climate->execute(page == "climate" and detailed_entity->state == "embedded_climate");
|
||||
|
||||
// Call page constructor
|
||||
if (page == "boot") page_boot->execute(true);
|
||||
if (page == "alarm") page_alarm->execute(true);
|
||||
else if (page == "boot") page_boot->execute(true);
|
||||
else if (page == "buttonpage01") page_buttonpage->execute(true, 1);
|
||||
else if (page == "buttonpage02") page_buttonpage->execute(true, 2);
|
||||
else if (page == "buttonpage03") page_buttonpage->execute(true, 3);
|
||||
@@ -2131,6 +2124,26 @@ script:
|
||||
else if (page == "weather04") page_weather->execute(true, 4);
|
||||
else if (page == "weather05") page_weather->execute(true, 5);
|
||||
|
||||
- id: page_alarm
|
||||
mode: restart
|
||||
parameters:
|
||||
construct_page: bool
|
||||
then:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "script.page_alarm";
|
||||
if (construct_page) {
|
||||
ESP_LOGV(TAG, "Construct alarm page");
|
||||
if (current_page->state == "alarm") {
|
||||
// Alarm page - Button's icons
|
||||
disp1->set_component_text_printf("bt_home_icon", "\uE689"); //mdi:shield-home
|
||||
disp1->set_component_text_printf("bt_away_icon", "\uE99C"); //mdi:shield-lock
|
||||
disp1->set_component_text_printf("bt_night_icon", "\uF827"); //mdi:shield-moon
|
||||
disp1->set_component_text_printf("bt_vacat_icon", "\uE6BA"); //mdi:shield-airplane
|
||||
disp1->set_component_text_printf("bt_bypass_icon", "\uE77F"); //mdi:shield-half-full
|
||||
disp1->set_component_text_printf("bt_disarm_icon", "\uE99D"); //mdi:shield-off
|
||||
}
|
||||
}
|
||||
|
||||
- id: page_boot
|
||||
mode: restart
|
||||
parameters:
|
||||
@@ -2205,7 +2218,7 @@ script:
|
||||
then:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "script.page_cover";
|
||||
if (construct_page) { // To do: Should be moved to Blueprint
|
||||
if (construct_page) {
|
||||
ESP_LOGV(TAG, "Construct cover page");
|
||||
disp1->set_component_text_printf("cover.cover_stop", "%s", "\uE666"); //mdi:stop-circle-outline
|
||||
// In the future this will be dynamically contructed based on the device_class
|
||||
@@ -2233,7 +2246,7 @@ script:
|
||||
then:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "script.page_fan";
|
||||
if (construct_page) { // To do: Should be moved to Blueprint
|
||||
if (construct_page) {
|
||||
ESP_LOGV(TAG, "Construct fan page");
|
||||
disp1->set_component_text_printf("fan.button_on", "%s", "\uE20F"); //mdi:fan
|
||||
disp1->set_component_text_printf("fan.button_off", "%s", "\uE81C"); //mdi:fan-off
|
||||
@@ -2295,7 +2308,7 @@ script:
|
||||
- logger.log: Page media_player
|
||||
- lambda: |-
|
||||
static const char *const TAG = "script.page_media_player";
|
||||
if (construct_page) { // To do: Should be moved to Blueprint
|
||||
if (construct_page) {
|
||||
ESP_LOGV(TAG, "Construct media_player page");
|
||||
disp1->set_component_text_printf("bt_on_off", "%s", "\uE424"); //mdi:power
|
||||
disp1->set_component_text_printf("bt_prev", "%s", "\uE4AD"); //mdi:skip-previous
|
||||
@@ -2364,7 +2377,7 @@ script:
|
||||
then:
|
||||
- lambda: |-
|
||||
static const char *const TAG = "script.page_settings";
|
||||
if (construct_page) { // To do: Add timers on TFT?
|
||||
if (construct_page) {
|
||||
ESP_LOGV(TAG, "Construct settings page");
|
||||
//disp1->set_component_text_printf("bt_sleep", "%s", (id(sleep_mode).state) ? "\uEA19" : "\uEA18"); //mdi:toggle-switch-outline or mdi:toggle-switch-off-outline
|
||||
disp1->hide_component("lbl_sleep");
|
||||
|
||||
Reference in New Issue
Block a user