Fix relay toggle when button action is set to none

Solves #59
This commit is contained in:
Edward Firmo
2024-12-23 11:48:31 +01:00
parent 73ecbba3b2
commit 82af8b6687
2 changed files with 28 additions and 7 deletions

View File

@@ -189,22 +189,43 @@ script:
}
// Toggle relay if corresponding button action is enabled
ESP_LOGVV("core_hw_relays", "Toggle relays: (${BUTTON_ACTION_NONE_TEXT})");
ESP_LOGVV("core_hw_relays", " Relay 1: %s (%s)",
YESNO(sl_button_1_action->state != "${BUTTON_ACTION_NONE_TEXT}"),
sl_button_1_action->state.c_str());
ESP_LOGVV("core_hw_relays", " Relay 2: %s (%s)",
YESNO(sl_button_2_action->state != "${BUTTON_ACTION_NONE_TEXT}"),
sl_button_2_action->state.c_str());
ESP_LOGVV("core_hw_relays", " Relay 3: %s (%s)",
YESNO(sl_button_3_action->state != "${BUTTON_ACTION_NONE_TEXT}"),
sl_button_3_action->state.c_str());
ESP_LOGVV("core_hw_relays", " Relay 4: %s (%s)",
YESNO(sl_button_4_action->state != "${BUTTON_ACTION_NONE_TEXT}"),
sl_button_4_action->state.c_str());
switch (button) {
case ${BUTTON_1_ID}:
if (sl_button_1_action->state != "${RELAY_MODE_TEXT_NOT_USED}")
if (sl_button_1_action->state != "${BUTTON_ACTION_NONE_TEXT}") {
ESP_LOGV("core_hw_relays", "Toggle relay 1: (%s)", sl_button_1_action->state.c_str());
sw_relay_1->toggle();
}
break;
case ${BUTTON_2_ID}:
if (sl_button_2_action->state != "${RELAY_MODE_TEXT_NOT_USED}")
if (sl_button_2_action->state != "${BUTTON_ACTION_NONE_TEXT}") {
ESP_LOGV("core_hw_relays", "Toggle relay 2: (%s)", sl_button_2_action->state.c_str());
sw_relay_2->toggle();
}
break;
case ${BUTTON_3_ID}:
if (sl_button_3_action->state != "${RELAY_MODE_TEXT_NOT_USED}")
if (sl_button_3_action->state != "${BUTTON_ACTION_NONE_TEXT}") {
ESP_LOGV("core_hw_relays", "Toggle relay 3: (%s)", sl_button_3_action->state.c_str());
sw_relay_3->toggle();
}
break;
case ${BUTTON_4_ID}:
if (sl_button_4_action->state != "${RELAY_MODE_TEXT_NOT_USED}")
if (sl_button_4_action->state != "${BUTTON_ACTION_NONE_TEXT}") {
ESP_LOGV("core_hw_relays", "Toggle relay 4: (%s)", sl_button_4_action->state.c_str());
sw_relay_4->toggle();
}
break;
}

View File

@@ -311,9 +311,9 @@ script:
- id: touch_on_release
mode: restart
then:
# Extended by:
# - HW Buttons
# - HW Vibration
# Extended by:
# - HW Buttons
# - HW Vibration
- id: touch_swipe_left
mode: restart