Auth log
This commit is contained in:
@@ -200,6 +200,7 @@ In a browser navigate to the IP address assigned to the ESP32.
|
||||
- lock/trigger: The trigger of the last action: autoLock, automatic, button, manual, system.
|
||||
- lock/lastLockAction: Reports the last lock action as a string. Possible values are: Unlock, Lock, Unlatch, LockNgo, LockNgoUnlatch, FullLock, FobAction1, FobAction2, FobAction3, Unknown.
|
||||
- lock/log: If "Publish auth data" is enabled in the web interface, this topic will be filled with the log of authorization data.
|
||||
- lock/shortLog: If "Publish auth data" is enabled in the web interface, this topic will be filled with the 3 most recent entries in the log of authorization data, updates faster than lock/log.
|
||||
- lock/completionStatus: Status of the last action as reported by Nuki Lock: success, motorBlocked, canceled, tooRecent, busy, lowMotorVoltage, clutchFailure, motorPowerFailure, incompleteFailure, invalidCode, otherError, unknown.
|
||||
- lock/authorizationId: If enabled in the web interface, this node returns the authorization id of the last lock action.
|
||||
- lock/authorizationName: If enabled in the web interface, this node returns the authorization name of the last lock action.
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#define mqtt_topic_lock_trigger "/lock/trigger"
|
||||
#define mqtt_topic_lock_last_lock_action "/lock/lastLockAction"
|
||||
#define mqtt_topic_lock_log "/lock/log"
|
||||
#define mqtt_topic_lock_log_latest "/lock/shortLog"
|
||||
#define mqtt_topic_lock_auth_id "/lock/authorizationId"
|
||||
#define mqtt_topic_lock_auth_name "/lock/authorizationName"
|
||||
#define mqtt_topic_lock_completionStatus "/lock/completionStatus"
|
||||
|
||||
@@ -429,8 +429,6 @@ void NetworkLock::publishAuthorizationInfo(const std::list<NukiLock::LogEntry>&
|
||||
}
|
||||
}
|
||||
|
||||
if(!latest)
|
||||
{
|
||||
auto entry = json.add<JsonVariant>();
|
||||
|
||||
entry["index"] = log.index;
|
||||
@@ -499,13 +497,11 @@ void NetworkLock::publishAuthorizationInfo(const std::list<NukiLock::LogEntry>&
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!latest)
|
||||
{
|
||||
serializeJson(json, _buffer, _bufferSize);
|
||||
publishString(mqtt_topic_lock_log, _buffer);
|
||||
}
|
||||
|
||||
if(latest) publishString(mqtt_topic_lock_log_latest, _buffer);
|
||||
else publishString(mqtt_topic_lock_log, _buffer);
|
||||
|
||||
if(authFound)
|
||||
{
|
||||
|
||||
@@ -398,8 +398,6 @@ void NetworkOpener::publishAuthorizationInfo(const std::list<NukiOpener::LogEntr
|
||||
}
|
||||
}
|
||||
|
||||
if(!latest)
|
||||
{
|
||||
auto entry = json.add<JsonVariant>();
|
||||
|
||||
entry["index"] = log.index;
|
||||
@@ -491,13 +489,11 @@ void NetworkOpener::publishAuthorizationInfo(const std::list<NukiOpener::LogEntr
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!latest)
|
||||
{
|
||||
serializeJson(json, _buffer, _bufferSize);
|
||||
publishString(mqtt_topic_lock_log, _buffer);
|
||||
}
|
||||
|
||||
if(latest) publishString(mqtt_topic_lock_log_latest, _buffer);
|
||||
else publishString(mqtt_topic_lock_log, _buffer);
|
||||
|
||||
if(authFound)
|
||||
{
|
||||
|
||||
@@ -499,24 +499,30 @@ void NukiOpenerWrapper::updateAuthData(bool retrieved)
|
||||
|
||||
if(!retrieved)
|
||||
{
|
||||
Nuki::CmdResult result = _nukiOpener.retrieveLogEntries(0, 3, 1, false);
|
||||
delay(250);
|
||||
Nuki::CmdResult result = _nukiOpener.retrieveLogEntries(0, _preferences->getInt(preference_authlog_max_entries, MAX_AUTHLOG), 1, false);
|
||||
Log->print(F("Retrieve log entries: "));
|
||||
Log->println(result);
|
||||
printCommandResult(result);
|
||||
if(result == Nuki::CmdResult::Success)
|
||||
{
|
||||
Nuki::CmdResult result = _nukiOpener.retrieveLogEntries(0, _preferences->getInt(preference_authlog_max_entries, MAX_AUTHLOG), 1, false);
|
||||
if(result == Nuki::CmdResult::Success)
|
||||
{
|
||||
_waitAuthLogUpdateTs = millis() + 5000;
|
||||
}
|
||||
delay(150);
|
||||
delay(100);
|
||||
|
||||
std::list<NukiOpener::LogEntry> log;
|
||||
_nukiOpener.getLogEntries(&log);
|
||||
|
||||
if(log.size() > _preferences->getInt(preference_authlog_max_entries, 3))
|
||||
{
|
||||
log.resize(_preferences->getInt(preference_authlog_max_entries, 3));
|
||||
}
|
||||
|
||||
if(log.size() > 0)
|
||||
{
|
||||
_network->publishAuthorizationInfo(log, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::list<NukiOpener::LogEntry> log;
|
||||
|
||||
@@ -480,24 +480,30 @@ void NukiWrapper::updateAuthData(bool retrieved)
|
||||
|
||||
if(!retrieved)
|
||||
{
|
||||
Nuki::CmdResult result = _nukiLock.retrieveLogEntries(0, 3, 1, false);
|
||||
delay(250);
|
||||
Nuki::CmdResult result = _nukiLock.retrieveLogEntries(0, _preferences->getInt(preference_authlog_max_entries, MAX_AUTHLOG), 1, false);
|
||||
Log->print(F("Retrieve log entries: "));
|
||||
Log->println(result);
|
||||
printCommandResult(result);
|
||||
if(result == Nuki::CmdResult::Success)
|
||||
{
|
||||
Nuki::CmdResult result = _nukiLock.retrieveLogEntries(0, _preferences->getInt(preference_authlog_max_entries, MAX_AUTHLOG), 1, false);
|
||||
if(result == Nuki::CmdResult::Success)
|
||||
{
|
||||
_waitAuthLogUpdateTs = millis() + 5000;
|
||||
}
|
||||
delay(150);
|
||||
delay(100);
|
||||
|
||||
std::list<NukiLock::LogEntry> log;
|
||||
_nukiLock.getLogEntries(&log);
|
||||
|
||||
if(log.size() > _preferences->getInt(preference_authlog_max_entries, 3))
|
||||
{
|
||||
log.resize(_preferences->getInt(preference_authlog_max_entries, 3));
|
||||
}
|
||||
|
||||
if(log.size() > 0)
|
||||
{
|
||||
_network->publishAuthorizationInfo(log, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::list<NukiLock::LogEntry> log;
|
||||
|
||||
Reference in New Issue
Block a user