Merge pull request #695 from iranl/optional-save-rolling-log
Make saving rolling log to flash optional
This commit is contained in:
@@ -324,7 +324,8 @@ Note: All of the following requires the Nuki security code / PIN to be set, see
|
|||||||
- Add, modify and delete timecontrol entries: Enable to allow configuration of timecontrol entries through MQTT, see the "[Timecontrol](#timecontrol)" section of this README
|
- Add, modify and delete timecontrol entries: Enable to allow configuration of timecontrol entries through MQTT, see the "[Timecontrol](#timecontrol)" section of this README
|
||||||
- Publish authorization information: Enable to publish information about authorization entries through MQTT, see the "[Authorization](#authorization)" section of this README
|
- Publish authorization information: Enable to publish information about authorization entries through MQTT, see the "[Authorization](#authorization)" section of this README
|
||||||
- Modify and delete authorization entries: Enable to allow configuration of authorization entries through MQTT, see the "[Authorization](#authorization)" section of this README
|
- Modify and delete authorization entries: Enable to allow configuration of authorization entries through MQTT, see the "[Authorization](#authorization)" section of this README
|
||||||
- Publish auth data: Enable to publish authorization data to the MQTT topic lock/log
|
- Publish authorization log: Enable to publish authorization data to the MQTT topic lock/log
|
||||||
|
- Save auth log number to flash: Enable to save the highest Nuki lock and/or opener auth log number to flash on change. Prevents duplicates in the rolling log but slightly increases flash wear.
|
||||||
|
|
||||||
#### Nuki Lock/Opener Access Control
|
#### Nuki Lock/Opener Access Control
|
||||||
- Enable or disable executing each available lock action for the Nuki Lock and Nuki Opener through MQTT. Note: GPIO control is not restricted through this setting.
|
- Enable or disable executing each available lock action for the Nuki Lock and Nuki Opener through MQTT. Note: GPIO control is not restricted through this setting.
|
||||||
|
|||||||
@@ -35,8 +35,11 @@ NukiNetworkLock::~NukiNetworkLock()
|
|||||||
|
|
||||||
void NukiNetworkLock::initialize()
|
void NukiNetworkLock::initialize()
|
||||||
{
|
{
|
||||||
_lastRollingLog = _preferences->getInt(preference_lock_log_num, 0);
|
if (_preferences->getBool(preference_save_log_num, false)) {
|
||||||
|
_lastRollingLog = _preferences->getInt(preference_lock_log_num, 0);
|
||||||
|
_saveLogEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
String mqttPath = _preferences->getString(preference_mqtt_lock_path, "");
|
String mqttPath = _preferences->getString(preference_mqtt_lock_path, "");
|
||||||
mqttPath.concat("/lock");
|
mqttPath.concat("/lock");
|
||||||
|
|
||||||
@@ -205,8 +208,7 @@ void NukiNetworkLock::onMqttDataReceived(const char* topic, byte* payload, const
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if(comparePrefixedPath(topic, mqtt_topic_lock_log_rolling_last) && !_saveLogEnabled)
|
||||||
if(comparePrefixedPath(topic, mqtt_topic_lock_log_rolling_last))
|
|
||||||
{
|
{
|
||||||
if(strcmp(data, "") == 0 ||
|
if(strcmp(data, "") == 0 ||
|
||||||
strcmp(data, "--") == 0)
|
strcmp(data, "--") == 0)
|
||||||
@@ -219,7 +221,6 @@ void NukiNetworkLock::onMqttDataReceived(const char* topic, byte* payload, const
|
|||||||
_lastRollingLog = atoi(data);
|
_lastRollingLog = atoi(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
if(_nukiOfficial->getOffEnabled())
|
if(_nukiOfficial->getOffEnabled())
|
||||||
{
|
{
|
||||||
@@ -774,7 +775,9 @@ void NukiNetworkLock::publishAuthorizationInfo(const std::list<NukiLock::LogEntr
|
|||||||
if(log.index > _lastRollingLog)
|
if(log.index > _lastRollingLog)
|
||||||
{
|
{
|
||||||
_lastRollingLog = log.index;
|
_lastRollingLog = log.index;
|
||||||
_preferences->putInt(preference_lock_log_num, _lastRollingLog);
|
if (_saveLogEnabled) {
|
||||||
|
_preferences->putInt(preference_lock_log_num, _lastRollingLog);
|
||||||
|
}
|
||||||
serializeJson(entry, _buffer, _bufferSize);
|
serializeJson(entry, _buffer, _bufferSize);
|
||||||
_nukiPublisher->publishString(mqtt_topic_lock_log_rolling, _buffer, true);
|
_nukiPublisher->publishString(mqtt_topic_lock_log_rolling, _buffer, true);
|
||||||
_nukiPublisher->publishInt(mqtt_topic_lock_log_rolling_last, log.index, true);
|
_nukiPublisher->publishInt(mqtt_topic_lock_log_rolling_last, log.index, true);
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ private:
|
|||||||
|
|
||||||
bool _firstTunerStatePublish = true;
|
bool _firstTunerStatePublish = true;
|
||||||
bool _haEnabled = false;
|
bool _haEnabled = false;
|
||||||
|
bool _saveLogEnabled = false;
|
||||||
bool _disableNonJSON = false;
|
bool _disableNonJSON = false;
|
||||||
bool _clearNonJsonKeypad = true;
|
bool _clearNonJsonKeypad = true;
|
||||||
bool _offConnected = false;
|
bool _offConnected = false;
|
||||||
|
|||||||
@@ -23,8 +23,11 @@ NukiNetworkOpener::NukiNetworkOpener(NukiNetwork* network, Preferences* preferen
|
|||||||
|
|
||||||
void NukiNetworkOpener::initialize()
|
void NukiNetworkOpener::initialize()
|
||||||
{
|
{
|
||||||
_lastRollingLog = _preferences->getInt(preference_opener_log_num, 0);
|
if (_preferences->getBool(preference_save_log_num, false)) {
|
||||||
|
_lastRollingLog = _preferences->getInt(preference_opener_log_num, 0);
|
||||||
|
_saveLogEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
String mqttPath = _preferences->getString(preference_mqtt_lock_path, "");
|
String mqttPath = _preferences->getString(preference_mqtt_lock_path, "");
|
||||||
mqttPath.concat("/opener");
|
mqttPath.concat("/opener");
|
||||||
|
|
||||||
@@ -157,8 +160,7 @@ void NukiNetworkOpener::onMqttDataReceived(const char* topic, byte* payload, con
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if(comparePrefixedPath(topic, mqtt_topic_lock_log_rolling_last) && !_saveLogEnabled)
|
||||||
if(comparePrefixedPath(topic, mqtt_topic_lock_log_rolling_last))
|
|
||||||
{
|
{
|
||||||
if(strcmp(data, "") == 0 ||
|
if(strcmp(data, "") == 0 ||
|
||||||
strcmp(data, "--") == 0)
|
strcmp(data, "--") == 0)
|
||||||
@@ -171,7 +173,6 @@ void NukiNetworkOpener::onMqttDataReceived(const char* topic, byte* payload, con
|
|||||||
_lastRollingLog = atoi(data);
|
_lastRollingLog = atoi(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
if(comparePrefixedPath(topic, mqtt_topic_lock_action))
|
if(comparePrefixedPath(topic, mqtt_topic_lock_action))
|
||||||
{
|
{
|
||||||
@@ -688,7 +689,9 @@ void NukiNetworkOpener::publishAuthorizationInfo(const std::list<NukiOpener::Log
|
|||||||
}
|
}
|
||||||
|
|
||||||
_lastRollingLog = log.index;
|
_lastRollingLog = log.index;
|
||||||
_preferences->putInt(preference_opener_log_num, _lastRollingLog);
|
if (_saveLogEnabled) {
|
||||||
|
_preferences->putInt(preference_opener_log_num, _lastRollingLog);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ private:
|
|||||||
char _mqttPath[181] = {0};
|
char _mqttPath[181] = {0};
|
||||||
bool _firstTunerStatePublish = true;
|
bool _firstTunerStatePublish = true;
|
||||||
bool _haEnabled = false;
|
bool _haEnabled = false;
|
||||||
|
bool _saveLogEnabled = false;
|
||||||
bool _disableNonJSON = false;
|
bool _disableNonJSON = false;
|
||||||
bool _clearNonJsonKeypad = true;
|
bool _clearNonJsonKeypad = true;
|
||||||
|
|
||||||
|
|||||||
@@ -158,6 +158,7 @@
|
|||||||
#define preference_mqtt_ca (char*)"mqttca"
|
#define preference_mqtt_ca (char*)"mqttca"
|
||||||
#define preference_mqtt_crt (char*)"mqttcrt"
|
#define preference_mqtt_crt (char*)"mqttcrt"
|
||||||
#define preference_mqtt_key (char*)"mqttkey"
|
#define preference_mqtt_key (char*)"mqttkey"
|
||||||
|
#define preference_save_log_num (char*)"svLgNm"
|
||||||
|
|
||||||
//NOT USER CHANGABLE
|
//NOT USER CHANGABLE
|
||||||
#define preference_mfa_reconfigure (char*)"mfaRECONF"
|
#define preference_mfa_reconfigure (char*)"mfaRECONF"
|
||||||
|
|||||||
@@ -4179,6 +4179,15 @@ bool WebCfgServer::processArgs(PsychicRequest *request, PsychicResponse* resp, S
|
|||||||
Log->println(key);
|
Log->println(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(key == "SAVELOGNUM")
|
||||||
|
{
|
||||||
|
if(_preferences->getBool(preference_save_log_num, false) != (value == "1"))
|
||||||
|
{
|
||||||
|
_preferences->putBool(preference_save_log_num, (value == "1"));
|
||||||
|
Log->print("Setting changed: ");
|
||||||
|
Log->println(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(key == "CREDDIGEST")
|
else if(key == "CREDDIGEST")
|
||||||
{
|
{
|
||||||
if(_preferences->getInt(preference_http_auth_type, 0) != value.toInt())
|
if(_preferences->getInt(preference_http_auth_type, 0) != value.toInt())
|
||||||
@@ -5925,6 +5934,7 @@ esp_err_t WebCfgServer::buildAccLvlHtml(PsychicRequest *request, PsychicResponse
|
|||||||
printCheckBox(&response, "AUTHPER", "Publish a topic per authorization entry and create HA sensor", _preferences->getBool(preference_auth_topic_per_entry), "");
|
printCheckBox(&response, "AUTHPER", "Publish a topic per authorization entry and create HA sensor", _preferences->getBool(preference_auth_topic_per_entry), "");
|
||||||
printCheckBox(&response, "AUTHENA", "Modify and delete authorization entries", _preferences->getBool(preference_auth_control_enabled), "");
|
printCheckBox(&response, "AUTHENA", "Modify and delete authorization entries", _preferences->getBool(preference_auth_control_enabled), "");
|
||||||
printCheckBox(&response, "PUBAUTH", "Publish authorization log", _preferences->getBool(preference_publish_authdata), "");
|
printCheckBox(&response, "PUBAUTH", "Publish authorization log", _preferences->getBool(preference_publish_authdata), "");
|
||||||
|
printCheckBox(&response, "SAVELOGNUM", "Save auth log number to flash", _preferences->getBool(preference_save_log_num), "");
|
||||||
response.print("</table><br>");
|
response.print("</table><br>");
|
||||||
response.print("<br><input type=\"submit\" name=\"submit\" value=\"Save\">");
|
response.print("<br><input type=\"submit\" name=\"submit\" value=\"Save\">");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user