Add Lock n Go to GPIO
This commit is contained in:
26
Gpio.cpp
26
Gpio.cpp
@@ -50,6 +50,14 @@ void Gpio::init()
|
|||||||
pinMode(entry.pin, INPUT_PULLUP);
|
pinMode(entry.pin, INPUT_PULLUP);
|
||||||
attachInterrupt(entry.pin, isrUnlatch, FALLING);
|
attachInterrupt(entry.pin, isrUnlatch, FALLING);
|
||||||
break;
|
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:
|
case PinRole::InputElectricStrikeActuation:
|
||||||
pinMode(entry.pin, INPUT_PULLUP);
|
pinMode(entry.pin, INPUT_PULLUP);
|
||||||
attachInterrupt(entry.pin, isrElectricStrikeActuation, FALLING);
|
attachInterrupt(entry.pin, isrElectricStrikeActuation, FALLING);
|
||||||
@@ -179,6 +187,10 @@ String Gpio::getRoleDescription(PinRole role) const
|
|||||||
return "Input: Unlock";
|
return "Input: Unlock";
|
||||||
case PinRole::InputUnlatch:
|
case PinRole::InputUnlatch:
|
||||||
return "Input: Unlatch";
|
return "Input: Unlatch";
|
||||||
|
case PinRole::InputLockNgo:
|
||||||
|
return "Input: Lock n Go";
|
||||||
|
case PinRole::InputLockNgoUnlatch:
|
||||||
|
return "Input: Lock n Go and unlatch";
|
||||||
case PinRole::InputElectricStrikeActuation:
|
case PinRole::InputElectricStrikeActuation:
|
||||||
return "Input: Electric strike actuation";
|
return "Input: Electric strike actuation";
|
||||||
case PinRole::InputActivateRTO:
|
case PinRole::InputActivateRTO:
|
||||||
@@ -273,6 +285,20 @@ void Gpio::isrUnlatch()
|
|||||||
_debounceTs = millis() + _debounceTime;
|
_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()
|
void Gpio::isrElectricStrikeActuation()
|
||||||
{
|
{
|
||||||
if(millis() < _debounceTs) return;
|
if(millis() < _debounceTs) return;
|
||||||
|
|||||||
8
Gpio.h
8
Gpio.h
@@ -10,6 +10,8 @@ enum class PinRole
|
|||||||
InputLock,
|
InputLock,
|
||||||
InputUnlock,
|
InputUnlock,
|
||||||
InputUnlatch,
|
InputUnlatch,
|
||||||
|
InputLockNgo,
|
||||||
|
InputLockNgoUnlatch,
|
||||||
InputElectricStrikeActuation,
|
InputElectricStrikeActuation,
|
||||||
InputActivateRTO,
|
InputActivateRTO,
|
||||||
InputActivateCM,
|
InputActivateCM,
|
||||||
@@ -30,6 +32,8 @@ enum class GpioAction
|
|||||||
Lock,
|
Lock,
|
||||||
Unlock,
|
Unlock,
|
||||||
Unlatch,
|
Unlatch,
|
||||||
|
LockNgo,
|
||||||
|
LockNgoUnlatch,
|
||||||
ElectricStrikeActuation,
|
ElectricStrikeActuation,
|
||||||
ActivateRTO,
|
ActivateRTO,
|
||||||
ActivateCM,
|
ActivateCM,
|
||||||
@@ -78,6 +82,8 @@ private:
|
|||||||
PinRole::InputLock,
|
PinRole::InputLock,
|
||||||
PinRole::InputUnlock,
|
PinRole::InputUnlock,
|
||||||
PinRole::InputUnlatch,
|
PinRole::InputUnlatch,
|
||||||
|
PinRole::InputLockNgo,
|
||||||
|
PinRole::InputLockNgoUnlatch,
|
||||||
PinRole::InputElectricStrikeActuation,
|
PinRole::InputElectricStrikeActuation,
|
||||||
PinRole::InputActivateRTO,
|
PinRole::InputActivateRTO,
|
||||||
PinRole::InputActivateCM,
|
PinRole::InputActivateCM,
|
||||||
@@ -98,6 +104,8 @@ private:
|
|||||||
static void IRAM_ATTR isrLock();
|
static void IRAM_ATTR isrLock();
|
||||||
static void IRAM_ATTR isrUnlock();
|
static void IRAM_ATTR isrUnlock();
|
||||||
static void IRAM_ATTR isrUnlatch();
|
static void IRAM_ATTR isrUnlatch();
|
||||||
|
static void IRAM_ATTR isrLockNgo();
|
||||||
|
static void IRAM_ATTR isrLockNgoUnlatch();
|
||||||
static void IRAM_ATTR isrElectricStrikeActuation();
|
static void IRAM_ATTR isrElectricStrikeActuation();
|
||||||
static void IRAM_ATTR isrActivateRTO();
|
static void IRAM_ATTR isrActivateRTO();
|
||||||
static void IRAM_ATTR isrActivateCM();
|
static void IRAM_ATTR isrActivateCM();
|
||||||
|
|||||||
@@ -277,6 +277,16 @@ void NukiWrapper::unlatch()
|
|||||||
_nextLockAction = NukiLock::LockAction::Unlatch;
|
_nextLockAction = NukiLock::LockAction::Unlatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NukiWrapper::lockngo()
|
||||||
|
{
|
||||||
|
_nextLockAction = NukiLock::LockAction::LockNgo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NukiWrapper::lockngounlatch()
|
||||||
|
{
|
||||||
|
_nextLockAction = NukiLock::LockAction::LockNgoUnlatch;
|
||||||
|
}
|
||||||
|
|
||||||
bool NukiWrapper::isPinSet()
|
bool NukiWrapper::isPinSet()
|
||||||
{
|
{
|
||||||
return _nukiLock.getSecurityPincode() != 0;
|
return _nukiLock.getSecurityPincode() != 0;
|
||||||
@@ -501,6 +511,12 @@ void NukiWrapper::gpioActionCallback(const GpioAction &action, const int& pin)
|
|||||||
case GpioAction::Unlatch:
|
case GpioAction::Unlatch:
|
||||||
nukiInst->unlatch();
|
nukiInst->unlatch();
|
||||||
break;
|
break;
|
||||||
|
case GpioAction::LockNgo:
|
||||||
|
nukiInst->lockngo();
|
||||||
|
break;
|
||||||
|
case GpioAction::LockNgoUnlatch:
|
||||||
|
nukiInst->lockngounlatch();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ public:
|
|||||||
void lock();
|
void lock();
|
||||||
void unlock();
|
void unlock();
|
||||||
void unlatch();
|
void unlatch();
|
||||||
|
void lockngo();
|
||||||
|
void lockngounlatch();
|
||||||
|
|
||||||
bool isPinSet();
|
bool isPinSet();
|
||||||
void setPin(const uint16_t pin);
|
void setPin(const uint16_t pin);
|
||||||
|
|||||||
@@ -193,7 +193,9 @@ can be configured for a specific role:
|
|||||||
- Disabled: The GPIO is disabled
|
- Disabled: The GPIO is disabled
|
||||||
- Input: Lock: When connect to Ground, a lock command is sent to the lock
|
- 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: 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: 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 RTO: When connect to Ground, Ring-to-open is activated (opener)
|
||||||
- Input: Activate CM: When connect to Ground, Continuous mode 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
|
### 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.
|
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.
|
### 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.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user