diff --git a/esphome/nspanel_esphome_core.yaml b/esphome/nspanel_esphome_core.yaml index da756bc..ce4b6f1 100644 --- a/esphome/nspanel_esphome_core.yaml +++ b/esphome/nspanel_esphome_core.yaml @@ -1582,12 +1582,16 @@ switch: restore_mode: RESTORE_DEFAULT_OFF on_turn_on: then: - - lambda: + - lambda: |- + if (id(relay_settings) & RelaySettings::Relay1_Local) + update_bitwise_setting(id(buttons_settings), true, ButtonSettings::ButtonLeft_State); refresh_relays->execute(1); refresh_hardware_buttons_bars->execute(1); on_turn_off: then: - - lambda: + - lambda: |- + if (id(relay_settings) & RelaySettings::Relay1_Local) + update_bitwise_setting(id(buttons_settings), false, ButtonSettings::ButtonLeft_State); refresh_relays->execute(1); refresh_hardware_buttons_bars->execute(1); ##### PHYSICAL SWITCH 2 ###### @@ -1599,12 +1603,16 @@ switch: restore_mode: RESTORE_DEFAULT_OFF on_turn_on: then: - - lambda: + - lambda: |- + if (id(relay_settings) & RelaySettings::Relay2_Local) + update_bitwise_setting(id(buttons_settings), true, ButtonSettings::ButtonRight_State); refresh_relays->execute(2); refresh_hardware_buttons_bars->execute(2); on_turn_off: then: - - lambda: + - lambda: |- + if (id(relay_settings) & RelaySettings::Relay2_Local) + update_bitwise_setting(id(buttons_settings), false, ButtonSettings::ButtonRight_State); refresh_relays->execute(2); refresh_hardware_buttons_bars->execute(2); @@ -2451,56 +2459,32 @@ script: switch (int(display_mode->state)) { case 1: // EU model if (button_mask & 1 and id(buttons_settings) & ButtonSettings::ButtonLeft_Enabled) { // Left button - disp1->fill_area(48, 307, 118, 3, - (((id(relay_settings) & RelaySettings::Relay1_Local) and relay_1->state) or (id(buttons_settings) & ButtonSettings::ButtonLeft_State)) ? - id(buttons_color_on) : id(buttons_color_off)); - disp1->fill_area(47, 308, 120, 1, - (((id(relay_settings) & RelaySettings::Relay1_Local) and relay_1->state) or (id(buttons_settings) & ButtonSettings::ButtonLeft_State)) ? - id(buttons_color_on) : id(buttons_color_off)); + disp1->fill_area(48, 307, 118, 3, (id(buttons_settings) & ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off)); + disp1->fill_area(47, 308, 120, 1, (id(buttons_settings) & ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off)); } if (button_mask & 2 and id(buttons_settings) & ButtonSettings::ButtonRight_Enabled) { // Right button - disp1->fill_area(289, 307, 118, 3, - (((id(relay_settings) & RelaySettings::Relay2_Local) and relay_2->state) or (id(buttons_settings) & ButtonSettings::ButtonRight_State)) ? - id(buttons_color_on) : id(buttons_color_off)); - disp1->fill_area(288, 308, 120, 1, - (((id(relay_settings) & RelaySettings::Relay2_Local) and relay_2->state) or (id(buttons_settings) & ButtonSettings::ButtonRight_State)) ? - id(buttons_color_on) : id(buttons_color_off)); + disp1->fill_area(289, 307, 118, 3, (id(buttons_settings) & ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off)); + disp1->fill_area(288, 308, 120, 1, (id(buttons_settings) & ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off)); } break; case 2: // US Portrait if (button_mask & 1 and id(buttons_settings) & ButtonSettings::ButtonLeft_Enabled) { // Left button - disp1->fill_area(17, 466, 118, 3, - (((id(relay_settings) & RelaySettings::Relay1_Local) and relay_1->state) or (id(buttons_settings) & ButtonSettings::ButtonLeft_State)) ? - id(buttons_color_on) : id(buttons_color_off)); - disp1->fill_area(16, 467, 120, 1, - (((id(relay_settings) & RelaySettings::Relay1_Local) and relay_1->state) or (id(buttons_settings) & ButtonSettings::ButtonLeft_State)) ? - id(buttons_color_on) : id(buttons_color_off)); + disp1->fill_area(17, 466, 118, 3, (id(buttons_settings) & ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off)); + disp1->fill_area(16, 467, 120, 1, (id(buttons_settings) & ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off)); } if (button_mask & 2 and id(buttons_settings) & ButtonSettings::ButtonRight_Enabled) { // Right button - disp1->fill_area(184, 466, 118, 3, - (((id(relay_settings) & RelaySettings::Relay2_Local) and relay_2->state) or (id(buttons_settings) & ButtonSettings::ButtonRight_State)) ? - id(buttons_color_on) : id(buttons_color_off)); - disp1->fill_area(183, 467, 120, 1, - (((id(relay_settings) & RelaySettings::Relay2_Local) and relay_2->state) or (id(buttons_settings) & ButtonSettings::ButtonRight_State)) ? - id(buttons_color_on) : id(buttons_color_off)); + disp1->fill_area(184, 466, 118, 3, (id(buttons_settings) & ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off)); + disp1->fill_area(183, 467, 120, 1, (id(buttons_settings) & ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off)); } break; case 3: // US Landscape if (button_mask & 1 and id(buttons_settings) & ButtonSettings::ButtonLeft_Enabled) { // Left button - disp1->fill_area(467, 174, 3, 118, - (((id(relay_settings) & RelaySettings::Relay1_Local) and relay_1->state) or (id(buttons_settings) & ButtonSettings::ButtonLeft_State)) ? - id(buttons_color_on) : id(buttons_color_off)); - disp1->fill_area(468, 173, 1, 120, - (((id(relay_settings) & RelaySettings::Relay1_Local) and relay_1->state) or (id(buttons_settings) & ButtonSettings::ButtonLeft_State)) ? - id(buttons_color_on) : id(buttons_color_off)); + disp1->fill_area(467, 174, 3, 118, (id(buttons_settings) & ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off)); + disp1->fill_area(468, 173, 1, 120, (id(buttons_settings) & ButtonSettings::ButtonLeft_State) ? id(buttons_color_on) : id(buttons_color_off)); } if (button_mask & 2 and id(buttons_settings) & ButtonSettings::ButtonRight_Enabled) { // Right button - disp1->fill_area(467, 28, 3, 118, - (((id(relay_settings) & RelaySettings::Relay2_Local) and relay_2->state) or (id(buttons_settings) & ButtonSettings::ButtonRight_State)) ? - id(buttons_color_on) : id(buttons_color_off)); - disp1->fill_area(468, 27, 1, 120, - (((id(relay_settings) & RelaySettings::Relay2_Local) and relay_2->state) or (id(buttons_settings) & ButtonSettings::ButtonRight_State)) ? - id(buttons_color_on) : id(buttons_color_off)); + disp1->fill_area(467, 28, 3, 118, (id(buttons_settings) & ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off)); + disp1->fill_area(468, 27, 1, 120, (id(buttons_settings) & ButtonSettings::ButtonRight_State) ? id(buttons_color_on) : id(buttons_color_off)); } break; }