Add option to remove some non-JSON MQTT topics

This commit is contained in:
iranl
2024-05-28 22:54:51 +02:00
parent fbb2068439
commit 4d025729b0
10 changed files with 292 additions and 143 deletions

View File

@@ -122,6 +122,7 @@ In a browser navigate to the IP address assigned to the ESP32.
- Restart on disconnect: Enable to restart the Nuki Hub after 60 seconds without a connection to a network. - Restart on disconnect: Enable to restart the Nuki Hub after 60 seconds without a connection to a network.
- Enable MQTT logging: Enable to fill the maintenance/log MQTT topic with debug log information. - Enable MQTT logging: Enable to fill the maintenance/log MQTT topic with debug log information.
- Check for Firmware Updates every 24h: Enable to allow the Nuki Hub to check the latest release of the Nuki Hub firmware on boot and every 24 hours. Requires the Nuki Hub to be able to connect to github.com. The latest version will be published to MQTT and will be visible on the main page of the Web Configurator. - Check for Firmware Updates every 24h: Enable to allow the Nuki Hub to check the latest release of the Nuki Hub firmware on boot and every 24 hours. Requires the Nuki Hub to be able to connect to github.com. The latest version will be published to MQTT and will be visible on the main page of the Web Configurator.
- Disable some extraneous non-JSON topics: Enable to not publish non-JSON keypad and config MQTT topics.
#### IP Address assignment #### IP Address assignment

View File

