Skip to content

Commit

Permalink
Merge pull request #45 from konnected-io/toggle-from-gdolib
Browse files Browse the repository at this point in the history
Let the gdolib handle door closing after toggle, reverts #42
  • Loading branch information
heythisisnate authored Apr 16, 2024
2 parents e8c48f4 + 6339e3f commit bb7a6a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions components/secplus_gdo/cover/gdo_door.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void GDODoor::set_state(gdo_door_state_t state, float position) {
this->publish_state(false);
}

void GDODoor::start_pre_close(uint32_t pos, bool toggle) {
void GDODoor::start_pre_close(uint32_t pos) {
if (this->pre_close_active_) {
return;
}
Expand All @@ -68,10 +68,7 @@ void GDODoor::start_pre_close(uint32_t pos, bool toggle) {
this->pre_close_end_trigger->trigger();
}

if (toggle) {
ESP_LOGD(TAG, "Toggling door to close");
gdo_door_toggle();
} else if (pos > 0) {
if (pos > 0) {
ESP_LOGD(TAG, "Moving door to position %d", pos);
gdo_door_move_to_target(pos);
} else {
Expand Down Expand Up @@ -102,7 +99,7 @@ void GDODoor::control(const cover::CoverCall& call) {
if (call.get_toggle()) {
ESP_LOGD(TAG, "Toggle command received");
if (this->position != COVER_CLOSED) {
this->start_pre_close(0, true);
this->start_pre_close(0);
} else {
gdo_door_toggle();
}
Expand Down
2 changes: 1 addition & 1 deletion components/secplus_gdo/cover/gdo_door.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ using namespace esphome::cover;
this->pre_close_end_trigger = trigger;
}

void start_pre_close(uint32_t pos = 0, bool toggle = false);
void start_pre_close(uint32_t pos = 0);
void set_pre_close_warning_duration(uint32_t ms) { this->pre_close_duration_ = ms; }
void set_state(gdo_door_state_t state, float position);

Expand Down

0 comments on commit bb7a6a2

Please sign in to comment.