Merge pull request #282 from iranl/add-lock-n-go-to-gpio

Add Lock n Go to GPIO + minor addition to README
This commit is contained in:
Jan-Ole Schümann
2024-02-01 22:23:39 +07:00
committed by GitHub
5 changed files with 56 additions and 1 deletions

View File

@@ -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;

8
Gpio.h
View File

@@ -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();

View File

@@ -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;
}
}

View File

@@ -22,6 +22,8 @@ public:
void lock();
void unlock();
void unlatch();
void lockngo();
void lockngounlatch();
bool isPinSet();
void setPin(const uint16_t pin);

View File

@@ -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.