From 30ef3e584ee67aee08c5eae251c6e94c8501e445 Mon Sep 17 00:00:00 2001 From: Till Date: Sat, 27 Jan 2024 18:35:18 +0100 Subject: [PATCH] Fix unintentional button press on boot (#27) --- components/philips_action_button/action_button.cpp | 2 +- components/philips_action_button/action_button.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/philips_action_button/action_button.cpp b/components/philips_action_button/action_button.cpp index b4971df..84a2758 100644 --- a/components/philips_action_button/action_button.cpp +++ b/components/philips_action_button/action_button.cpp @@ -18,7 +18,7 @@ namespace esphome void ActionButton::loop() { // Repeated message sending for long presses - if (millis() - press_start_ <= LONG_PRESS_DURATION) + if (should_long_press_ && millis() - press_start_ <= LONG_PRESS_DURATION) { if (millis() - last_message_sent_ > LONG_PRESS_REPETITION_DELAY) { diff --git a/components/philips_action_button/action_button.h b/components/philips_action_button/action_button.h index 7b497b7..24ba191 100644 --- a/components/philips_action_button/action_button.h +++ b/components/philips_action_button/action_button.h @@ -110,7 +110,7 @@ namespace esphome /// @brief true if the component is currently performing a long press bool is_long_pressing_ = false; /// @brief time at which the button press was started - long press_start_ = 0; + long press_start_ = -(LONG_PRESS_DURATION + 1); /// @brief time at which the last message was sent long last_message_sent_ = 0; };