Skip to content

Commit

Permalink
Added support for lock.open (unlatch door)
Browse files Browse the repository at this point in the history
  • Loading branch information
uriyacovy committed Jun 10, 2022
1 parent e135fa2 commit 255df4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion components/nuki_lock/nuki_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ void NukiLock::control(const lock::LockCall &call) {
if (state == lock::LOCK_STATE_LOCKED) {
result = this->nukiBle_->lockAction(Nuki::LockAction::Lock);
} else if (state == lock::LOCK_STATE_UNLOCKED) {
result = this->nukiBle_->lockAction(Nuki::LockAction::Unlock);
result = this->nukiBle_->lockAction(this->open_latch_ ? Nuki::LockAction::Unlatch : Nuki::LockAction::Unlock);
this->open_latch_ = false;
}
else {
ESP_LOGE(TAG, "lockAction unsupported state");
Expand Down
6 changes: 5 additions & 1 deletion components/nuki_lock/nuki_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class NukiLock : public lock::Lock, public PollingComponent {
const uint32_t deviceId_ = 2020002;
const std::string deviceName_ = "Nuki ESPHome";

explicit NukiLock() : Lock(), unpair_(false), open_latch_(false) { this->traits.set_supports_open(true); }

void setup() override;
void update() override;

Expand All @@ -47,6 +49,7 @@ class NukiLock : public lock::Lock, public PollingComponent {
protected:
void control(const lock::LockCall &call) override;
void update_status();
void open_latch() override { this->open_latch_ = true; unlock();}

binary_sensor::BinarySensor *is_paired_;
binary_sensor::BinarySensor *battery_critical_;
Expand All @@ -56,7 +59,8 @@ class NukiLock : public lock::Lock, public PollingComponent {
Nuki::KeyTurnerState retrievedKeyTurnerState_;
Handler *handler_;
bool status_update_;
bool unpair_ = false;
bool unpair_;
bool open_latch_;
};

} //namespace nuki_lock
Expand Down

0 comments on commit 255df4f

Please sign in to comment.