Skip to content

Commit

Permalink
Fix wall panel detection
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulWieland committed Jul 12, 2024
1 parent 3ee8d49 commit 9fc41b4
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions components/ratgdo/secplus1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ namespace ratgdo {
void Secplus1::wall_panel_emulation(size_t index)
{
if (this->wall_panel_emulation_state_ == WallPanelEmulationState::WAITING) {
ESP_LOG1(TAG, "Looking for security+ 1.0 wall panel...");
ESP_LOGD(TAG, "Looking for security+ 1.0 wall panel...");

if (this->door_state != DoorState::UNKNOWN || this->light_state != LightState::UNKNOWN) {
ESP_LOG1(TAG, "Wall panel detected");
return;
}
if (millis() - this->wall_panel_emulation_start_ > 35000 && !this->wall_panel_starting_) {
ESP_LOG1(TAG, "No wall panel detected. Switching to emulation mode.");
ESP_LOGD(TAG, "No wall panel detected. Switching to emulation mode.");
this->wall_panel_emulation_state_ = WallPanelEmulationState::RUNNING;
}
this->scheduler_->set_timeout(this->ratgdo_, "wall_panel_emulation", 2000, [=] {
Expand Down Expand Up @@ -293,8 +293,10 @@ namespace ratgdo {

void Secplus1::handle_command(const RxCommand& cmd)
{
ESP_LOGD("xxx","handle rx command fired");
if (cmd.req == CommandType::QUERY_DOOR_STATUS) {
if (cmd.req == CommandType::TOGGLE_DOOR_RELEASE || cmd.resp == 0x31) {
ESP_LOGD(TAG,"wall panel is starting");
this->wall_panel_starting_ = true;
} else if (cmd.req == CommandType::QUERY_DOOR_STATUS) {

DoorState door_state;
auto val = cmd.resp & 0x7;
Expand Down Expand Up @@ -366,10 +368,6 @@ namespace ratgdo {
} else if (cmd.req == CommandType::OBSTRUCTION) {
ObstructionState obstruction_state = cmd.resp == 0 ? ObstructionState::CLEAR : ObstructionState::OBSTRUCTED;
this->ratgdo_->received(obstruction_state);
} else if (cmd.req == CommandType::TOGGLE_DOOR_RELEASE) {
if (cmd.resp == 0x31) {
this->wall_panel_starting_ = true;
}
} else if (cmd.req == CommandType::TOGGLE_LIGHT_PRESS) {
// motion was detected, or the light toggle button was pressed
// either way it's ok to trigger motion detection
Expand Down

0 comments on commit 9fc41b4

Please sign in to comment.