diff --git a/Gpio.cpp b/Gpio.cpp index 9af20a3..0ad2c4a 100644 --- a/Gpio.cpp +++ b/Gpio.cpp @@ -50,6 +50,14 @@ void Gpio::init() pinMode(entry.pin, INPUT_PULLUP); attachInterrupt(entry.pin, isrUnlatch, FALLING); break; + case PinRole::InputLockNgo: + pinMode(entry.pin, INPUT_PULLUP); + attachInterrupt(entry.pin, isrLockNgo, FALLING); + break; + case PinRole::InputLockNgoUnlatch: + pinMode(entry.pin, INPUT_PULLUP); + attachInterrupt(entry.pin, isrLockNgoUnlatch, FALLING); + break; case PinRole::InputElectricStrikeActuation: pinMode(entry.pin, INPUT_PULLUP); attachInterrupt(entry.pin, isrElectricStrikeActuation, FALLING); @@ -179,6 +187,10 @@ String Gpio::getRoleDescription(PinRole role) const return "Input: Unlock"; case PinRole::InputUnlatch: return "Input: Unlatch"; + case PinRole::InputLockNgo: + return "Input: Lock n Go"; + case PinRole::InputLockNgoUnlatch: + return "Input: Lock n Go and unlatch"; case PinRole::InputElectricStrikeActuation: return "Input: Electric strike actuation"; case PinRole::InputActivateRTO: @@ -273,6 +285,20 @@ void Gpio::isrUnlatch() _debounceTs = millis() + _debounceTime; } +void Gpio::isrLockNgo() +{ + if(millis() < _debounceTs) return; + _inst->notify(GpioAction::LockNgo, -1); + _debounceTs = millis() + _debounceTime; +} + +void Gpio::isrLockNgoUnlatch() +{ + if(millis() < _debounceTs) return; + _inst->notify(GpioAction::LockNgoUnlatch, -1); + _debounceTs = millis() + _debounceTime; +} + void Gpio::isrElectricStrikeActuation() { if(millis() < _debounceTs) return; diff --git a/Gpio.h b/Gpio.h index a770a2c..1203c66 100644 --- a/Gpio.h +++ b/Gpio.h @@ -10,6 +10,8 @@ enum class PinRole InputLock, InputUnlock, InputUnlatch, + InputLockNgo, + InputLockNgoUnlatch, InputElectricStrikeActuation, InputActivateRTO, InputActivateCM, @@ -30,6 +32,8 @@ enum class GpioAction Lock, Unlock, Unlatch, + LockNgo, + LockNgoUnlatch, ElectricStrikeActuation, ActivateRTO, ActivateCM, @@ -78,6 +82,8 @@ private: PinRole::InputLock, PinRole::InputUnlock, PinRole::InputUnlatch, + PinRole::InputLockNgo, + PinRole::InputLockNgoUnlatch, PinRole::InputElectricStrikeActuation, PinRole::InputActivateRTO, PinRole::InputActivateCM, @@ -98,6 +104,8 @@ private: static void IRAM_ATTR isrLock(); static void IRAM_ATTR isrUnlock(); static void IRAM_ATTR isrUnlatch(); + static void IRAM_ATTR isrLockNgo(); + static void IRAM_ATTR isrLockNgoUnlatch(); static void IRAM_ATTR isrElectricStrikeActuation(); static void IRAM_ATTR isrActivateRTO(); static void IRAM_ATTR isrActivateCM(); diff --git a/NukiWrapper.cpp b/NukiWrapper.cpp index 4a79b50..50519eb 100644 --- a/NukiWrapper.cpp +++ b/NukiWrapper.cpp @@ -277,6 +277,16 @@ void NukiWrapper::unlatch() _nextLockAction = NukiLock::LockAction::Unlatch; } +void NukiWrapper::lockngo() +{ + _nextLockAction = NukiLock::LockAction::LockNgo; +} + +void NukiWrapper::lockngounlatch() +{ + _nextLockAction = NukiLock::LockAction::LockNgoUnlatch; +} + bool NukiWrapper::isPinSet() { return _nukiLock.getSecurityPincode() != 0; @@ -501,6 +511,12 @@ void NukiWrapper::gpioActionCallback(const GpioAction &action, const int& pin) case GpioAction::Unlatch: nukiInst->unlatch(); break; + case GpioAction::LockNgo: + nukiInst->lockngo(); + break; + case GpioAction::LockNgoUnlatch: + nukiInst->lockngounlatch(); + break; } } diff --git a/NukiWrapper.h b/NukiWrapper.h index c8fd14f..c20ad2f 100644 --- a/NukiWrapper.h +++ b/NukiWrapper.h @@ -22,6 +22,8 @@ public: void lock(); void unlock(); void unlatch(); + void lockngo(); + void lockngounlatch(); bool isPinSet(); void setPin(const uint16_t pin); diff --git a/README.md b/README.md index 0c0748d..ed0b1bf 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,9 @@ can be configured for a specific role: - Disabled: The GPIO is disabled - Input: Lock: When connect to Ground, a lock command is sent to the lock - Input: Unlock: When connect to Ground, an unlock command is sent to the lock -- Input: Unlatch: When connect to Ground, an unlatch command is sent to the lock +- Input: Unlatch: When connect to Ground, an unlatch command is sent to the lock +- Input: Lock n Go: When connect to Ground, a Lock n Go command is sent to the lock +- Input: Lock n Go and unlatch: When connect to Ground, a Lock n Go and unlatch command is sent to the lock - Input: Electric strike actuation: When connect to Ground, an electric strike actuation command is sent to the opener (open door for configured amount of time) - Input: Activate RTO: When connect to Ground, Ring-to-open is activated (opener) - Input: Activate CM: When connect to Ground, Continuous mode is activated (opener) @@ -285,6 +287,7 @@ See previous point, this needs the correct PIN to be configured. ### Using home assistant, it's only possible to lock or unlock the door, but not to unlatch it Unlatching can be triggered using the lock.open service. +Also make sure "Access level" under "Advanced NUKI Configuration" is set to "Full" ### When controlling two locks (or openers) connected to two ESPs, both devices react to the same command. When using Home Asistant, the same status is display for both locks.