Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
AzonInc committed Mar 24, 2024
1 parent f419679 commit 1740205
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
17 changes: 17 additions & 0 deletions components/nuki_lock/nuki_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ namespace esphome
// Terminate stale Bluetooth connections
this->nukiLock_.updateConnectionState();

if(this->pairing_mode_switch_->state)
{
if(millis() > this->pairing_mode_switch_->timer_)
{
this->pairing_mode_switch_->turn_off();
}
}

if (millis() - lastCommandExecutedTime_ < command_cooldown_millis)
{
// Give the lock time to terminate the previous command
Expand Down Expand Up @@ -590,6 +598,15 @@ namespace esphome
void NukiLockPairingModeSwitch::write_state(bool state)
{
this->parent_->set_pairing_mode(state);

if(state)
{
this->timer_ = millis() + 10000;
}
else
{
this->timer_ = 0;
}
}

} //namespace nuki_lock
Expand Down
1 change: 1 addition & 0 deletions components/nuki_lock/nuki_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ namespace esphome {
void setup() override;
void dump_config() override;
void write_state(bool state) override;
uint32_t timer_ = 0;
NukiLockComponent *parent_;
};

Expand Down

0 comments on commit 1740205

Please sign in to comment.