@@ -66,7 +66,7 @@ board = esp32dev
build_flags = build_flags =
${env.build_flags} ${env.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=4 -DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
-DDEBUG_NUKIHUB -DDEBUG_NUKIHUB
-DDEBUG_SENSE_NUKI -DDEBUG_SENSE_NUKI
-DDEBUG_NUKI_COMMAND -DDEBUG_NUKI_COMMAND
@@ -80,7 +80,7 @@ board = esp32-s3-devkitc-1
build_flags = build_flags =
${env.build_flags} ${env.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=4 -DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
-DDEBUG_NUKIHUB -DDEBUG_NUKIHUB
-DDEBUG_SENSE_NUKI -DDEBUG_SENSE_NUKI
-DDEBUG_NUKI_COMMAND -DDEBUG_NUKI_COMMAND
@@ -94,7 +94,7 @@ board = esp32-c3-devkitc-02
build_flags = build_flags =
${env.build_flags} ${env.build_flags}
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=4 -DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
-DDEBUG_NUKIHUB -DDEBUG_NUKIHUB
-DDEBUG_SENSE_NUKI -DDEBUG_SENSE_NUKI
-DDEBUG_NUKI_COMMAND -DDEBUG_NUKI_COMMAND
@@ -110,7 +110,7 @@ build_flags =
${env.build_flags} ${env.build_flags}
-DFRAMEWORK_ARDUINO_SOLO1 -DFRAMEWORK_ARDUINO_SOLO1
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=4 -DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
-DDEBUG_NUKIHUB -DDEBUG_NUKIHUB
-DDEBUG_SENSE_NUKI -DDEBUG_SENSE_NUKI
-DDEBUG_NUKI_COMMAND -DDEBUG_NUKI_COMMAND

View File

@@ -264,13 +264,13 @@ void Network::initialize()
bool Network::update() bool Network::update()
{ {
unsigned long ts = millis(); unsigned long ts = millis();
if(ts > 120000 && ts < 125000 && _preferences->getInt(preference_bootloop_counter, 0) > 0) if(ts > 120000 && ts < 125000 && _preferences->getInt(preference_bootloop_counter, 0) > 0)
{ {
_preferences->putInt(preference_bootloop_counter, 0); _preferences->putInt(preference_bootloop_counter, 0);
Log->println(F("Bootloop counter reset")); Log->println(F("Bootloop counter reset"));
} }
_device->update(); _device->update();
if(!_mqttEnabled) if(!_mqttEnabled)
@@ -935,7 +935,7 @@ void Network::publishHASSConfig(char* deviceType, const char* baseTopic, char* n
"", "",
{ { (char*)"en", (char*)"true" }, { { (char*)"en", (char*)"true" },
{(char*)"ic", (char*)"mdi:counter"}}); {(char*)"ic", (char*)"mdi:counter"}});
// Nuki Hub build // Nuki Hub build
publishHassTopic("sensor", publishHassTopic("sensor",
"nuki_hub_build", "nuki_hub_build",
@@ -2298,7 +2298,7 @@ void Network::publishHASSConfigAdditionalOpenerEntities(char *deviceType, const
"", "",
{{(char*)"pl_on", (char*)"ring"}, {{(char*)"pl_on", (char*)"ring"},
{(char*)"pl_off", (char*)"standby"}}); {(char*)"pl_off", (char*)"standby"}});
JsonDocument json; JsonDocument json;
json = createHassJson(uidString, "_ring_event", "Ring", name, baseTopic, String("~") + mqtt_topic_lock_ring, deviceType, "doorbell", "", "", "", {{(char*)"val_tpl", (char*)"{ \"event_type\": \"{{ value }}\" }"}}); json = createHassJson(uidString, "_ring_event", "Ring", name, baseTopic, String("~") + mqtt_topic_lock_ring, deviceType, "doorbell", "", "", "", {{(char*)"val_tpl", (char*)"{ \"event_type\": \"{{ value }}\" }"}});
json["event_types"][0] = "ring"; json["event_types"][0] = "ring";
@@ -3152,6 +3152,18 @@ void Network::removeHassTopic(const String& mqttDeviceType, const String& mqttDe
} }
} }
void Network::removeTopic(const String& mqttPath, const String& mqttTopic)
{
String path = mqttPath;
path.concat(mqttTopic);
_device->mqttPublish(path.c_str(), MQTT_QOS_LEVEL, true, "");
#ifdef DEBUG_NUKIHUB
Log->print(F("Removing MQTT topic: "));
Log->println(path.c_str());
#endif
}
void Network::removeHASSConfig(char* uidString) void Network::removeHASSConfig(char* uidString)
{ {

View File

@@ -55,6 +55,7 @@ public:
void publishHASSWifiRssiConfig(char* deviceType, const char* baseTopic, char* name, char* uidString); void publishHASSWifiRssiConfig(char* deviceType, const char* baseTopic, char* name, char* uidString);
void removeHASSConfig(char* uidString); void removeHASSConfig(char* uidString);
void removeHASSConfigTopic(char* deviceType, char* name, char* uidString); void removeHASSConfigTopic(char* deviceType, char* name, char* uidString);
void removeTopic(const String& mqttPath, const String& mqttTopic);
void batteryTypeToString(const Nuki::BatteryType battype, char* str); void batteryTypeToString(const Nuki::BatteryType battype, char* str);
void advertisingModeToString(const Nuki::AdvertisingMode advmode, char* str); void advertisingModeToString(const Nuki::AdvertisingMode advmode, char* str);
void timeZoneIdToString(const Nuki::TimeZoneId timeZoneId, char* str); void timeZoneIdToString(const Nuki::TimeZoneId timeZoneId, char* str);

View File

@@ -63,20 +63,41 @@ void NetworkLock::initialize()
_network->subscribe(_mqttPath, mqtt_topic_query_lockstate); _network->subscribe(_mqttPath, mqtt_topic_query_lockstate);
_network->subscribe(_mqttPath, mqtt_topic_query_battery); _network->subscribe(_mqttPath, mqtt_topic_query_battery);
if(_preferences->getBool(preference_disable_non_json, false))
{
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_action);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_id);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_name);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_code);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_enabled);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_result);
_network->removeTopic(_mqttPath, mqtt_topic_config_button_enabled);
_network->removeTopic(_mqttPath, mqtt_topic_config_led_enabled);
_network->removeTopic(_mqttPath, mqtt_topic_config_led_brightness);
_network->removeTopic(_mqttPath, mqtt_topic_config_auto_unlock);
_network->removeTopic(_mqttPath, mqtt_topic_config_auto_lock);
_network->removeTopic(_mqttPath, mqtt_topic_config_single_lock);
//_network->removeTopic(_mqttPath, mqtt_topic_presence);
}
if(_preferences->getBool(preference_keypad_control_enabled)) if(_preferences->getBool(preference_keypad_control_enabled))
{ {
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_action); if(!_preferences->getBool(preference_disable_non_json, false))
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_id); {
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_name); _network->subscribe(_mqttPath, mqtt_topic_keypad_command_action);
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_code); _network->subscribe(_mqttPath, mqtt_topic_keypad_command_id);
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_enabled); _network->subscribe(_mqttPath, mqtt_topic_keypad_command_name);
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_code);
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_enabled);
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_action, "--");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_id, "0");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_name, "--");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_code, "000000");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_enabled, "1");
}
_network->subscribe(_mqttPath, mqtt_topic_query_keypad); _network->subscribe(_mqttPath, mqtt_topic_query_keypad);
_network->subscribe(_mqttPath, mqtt_topic_keypad_json_action); _network->subscribe(_mqttPath, mqtt_topic_keypad_json_action);
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_action, "--");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_id, "0");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_name, "--");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_code, "000000");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_enabled, "1");
_network->initTopic(_mqttPath, mqtt_topic_query_keypad, "0"); _network->initTopic(_mqttPath, mqtt_topic_query_keypad, "0");
_network->initTopic(_mqttPath, mqtt_topic_keypad_json_action, "--"); _network->initTopic(_mqttPath, mqtt_topic_keypad_json_action, "--");
} }
@@ -104,8 +125,7 @@ void NetworkLock::onMqttDataReceived(const char* topic, byte* payload, const uns
delay(200); delay(200);
restartEsp(RestartReason::RequestedViaMqtt); restartEsp(RestartReason::RequestedViaMqtt);
} }
else if(comparePrefixedPath(topic, mqtt_topic_webserver_action))
if(comparePrefixedPath(topic, mqtt_topic_webserver_action))
{ {
if(strcmp(value, "") == 0 || if(strcmp(value, "") == 0 ||
strcmp(value, "--") == 0) return; strcmp(value, "--") == 0) return;
@@ -164,46 +184,50 @@ void NetworkLock::onMqttDataReceived(const char* topic, byte* payload, const uns
} }
} }
if(comparePrefixedPath(topic, mqtt_topic_keypad_command_action)) if(!_preferences->getBool(preference_disable_non_json, false))
{ {
if(_keypadCommandReceivedReceivedCallback != nullptr) if(comparePrefixedPath(topic, mqtt_topic_keypad_command_action))
{ {
if(strcmp(value, "--") == 0) return; if(_keypadCommandReceivedReceivedCallback != nullptr)
_keypadCommandReceivedReceivedCallback(value, _keypadCommandId, _keypadCommandName, _keypadCommandCode, _keypadCommandEnabled);
_keypadCommandId = 0;
_keypadCommandName = "--";
_keypadCommandCode = "000000";
_keypadCommandEnabled = 1;
if(strcmp(value, "--") != 0)
{ {
publishString(mqtt_topic_keypad_command_action, "--"); if(strcmp(value, "--") == 0) return;
_keypadCommandReceivedReceivedCallback(value, _keypadCommandId, _keypadCommandName, _keypadCommandCode, _keypadCommandEnabled);
_keypadCommandId = 0;
_keypadCommandName = "--";
_keypadCommandCode = "000000";
_keypadCommandEnabled = 1;
if(strcmp(value, "--") != 0)
{
publishString(mqtt_topic_keypad_command_action, "--");
}
publishInt(mqtt_topic_keypad_command_id, _keypadCommandId);
publishString(mqtt_topic_keypad_command_name, _keypadCommandName);
publishString(mqtt_topic_keypad_command_code, _keypadCommandCode);
publishInt(mqtt_topic_keypad_command_enabled, _keypadCommandEnabled);
} }
publishInt(mqtt_topic_keypad_command_id, _keypadCommandId); }
publishString(mqtt_topic_keypad_command_name, _keypadCommandName); else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_id))
publishString(mqtt_topic_keypad_command_code, _keypadCommandCode); {
publishInt(mqtt_topic_keypad_command_enabled, _keypadCommandEnabled); _keypadCommandId = atoi(value);
}
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_name))
{
_keypadCommandName = value;
}
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_code))
{
_keypadCommandCode = value;
}
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_enabled))
{
_keypadCommandEnabled = atoi(value);
} }
} }
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_id))
{ if(comparePrefixedPath(topic, mqtt_topic_query_config) && strcmp(value, "1") == 0)
_keypadCommandId = atoi(value);
}
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_name))
{
_keypadCommandName = value;
}
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_code))
{
_keypadCommandCode = value;
}
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_enabled))
{
_keypadCommandEnabled = atoi(value);
}
else if(comparePrefixedPath(topic, mqtt_topic_query_config) && strcmp(value, "1") == 0)
{ {
_queryCommands = _queryCommands | QUERY_COMMAND_CONFIG; _queryCommands = _queryCommands | QUERY_COMMAND_CONFIG;
publishString(mqtt_topic_query_config, "0"); publishString(mqtt_topic_query_config, "0");
@@ -583,10 +607,15 @@ void NetworkLock::publishConfig(const NukiLock::Config &config)
serializeJson(json, _buffer, _bufferSize); serializeJson(json, _buffer, _bufferSize);
publishString(mqtt_topic_config_basic_json, _buffer); publishString(mqtt_topic_config_basic_json, _buffer);
publishBool(mqtt_topic_config_button_enabled, config.buttonEnabled == 1);
publishBool(mqtt_topic_config_led_enabled, config.ledEnabled == 1); if(!_preferences->getBool(preference_disable_non_json, false))
publishInt(mqtt_topic_config_led_brightness, config.ledBrightness); {
publishBool(mqtt_topic_config_single_lock, config.singleLock == 1); publishBool(mqtt_topic_config_button_enabled, config.buttonEnabled == 1);
publishBool(mqtt_topic_config_led_enabled, config.ledEnabled == 1);
publishInt(mqtt_topic_config_led_brightness, config.ledBrightness);
publishBool(mqtt_topic_config_single_lock, config.singleLock == 1);
}
publishString(mqtt_topic_info_firmware_version, std::to_string(config.firmwareVersion[0]) + "." + std::to_string(config.firmwareVersion[1]) + "." + std::to_string(config.firmwareVersion[2])); publishString(mqtt_topic_info_firmware_version, std::to_string(config.firmwareVersion[0]) + "." + std::to_string(config.firmwareVersion[1]) + "." + std::to_string(config.firmwareVersion[2]));
publishString(mqtt_topic_info_hardware_version, std::to_string(config.hardwareRevision[0]) + "." + std::to_string(config.hardwareRevision[1])); publishString(mqtt_topic_info_hardware_version, std::to_string(config.hardwareRevision[0]) + "." + std::to_string(config.hardwareRevision[1]));
} }
@@ -633,8 +662,12 @@ void NetworkLock::publishAdvancedConfig(const NukiLock::AdvancedConfig &config)
serializeJson(json, _buffer, _bufferSize); serializeJson(json, _buffer, _bufferSize);
publishString(mqtt_topic_config_advanced_json, _buffer); publishString(mqtt_topic_config_advanced_json, _buffer);
publishBool(mqtt_topic_config_auto_unlock, config.autoUnLockDisabled == 0);
publishBool(mqtt_topic_config_auto_lock, config.autoLockEnabled == 1); if(!_preferences->getBool(preference_disable_non_json, false))
{
publishBool(mqtt_topic_config_auto_unlock, config.autoUnLockDisabled == 0);
publishBool(mqtt_topic_config_auto_lock, config.autoLockEnabled == 1);
}
} }
void NetworkLock::publishRssi(const int& rssi) void NetworkLock::publishRssi(const int& rssi)
@@ -746,16 +779,42 @@ void NetworkLock::publishKeypad(const std::list<NukiLock::KeypadEntry>& entries,
serializeJson(json, _buffer, _bufferSize); serializeJson(json, _buffer, _bufferSize);
publishString(mqtt_topic_keypad_json, _buffer); publishString(mqtt_topic_keypad_json, _buffer);
while(index < maxKeypadCodeCount) if(!_preferences->getBool(preference_disable_non_json, false))
{ {
NukiLock::KeypadEntry entry; while(index < maxKeypadCodeCount)
memset(&entry, 0, sizeof(entry)); {
String basePath = mqtt_topic_keypad; NukiLock::KeypadEntry entry;
basePath.concat("/code_"); memset(&entry, 0, sizeof(entry));
basePath.concat(std::to_string(index).c_str()); String basePath = mqtt_topic_keypad;
publishKeypadEntry(basePath, entry); basePath.concat("/code_");
basePath.concat(std::to_string(index).c_str());
publishKeypadEntry(basePath, entry);
++index; ++index;
}
}
else if (maxKeypadCodeCount > 0)
{
for(int i=0; i<maxKeypadCodeCount; i++)
{
String codeTopic = _mqttPath;
codeTopic.concat(mqtt_topic_keypad);
codeTopic.concat("/code_");
codeTopic.concat(std::to_string(i).c_str());
codeTopic.concat("/");
_network->removeTopic(codeTopic, "id");
_network->removeTopic(codeTopic, "enabled");
_network->removeTopic(codeTopic, "name");
_network->removeTopic(codeTopic, "createdYear");
_network->removeTopic(codeTopic, "createdMonth");
_network->removeTopic(codeTopic, "createdDay");
_network->removeTopic(codeTopic, "createdHour");
_network->removeTopic(codeTopic, "createdMin");
_network->removeTopic(codeTopic, "createdSec");
_network->removeTopic(codeTopic, "lockCount");
}
_preferences->putUInt(preference_lock_max_keypad_code_count, 0);
} }
} }
@@ -838,6 +897,7 @@ void NetworkLock::publishConfigCommandResult(const char* result)
void NetworkLock::publishKeypadCommandResult(const char* result) void NetworkLock::publishKeypadCommandResult(const char* result)
{ {
if(_preferences->getBool(preference_disable_non_json, false)) return;
publishString(mqtt_topic_keypad_command_result, result); publishString(mqtt_topic_keypad_command_result, result);
} }
@@ -868,6 +928,7 @@ void NetworkLock::setConfigUpdateReceivedCallback(void (*configUpdateReceivedCal
void NetworkLock::setKeypadCommandReceivedCallback(void (*keypadCommandReceivedReceivedCallback)(const char* command, const uint& id, const String& name, const String& code, const int& enabled)) void NetworkLock::setKeypadCommandReceivedCallback(void (*keypadCommandReceivedReceivedCallback)(const char* command, const uint& id, const String& name, const String& code, const int& enabled))
{ {
if(_preferences->getBool(preference_disable_non_json, false)) return;
_keypadCommandReceivedReceivedCallback = keypadCommandReceivedReceivedCallback; _keypadCommandReceivedReceivedCallback = keypadCommandReceivedReceivedCallback;
} }
@@ -994,6 +1055,8 @@ bool NetworkLock::publishString(const char *topic, const char *value)
void NetworkLock::publishKeypadEntry(const String topic, NukiLock::KeypadEntry entry) void NetworkLock::publishKeypadEntry(const String topic, NukiLock::KeypadEntry entry)
{ {
if(_preferences->getBool(preference_disable_non_json, false)) return;
char codeName[sizeof(entry.name) + 1]; char codeName[sizeof(entry.name) + 1];
memset(codeName, 0, sizeof(codeName)); memset(codeName, 0, sizeof(codeName));
memcpy(codeName, entry.name, sizeof(entry.name)); memcpy(codeName, entry.name, sizeof(entry.name));

View File

@@ -50,20 +50,38 @@ void NetworkOpener::initialize()
_network->subscribe(_mqttPath, mqtt_topic_query_lockstate); _network->subscribe(_mqttPath, mqtt_topic_query_lockstate);
_network->subscribe(_mqttPath, mqtt_topic_query_battery); _network->subscribe(_mqttPath, mqtt_topic_query_battery);
if(_preferences->getBool(preference_disable_non_json, false))
{
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_action);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_id);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_name);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_code);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_enabled);
_network->removeTopic(_mqttPath, mqtt_topic_config_button_enabled);
_network->removeTopic(_mqttPath, mqtt_topic_config_led_enabled);
_network->removeTopic(_mqttPath, mqtt_topic_config_sound_level);
_network->removeTopic(_mqttPath, mqtt_topic_keypad_command_result);
//_network->removeTopic(_mqttPath, mqtt_topic_presence);
}
if(_preferences->getBool(preference_keypad_control_enabled)) if(_preferences->getBool(preference_keypad_control_enabled))
{ {
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_action); if(!_preferences->getBool(preference_disable_non_json, false))
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_id); {
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_name); _network->subscribe(_mqttPath, mqtt_topic_keypad_command_action);
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_code); _network->subscribe(_mqttPath, mqtt_topic_keypad_command_id);
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_enabled); _network->subscribe(_mqttPath, mqtt_topic_keypad_command_name);
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_code);
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_enabled);
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_action, "--");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_id, "0");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_name, "--");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_code, "000000");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_enabled, "1");
}
_network->subscribe(_mqttPath, mqtt_topic_query_keypad); _network->subscribe(_mqttPath, mqtt_topic_query_keypad);
_network->subscribe(_mqttPath, mqtt_topic_keypad_json_action); _network->subscribe(_mqttPath, mqtt_topic_keypad_json_action);
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_action, "--");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_id, "0");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_name, "--");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_code, "000000");
_network->initTopic(_mqttPath, mqtt_topic_keypad_command_enabled, "1");
_network->initTopic(_mqttPath, mqtt_topic_query_keypad, "0"); _network->initTopic(_mqttPath, mqtt_topic_query_keypad, "0");
_network->initTopic(_mqttPath, mqtt_topic_keypad_json_action, "--"); _network->initTopic(_mqttPath, mqtt_topic_keypad_json_action, "--");
} }
@@ -127,46 +145,50 @@ void NetworkOpener::onMqttDataReceived(const char* topic, byte* payload, const u
} }
} }
if(comparePrefixedPath(topic, mqtt_topic_keypad_command_action)) if(!_preferences->getBool(preference_disable_non_json, false))
{ {
if(_keypadCommandReceivedReceivedCallback != nullptr) if(comparePrefixedPath(topic, mqtt_topic_keypad_command_action))
{ {
if(strcmp(value, "--") == 0) return; if(_keypadCommandReceivedReceivedCallback != nullptr)
_keypadCommandReceivedReceivedCallback(value, _keypadCommandId, _keypadCommandName, _keypadCommandCode, _keypadCommandEnabled);
_keypadCommandId = 0;
_keypadCommandName = "--";
_keypadCommandCode = "000000";
_keypadCommandEnabled = 1;
if(strcmp(value, "--") != 0)
{ {
publishString(mqtt_topic_keypad_command_action, "--"); if(strcmp(value, "--") == 0) return;
_keypadCommandReceivedReceivedCallback(value, _keypadCommandId, _keypadCommandName, _keypadCommandCode, _keypadCommandEnabled);
_keypadCommandId = 0;
_keypadCommandName = "--";
_keypadCommandCode = "000000";
_keypadCommandEnabled = 1;
if(strcmp(value, "--") != 0)
{
publishString(mqtt_topic_keypad_command_action, "--");
}
publishInt(mqtt_topic_keypad_command_id, _keypadCommandId);
publishString(mqtt_topic_keypad_command_name, _keypadCommandName);
publishString(mqtt_topic_keypad_command_code, _keypadCommandCode);
publishInt(mqtt_topic_keypad_command_enabled, _keypadCommandEnabled);
} }
publishInt(mqtt_topic_keypad_command_id, _keypadCommandId); }
publishString(mqtt_topic_keypad_command_name, _keypadCommandName); else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_id))
publishString(mqtt_topic_keypad_command_code, _keypadCommandCode); {
publishInt(mqtt_topic_keypad_command_enabled, _keypadCommandEnabled); _keypadCommandId = atoi(value);
}
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_name))
{
_keypadCommandName = value;
}
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_code))
{
_keypadCommandCode = value;
}
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_enabled))
{
_keypadCommandEnabled = atoi(value);
} }
} }
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_id))
{ if(comparePrefixedPath(topic, mqtt_topic_query_config) && strcmp(value, "1") == 0)
_keypadCommandId = atoi(value);
}
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_name))
{
_keypadCommandName = value;
}
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_code))
{
_keypadCommandCode = value;
}
else if(comparePrefixedPath(topic, mqtt_topic_keypad_command_enabled))
{
_keypadCommandEnabled = atoi(value);
}
else if(comparePrefixedPath(topic, mqtt_topic_query_config) && strcmp(value, "1") == 0)
{ {
_queryCommands = _queryCommands | QUERY_COMMAND_CONFIG; _queryCommands = _queryCommands | QUERY_COMMAND_CONFIG;
publishString(mqtt_topic_query_config, "0"); publishString(mqtt_topic_query_config, "0");
@@ -494,7 +516,7 @@ void NetworkOpener::publishAuthorizationInfo(const std::list<NukiOpener::LogEntr
if(latest) publishString(mqtt_topic_lock_log_latest, _buffer); if(latest) publishString(mqtt_topic_lock_log_latest, _buffer);
else publishString(mqtt_topic_lock_log, _buffer); else publishString(mqtt_topic_lock_log, _buffer);
if(authFound) if(authFound)
{ {
publishUInt(mqtt_topic_lock_auth_id, _authId); publishUInt(mqtt_topic_lock_auth_id, _authId);
@@ -573,8 +595,13 @@ void NetworkOpener::publishConfig(const NukiOpener::Config &config)
serializeJson(json, _buffer, _bufferSize); serializeJson(json, _buffer, _bufferSize);
publishString(mqtt_topic_config_basic_json, _buffer); publishString(mqtt_topic_config_basic_json, _buffer);
publishBool(mqtt_topic_config_button_enabled, config.buttonEnabled == 1);
publishBool(mqtt_topic_config_led_enabled, config.ledFlashEnabled == 1); if(!_preferences->getBool(preference_disable_non_json, false))
{
publishBool(mqtt_topic_config_button_enabled, config.buttonEnabled == 1);
publishBool(mqtt_topic_config_led_enabled, config.ledFlashEnabled == 1);
}
publishString(mqtt_topic_info_firmware_version, std::to_string(config.firmwareVersion[0]) + "." + std::to_string(config.firmwareVersion[1]) + "." + std::to_string(config.firmwareVersion[2])); publishString(mqtt_topic_info_firmware_version, std::to_string(config.firmwareVersion[0]) + "." + std::to_string(config.firmwareVersion[1]) + "." + std::to_string(config.firmwareVersion[2]));
publishString(mqtt_topic_info_hardware_version, std::to_string(config.hardwareRevision[0]) + "." + std::to_string(config.hardwareRevision[1])); publishString(mqtt_topic_info_hardware_version, std::to_string(config.hardwareRevision[0]) + "." + std::to_string(config.hardwareRevision[1]));
} }
@@ -624,7 +651,11 @@ void NetworkOpener::publishAdvancedConfig(const NukiOpener::AdvancedConfig &conf
serializeJson(json, _buffer, _bufferSize); serializeJson(json, _buffer, _bufferSize);
publishString(mqtt_topic_config_advanced_json, _buffer); publishString(mqtt_topic_config_advanced_json, _buffer);
publishUInt(mqtt_topic_config_sound_level, config.soundLevel);
if(!_preferences->getBool(preference_disable_non_json, false))
{
publishUInt(mqtt_topic_config_sound_level, config.soundLevel);
}
} }
void NetworkOpener::publishRssi(const int &rssi) void NetworkOpener::publishRssi(const int &rssi)
@@ -668,7 +699,7 @@ void NetworkOpener::publishKeypad(const std::list<NukiLock::KeypadEntry>& entrie
basePath.concat("/code_"); basePath.concat("/code_");
basePath.concat(std::to_string(index).c_str()); basePath.concat(std::to_string(index).c_str());
publishKeypadEntry(basePath, entry); publishKeypadEntry(basePath, entry);
auto jsonEntry = json.add<JsonVariant>(); auto jsonEntry = json.add<JsonVariant>();
jsonEntry["codeId"] = entry.codeId; jsonEntry["codeId"] = entry.codeId;
@@ -750,16 +781,42 @@ void NetworkOpener::publishKeypad(const std::list<NukiLock::KeypadEntry>& entrie
serializeJson(json, _buffer, _bufferSize); serializeJson(json, _buffer, _bufferSize);
publishString(mqtt_topic_keypad_json, _buffer); publishString(mqtt_topic_keypad_json, _buffer);
while(index < maxKeypadCodeCount) if(!_preferences->getBool(preference_disable_non_json, false))
{ {
NukiLock::KeypadEntry entry; while(index < maxKeypadCodeCount)
memset(&entry, 0, sizeof(entry)); {
String basePath = mqtt_topic_keypad; NukiLock::KeypadEntry entry;
basePath.concat("/code_"); memset(&entry, 0, sizeof(entry));
basePath.concat(std::to_string(index).c_str()); String basePath = mqtt_topic_keypad;
publishKeypadEntry(basePath, entry); basePath.concat("/code_");
basePath.concat(std::to_string(index).c_str());
publishKeypadEntry(basePath, entry);
++index; ++index;
}
}
else if (maxKeypadCodeCount > 0)
{
for(int i=0; i<maxKeypadCodeCount; i++)
{
String codeTopic = _mqttPath;
codeTopic.concat(mqtt_topic_keypad);
codeTopic.concat("/code_");
codeTopic.concat(std::to_string(i).c_str());
codeTopic.concat("/");
_network->removeTopic(codeTopic, "id");
_network->removeTopic(codeTopic, "enabled");
_network->removeTopic(codeTopic, "name");
_network->removeTopic(codeTopic, "createdYear");
_network->removeTopic(codeTopic, "createdMonth");
_network->removeTopic(codeTopic, "createdDay");
_network->removeTopic(codeTopic, "createdHour");
_network->removeTopic(codeTopic, "createdMin");
_network->removeTopic(codeTopic, "createdSec");
_network->removeTopic(codeTopic, "lockCount");
}
_preferences->putUInt(preference_lock_max_keypad_code_count, 0);
} }
} }
@@ -842,6 +899,7 @@ void NetworkOpener::publishConfigCommandResult(const char* result)
void NetworkOpener::publishKeypadCommandResult(const char* result) void NetworkOpener::publishKeypadCommandResult(const char* result)
{ {
if(_preferences->getBool(preference_disable_non_json, false)) return;
publishString(mqtt_topic_keypad_command_result, result); publishString(mqtt_topic_keypad_command_result, result);
} }
@@ -872,6 +930,7 @@ void NetworkOpener::setConfigUpdateReceivedCallback(void (*configUpdateReceivedC
void NetworkOpener::setKeypadCommandReceivedCallback(void (*keypadCommandReceivedReceivedCallback)(const char* command, const uint& id, const String& name, const String& code, const int& enabled)) void NetworkOpener::setKeypadCommandReceivedCallback(void (*keypadCommandReceivedReceivedCallback)(const char* command, const uint& id, const String& name, const String& code, const int& enabled))
{ {
if(_preferences->getBool(preference_disable_non_json, false)) return;
_keypadCommandReceivedReceivedCallback = keypadCommandReceivedReceivedCallback; _keypadCommandReceivedReceivedCallback = keypadCommandReceivedReceivedCallback;
} }
@@ -928,6 +987,8 @@ void NetworkOpener::publishString(const char* topic, const char* value)
void NetworkOpener::publishKeypadEntry(const String topic, NukiLock::KeypadEntry entry) void NetworkOpener::publishKeypadEntry(const String topic, NukiLock::KeypadEntry entry)
{ {
if(_preferences->getBool(preference_disable_non_json, false)) return;
char codeName[sizeof(entry.name) + 1]; char codeName[sizeof(entry.name) + 1];
memset(codeName, 0, sizeof(codeName)); memset(codeName, 0, sizeof(codeName));
memcpy(codeName, entry.name, sizeof(entry.name)); memcpy(codeName, entry.name, sizeof(entry.name));

View File

@@ -32,7 +32,7 @@ NukiOpenerWrapper::NukiOpenerWrapper(const std::string& deviceName, NukiDeviceId
network->setLockActionReceivedCallback(nukiOpenerInst->onLockActionReceivedCallback); network->setLockActionReceivedCallback(nukiOpenerInst->onLockActionReceivedCallback);
network->setConfigUpdateReceivedCallback(nukiOpenerInst->onConfigUpdateReceivedCallback); network->setConfigUpdateReceivedCallback(nukiOpenerInst->onConfigUpdateReceivedCallback);
network->setKeypadCommandReceivedCallback(nukiOpenerInst->onKeypadCommandReceivedCallback); if(_preferences->getBool(preference_disable_non_json, false)) network->setKeypadCommandReceivedCallback(nukiOpenerInst->onKeypadCommandReceivedCallback);
network->setKeypadJsonCommandReceivedCallback(nukiOpenerInst->onKeypadJsonCommandReceivedCallback); network->setKeypadJsonCommandReceivedCallback(nukiOpenerInst->onKeypadJsonCommandReceivedCallback);
_gpio->addCallback(NukiOpenerWrapper::gpioActionCallback); _gpio->addCallback(NukiOpenerWrapper::gpioActionCallback);
@@ -516,7 +516,7 @@ void NukiOpenerWrapper::updateAuthData(bool retrieved)
{ {
log.resize(_preferences->getInt(preference_authlog_max_entries, 3)); log.resize(_preferences->getInt(preference_authlog_max_entries, 3));
} }
if(log.size() > 0) if(log.size() > 0)
{ {
_network->publishAuthorizationInfo(log, true); _network->publishAuthorizationInfo(log, true);
@@ -567,7 +567,7 @@ void NukiOpenerWrapper::updateKeypad(bool retrieved)
} }
uint keypadCount = entries.size(); uint keypadCount = entries.size();
if(keypadCount > _maxKeypadCodeCount) if(keypadCount > _maxKeypadCodeCount && !_preferences->getBool(preference_disable_non_json, false))
{ {
_maxKeypadCodeCount = keypadCount; _maxKeypadCodeCount = keypadCount;
_preferences->putUInt(preference_lock_max_keypad_code_count, _maxKeypadCodeCount); _preferences->putUInt(preference_lock_max_keypad_code_count, _maxKeypadCodeCount);
@@ -1354,6 +1354,8 @@ void NukiOpenerWrapper::gpioActionCallback(const GpioAction &action, const int&
void NukiOpenerWrapper::onKeypadCommandReceived(const char *command, const uint &id, const String &name, const String &code, const int& enabled) void NukiOpenerWrapper::onKeypadCommandReceived(const char *command, const uint &id, const String &name, const String &code, const int& enabled)
{ {
if(_preferences->getBool(preference_disable_non_json, false)) return;
if(!_preferences->getBool(preference_keypad_control_enabled)) if(!_preferences->getBool(preference_keypad_control_enabled))
{ {
_network->publishKeypadCommandResult("KeypadControlDisabled"); _network->publishKeypadCommandResult("KeypadControlDisabled");

View File

@@ -32,7 +32,7 @@ NukiWrapper::NukiWrapper(const std::string& deviceName, NukiDeviceId* deviceId,
network->setLockActionReceivedCallback(nukiInst->onLockActionReceivedCallback); network->setLockActionReceivedCallback(nukiInst->onLockActionReceivedCallback);
network->setConfigUpdateReceivedCallback(nukiInst->onConfigUpdateReceivedCallback); network->setConfigUpdateReceivedCallback(nukiInst->onConfigUpdateReceivedCallback);
network->setKeypadCommandReceivedCallback(nukiInst->onKeypadCommandReceivedCallback); if(_preferences->getBool(preference_disable_non_json, false)) network->setKeypadCommandReceivedCallback(nukiInst->onKeypadCommandReceivedCallback);
network->setKeypadJsonCommandReceivedCallback(nukiInst->onKeypadJsonCommandReceivedCallback); network->setKeypadJsonCommandReceivedCallback(nukiInst->onKeypadJsonCommandReceivedCallback);
network->setTimeControlCommandReceivedCallback(nukiInst->onTimeControlCommandReceivedCallback); network->setTimeControlCommandReceivedCallback(nukiInst->onTimeControlCommandReceivedCallback);
@@ -202,7 +202,7 @@ void NukiWrapper::update()
{ {
_waitKeypadUpdateTs = 0; _waitKeypadUpdateTs = 0;
updateKeypad(true); updateKeypad(true);
} }
if(_waitTimeControlUpdateTs != 0 && ts > _waitTimeControlUpdateTs) if(_waitTimeControlUpdateTs != 0 && ts > _waitTimeControlUpdateTs)
{ {
_waitTimeControlUpdateTs = 0; _waitTimeControlUpdateTs = 0;
@@ -492,12 +492,12 @@ void NukiWrapper::updateAuthData(bool retrieved)
std::list<NukiLock::LogEntry> log; std::list<NukiLock::LogEntry> log;
_nukiLock.getLogEntries(&log); _nukiLock.getLogEntries(&log);
if(log.size() > _preferences->getInt(preference_authlog_max_entries, 3)) if(log.size() > _preferences->getInt(preference_authlog_max_entries, 3))
{ {
log.resize(_preferences->getInt(preference_authlog_max_entries, 3)); log.resize(_preferences->getInt(preference_authlog_max_entries, 3));
} }
if(log.size() > 0) if(log.size() > 0)
{ {
_network->publishAuthorizationInfo(log, true); _network->publishAuthorizationInfo(log, true);
@@ -508,7 +508,7 @@ void NukiWrapper::updateAuthData(bool retrieved)
{ {
std::list<NukiLock::LogEntry> log; std::list<NukiLock::LogEntry> log;
_nukiLock.getLogEntries(&log); _nukiLock.getLogEntries(&log);
if(log.size() > _preferences->getInt(preference_authlog_max_entries, MAX_AUTHLOG)) if(log.size() > _preferences->getInt(preference_authlog_max_entries, MAX_AUTHLOG))
{ {
log.resize(_preferences->getInt(preference_authlog_max_entries, MAX_AUTHLOG)); log.resize(_preferences->getInt(preference_authlog_max_entries, MAX_AUTHLOG));
@@ -522,14 +522,14 @@ void NukiWrapper::updateAuthData(bool retrieved)
_network->publishAuthorizationInfo(log, false); _network->publishAuthorizationInfo(log, false);
} }
} }
postponeBleWatchdog(); postponeBleWatchdog();
} }
void NukiWrapper::updateKeypad(bool retrieved) void NukiWrapper::updateKeypad(bool retrieved)
{ {
if(!_preferences->getBool(preference_keypad_info_enabled)) return; if(!_preferences->getBool(preference_keypad_info_enabled)) return;
if(!retrieved) if(!retrieved)
{ {
Log->print(F("Querying lock keypad: ")); Log->print(F("Querying lock keypad: "));
@@ -549,14 +549,14 @@ void NukiWrapper::updateKeypad(bool retrieved)
Log->println(entries.size()); Log->println(entries.size());
entries.sort([](const NukiLock::KeypadEntry& a, const NukiLock::KeypadEntry& b) { return a.codeId < b.codeId; }); entries.sort([](const NukiLock::KeypadEntry& a, const NukiLock::KeypadEntry& b) { return a.codeId < b.codeId; });
if(entries.size() > _preferences->getInt(preference_keypad_max_entries, MAX_KEYPAD)) if(entries.size() > _preferences->getInt(preference_keypad_max_entries, MAX_KEYPAD))
{ {
entries.resize(_preferences->getInt(preference_keypad_max_entries, MAX_KEYPAD)); entries.resize(_preferences->getInt(preference_keypad_max_entries, MAX_KEYPAD));
} }
uint keypadCount = entries.size(); uint keypadCount = entries.size();
if(keypadCount > _maxKeypadCodeCount) if(keypadCount > _maxKeypadCodeCount && !_preferences->getBool(preference_disable_non_json, false))
{ {
_maxKeypadCodeCount = keypadCount; _maxKeypadCodeCount = keypadCount;
_preferences->putUInt(preference_lock_max_keypad_code_count, _maxKeypadCodeCount); _preferences->putUInt(preference_lock_max_keypad_code_count, _maxKeypadCodeCount);
@@ -601,12 +601,12 @@ void NukiWrapper::updateTimeControl(bool retrieved)
Log->println(timeControlEntries.size()); Log->println(timeControlEntries.size());
timeControlEntries.sort([](const NukiLock::TimeControlEntry& a, const NukiLock::TimeControlEntry& b) { return a.entryId < b.entryId; }); timeControlEntries.sort([](const NukiLock::TimeControlEntry& a, const NukiLock::TimeControlEntry& b) { return a.entryId < b.entryId; });
if(timeControlEntries.size() > _preferences->getInt(preference_timecontrol_max_entries, MAX_TIMECONTROL)) if(timeControlEntries.size() > _preferences->getInt(preference_timecontrol_max_entries, MAX_TIMECONTROL))
{ {
timeControlEntries.resize(_preferences->getInt(preference_timecontrol_max_entries, MAX_TIMECONTROL)); timeControlEntries.resize(_preferences->getInt(preference_timecontrol_max_entries, MAX_TIMECONTROL));
} }
_network->publishTimeControl(timeControlEntries); _network->publishTimeControl(timeControlEntries);
_timeControlIds.clear(); _timeControlIds.clear();
@@ -1348,6 +1348,8 @@ void NukiWrapper::gpioActionCallback(const GpioAction &action, const int& pin)
void NukiWrapper::onKeypadCommandReceived(const char *command, const uint &id, const String &name, const String &code, const int& enabled) void NukiWrapper::onKeypadCommandReceived(const char *command, const uint &id, const String &name, const String &code, const int& enabled)
{ {
if(_preferences->getBool(preference_disable_non_json, false)) return;
if(!_preferences->getBool(preference_keypad_control_enabled)) if(!_preferences->getBool(preference_keypad_control_enabled))
{ {
_network->publishKeypadCommandResult("KeypadControlDisabled"); _network->publishKeypadCommandResult("KeypadControlDisabled");
@@ -1740,7 +1742,7 @@ void NukiWrapper::onKeypadJsonCommandReceived(const char *value)
entry.codeId = codeId; entry.codeId = codeId;
size_t nameLen = strlen(name); size_t nameLen = strlen(name);
memcpy(&entry.name, name, nameLen > 20 ? 20 : nameLen); memcpy(&entry.name, name, nameLen > 20 ? 20 : nameLen);
if(code) entry.code = code; if(code) entry.code = code;
else else
{ {
@@ -1851,7 +1853,7 @@ void NukiWrapper::onTimeControlCommandReceived(const char *value)
const char *time = json["time"].as<const char*>(); const char *time = json["time"].as<const char*>();
const char *lockAct = json["lockAction"].as<const char*>(); const char *lockAct = json["lockAction"].as<const char*>();
NukiLock::LockAction timeControlLockAction; NukiLock::LockAction timeControlLockAction;
if(lockAct) if(lockAct)
{ {
timeControlLockAction = nukiInst->lockActionToEnum(lockAct); timeControlLockAction = nukiInst->lockActionToEnum(lockAct);

View File

@@ -82,6 +82,7 @@
#define preference_bootloop_counter (char*)"btlpcounter" #define preference_bootloop_counter (char*)"btlpcounter"
#define preference_enable_bootloop_reset (char*)"enabtlprst" #define preference_enable_bootloop_reset (char*)"enabtlprst"
#define preference_buffer_size (char*)"buffsize" #define preference_buffer_size (char*)"buffsize"
#define preference_disable_non_json (char*)"disnonjson"
class DebugPreferences class DebugPreferences
{ {
@@ -99,7 +100,7 @@ private:
preference_keypad_info_enabled, preference_acl, preference_timecontrol_control_enabled, preference_timecontrol_info_enabled, preference_keypad_info_enabled, preference_acl, preference_timecontrol_control_enabled, preference_timecontrol_info_enabled,
preference_conf_lock_basic_acl, preference_conf_lock_advanced_acl, preference_conf_opener_basic_acl, preference_conf_opener_advanced_acl, preference_conf_lock_basic_acl, preference_conf_lock_advanced_acl, preference_conf_opener_basic_acl, preference_conf_opener_advanced_acl,
preference_access_level, preference_register_as_app, preference_command_nr_of_retries, preference_command_retry_delay, preference_cred_user, preference_access_level, preference_register_as_app, preference_command_nr_of_retries, preference_command_retry_delay, preference_cred_user,
preference_cred_password, preference_publish_authdata, preference_publish_debug_info, preference_presence_detection_timeout, preference_cred_password, preference_publish_authdata, preference_publish_debug_info, preference_presence_detection_timeout, preference_disable_non_json,
preference_has_mac_saved, preference_has_mac_byte_0, preference_has_mac_byte_1, preference_has_mac_byte_2, preference_latest_version, preference_has_mac_saved, preference_has_mac_byte_0, preference_has_mac_byte_1, preference_has_mac_byte_2, preference_latest_version,
preference_task_size_network, preference_task_size_nuki, preference_task_size_pd, preference_authlog_max_entries, preference_keypad_max_entries, preference_timecontrol_max_entries preference_task_size_network, preference_task_size_nuki, preference_task_size_pd, preference_authlog_max_entries, preference_keypad_max_entries, preference_timecontrol_max_entries
}; };
@@ -115,7 +116,7 @@ private:
preference_started_before, preference_mqtt_log_enabled, preference_check_updates, preference_lock_enabled, preference_opener_enabled, preference_opener_continuous_mode, preference_started_before, preference_mqtt_log_enabled, preference_check_updates, preference_lock_enabled, preference_opener_enabled, preference_opener_continuous_mode,
preference_enable_bootloop_reset, preference_webserver_enabled, preference_find_best_rssi, preference_restart_on_disconnect, preference_keypad_control_enabled, preference_enable_bootloop_reset, preference_webserver_enabled, preference_find_best_rssi, preference_restart_on_disconnect, preference_keypad_control_enabled,
preference_keypad_info_enabled, preference_timecontrol_control_enabled, preference_timecontrol_info_enabled, preference_register_as_app, preference_ip_dhcp_enabled, preference_keypad_info_enabled, preference_timecontrol_control_enabled, preference_timecontrol_info_enabled, preference_register_as_app, preference_ip_dhcp_enabled,
preference_publish_authdata, preference_has_mac_saved, preference_publish_debug_info, preference_network_wifi_fallback_disabled preference_publish_authdata, preference_has_mac_saved, preference_publish_debug_info, preference_network_wifi_fallback_disabled, preference_disable_non_json
}; };
const bool isRedacted(const char* key) const const bool isRedacted(const char* key) const

View File

@@ -413,6 +413,11 @@ bool WebCfgServer::processArgs(String& message)
_preferences->putBool(preference_check_updates, (value == "1")); _preferences->putBool(preference_check_updates, (value == "1"));
configChanged = true; configChanged = true;
} }
else if(key == "DISNONJSON")
{
_preferences->putBool(preference_disable_non_json, (value == "1"));
configChanged = true;
}
else if(key == "DHCPENA") else if(key == "DHCPENA")
{ {
_preferences->putBool(preference_ip_dhcp_enabled, (value == "1")); _preferences->putBool(preference_ip_dhcp_enabled, (value == "1"));
@@ -1319,6 +1324,7 @@ void WebCfgServer::buildMqttConfigHtml(String &response)
printCheckBox(response, "RSTDISC", "Restart on disconnect", _preferences->getBool(preference_restart_on_disconnect), ""); printCheckBox(response, "RSTDISC", "Restart on disconnect", _preferences->getBool(preference_restart_on_disconnect), "");
printCheckBox(response, "MQTTLOG", "Enable MQTT logging", _preferences->getBool(preference_mqtt_log_enabled), ""); printCheckBox(response, "MQTTLOG", "Enable MQTT logging", _preferences->getBool(preference_mqtt_log_enabled), "");
printCheckBox(response, "CHECKUPDATE", "Check for Firmware Updates every 24h", _preferences->getBool(preference_check_updates), ""); printCheckBox(response, "CHECKUPDATE", "Check for Firmware Updates every 24h", _preferences->getBool(preference_check_updates), "");
printCheckBox(response, "DISNONJSON", "Disable some extraneous non-JSON topics", _preferences->getBool(preference_disable_non_json), "");
response.concat("</table>"); response.concat("</table>");
response.concat("* If no encryption is configured for the MQTT broker, leave empty. Only supported for Wi-Fi connections.<br><br>"); response.concat("* If no encryption is configured for the MQTT broker, leave empty. Only supported for Wi-Fi connections.<br><br>");