Skip to content

Commit 15c6376

Browse files
committed
Refactor event notification handling in NukiLockComponent
1 parent c143507 commit 15c6376

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

components/nuki_lock/nuki_lock.cpp

+17-12
Original file line numberDiff line numberDiff line change
@@ -1391,20 +1391,25 @@ void NukiLockComponent::dump_config() {
13911391
}
13921392

13931393
void NukiLockComponent::notify(Nuki::EventType event_type) {
1394+
ESP_LOGI(TAG, "Event notified %d", event_type);
1395+
1396+
if(event_type == Nuki::EventType::KeyTurnerStatusReset) {
1397+
// IDK
1398+
} else if (event_type == Nuki::EventType::ERROR_BAD_PIN) {
1399+
// Invalid Pin
1400+
} else if(event_type == Nuki::EventType::KeyTurnerStatusUpdated) {
1401+
// Request status update
1402+
this->status_update_ = true;
13941403

1395-
// Ignore bad pin error to prevent loop
1396-
if (event_type == Nuki::EventType::ERROR_BAD_PIN) {
1397-
return;
1398-
}
1399-
1400-
this->status_update_ = true;
1401-
1402-
// Request event logs after every notify
1403-
if (this->send_events_) {
1404-
this->event_log_update_ = true;
1404+
// Request event logs
1405+
if (this->send_events_) {
1406+
this->event_log_update_ = true;
1407+
}
1408+
} else if(event_type == Nuki::EventType::BLE_ERROR_ON_DISCONNECT) {
1409+
ESP_LOGI(TAG, "Failed to disconnect from Nuki. Restarting ESP...");
1410+
delay(100); // NOLINT
1411+
App.safe_reboot();
14051412
}
1406-
1407-
ESP_LOGI(TAG, "event notified %d", event_type);
14081413
}
14091414

14101415
void NukiLockComponent::unpair() {

0 commit comments

Comments
 (0)