Add option to remove some non-JSON MQTT topics
This commit is contained in:
@@ -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.
|
||||
- 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.
|
||||
- Disable some extraneous non-JSON topics: Enable to not publish non-JSON keypad and config MQTT topics.
|
||||
|
||||
#### IP Address assignment
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ board = esp32dev
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=4
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
|
||||
-DDEBUG_NUKIHUB
|
||||
-DDEBUG_SENSE_NUKI
|
||||
-DDEBUG_NUKI_COMMAND
|
||||
@@ -80,7 +80,7 @@ board = esp32-s3-devkitc-1
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=4
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
|
||||
-DDEBUG_NUKIHUB
|
||||
-DDEBUG_SENSE_NUKI
|
||||
-DDEBUG_NUKI_COMMAND
|
||||
@@ -94,7 +94,7 @@ board = esp32-c3-devkitc-02
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=4
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
|
||||
-DDEBUG_NUKIHUB
|
||||
-DDEBUG_SENSE_NUKI
|
||||
-DDEBUG_NUKI_COMMAND
|
||||
@@ -110,7 +110,7 @@ build_flags =
|
||||
${env.build_flags}
|
||||
-DFRAMEWORK_ARDUINO_SOLO1
|
||||
-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=4
|
||||
-DCONFIG_NIMBLE_CPP_LOG_LEVEL=0
|
||||
-DDEBUG_NUKIHUB
|
||||
-DDEBUG_SENSE_NUKI
|
||||
-DDEBUG_NUKI_COMMAND
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -55,6 +55,7 @@ public:
|
||||
void publishHASSWifiRssiConfig(char* deviceType, const char* baseTopic, char* name, char* uidString);
|
||||
void removeHASSConfig(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 advertisingModeToString(const Nuki::AdvertisingMode advmode, char* str);
|
||||
void timeZoneIdToString(const Nuki::TimeZoneId timeZoneId, char* str);
|
||||
|
||||
@@ -63,20 +63,41 @@ void NetworkLock::initialize()
|
||||
_network->subscribe(_mqttPath, mqtt_topic_query_lockstate);
|
||||
_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_disable_non_json, false))
|
||||
{
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_action);
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_id);
|
||||
_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->subscribe(_mqttPath, mqtt_topic_query_keypad);
|
||||
_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->subscribe(_mqttPath, mqtt_topic_query_keypad);
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_json_action);
|
||||
_network->initTopic(_mqttPath, mqtt_topic_query_keypad, "0");
|
||||
_network->initTopic(_mqttPath, mqtt_topic_keypad_json_action, "--");
|
||||
}
|
||||
@@ -104,8 +125,7 @@ void NetworkLock::onMqttDataReceived(const char* topic, byte* payload, const uns
|
||||
delay(200);
|
||||
restartEsp(RestartReason::RequestedViaMqtt);
|
||||
}
|
||||
|
||||
if(comparePrefixedPath(topic, mqtt_topic_webserver_action))
|
||||
else if(comparePrefixedPath(topic, mqtt_topic_webserver_action))
|
||||
{
|
||||
if(strcmp(value, "") == 0 ||
|
||||
strcmp(value, "--") == 0) return;
|
||||
@@ -164,6 +184,8 @@ void NetworkLock::onMqttDataReceived(const char* topic, byte* payload, const uns
|
||||
}
|
||||
}
|
||||
|
||||
if(!_preferences->getBool(preference_disable_non_json, false))
|
||||
{
|
||||
if(comparePrefixedPath(topic, mqtt_topic_keypad_command_action))
|
||||
{
|
||||
if(_keypadCommandReceivedReceivedCallback != nullptr)
|
||||
@@ -203,7 +225,9 @@ void NetworkLock::onMqttDataReceived(const char* topic, byte* payload, const uns
|
||||
{
|
||||
_keypadCommandEnabled = atoi(value);
|
||||
}
|
||||
else if(comparePrefixedPath(topic, mqtt_topic_query_config) && strcmp(value, "1") == 0)
|
||||
}
|
||||
|
||||
if(comparePrefixedPath(topic, mqtt_topic_query_config) && strcmp(value, "1") == 0)
|
||||
{
|
||||
_queryCommands = _queryCommands | QUERY_COMMAND_CONFIG;
|
||||
publishString(mqtt_topic_query_config, "0");
|
||||
@@ -583,10 +607,15 @@ void NetworkLock::publishConfig(const NukiLock::Config &config)
|
||||
|
||||
serializeJson(json, _buffer, _bufferSize);
|
||||
publishString(mqtt_topic_config_basic_json, _buffer);
|
||||
|
||||
if(!_preferences->getBool(preference_disable_non_json, false))
|
||||
{
|
||||
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_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);
|
||||
publishString(mqtt_topic_config_advanced_json, _buffer);
|
||||
|
||||
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)
|
||||
@@ -746,6 +779,8 @@ void NetworkLock::publishKeypad(const std::list<NukiLock::KeypadEntry>& entries,
|
||||
serializeJson(json, _buffer, _bufferSize);
|
||||
publishString(mqtt_topic_keypad_json, _buffer);
|
||||
|
||||
if(!_preferences->getBool(preference_disable_non_json, false))
|
||||
{
|
||||
while(index < maxKeypadCodeCount)
|
||||
{
|
||||
NukiLock::KeypadEntry entry;
|
||||
@@ -757,6 +792,30 @@ void NetworkLock::publishKeypad(const std::list<NukiLock::KeypadEntry>& entries,
|
||||
|
||||
++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);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkLock::publishTimeControl(const std::list<NukiLock::TimeControlEntry>& timeControlEntries)
|
||||
@@ -838,6 +897,7 @@ void NetworkLock::publishConfigCommandResult(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);
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
if(_preferences->getBool(preference_disable_non_json, false)) return;
|
||||
_keypadCommandReceivedReceivedCallback = keypadCommandReceivedReceivedCallback;
|
||||
}
|
||||
|
||||
@@ -994,6 +1055,8 @@ bool NetworkLock::publishString(const char *topic, const char *value)
|
||||
|
||||
void NetworkLock::publishKeypadEntry(const String topic, NukiLock::KeypadEntry entry)
|
||||
{
|
||||
if(_preferences->getBool(preference_disable_non_json, false)) return;
|
||||
|
||||
char codeName[sizeof(entry.name) + 1];
|
||||
memset(codeName, 0, sizeof(codeName));
|
||||
memcpy(codeName, entry.name, sizeof(entry.name));
|
||||
|
||||
@@ -50,20 +50,38 @@ void NetworkOpener::initialize()
|
||||
_network->subscribe(_mqttPath, mqtt_topic_query_lockstate);
|
||||
_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_disable_non_json, false))
|
||||
{
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_action);
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_command_id);
|
||||
_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->subscribe(_mqttPath, mqtt_topic_query_keypad);
|
||||
_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->subscribe(_mqttPath, mqtt_topic_query_keypad);
|
||||
_network->subscribe(_mqttPath, mqtt_topic_keypad_json_action);
|
||||
_network->initTopic(_mqttPath, mqtt_topic_query_keypad, "0");
|
||||
_network->initTopic(_mqttPath, mqtt_topic_keypad_json_action, "--");
|
||||
}
|
||||
@@ -127,6 +145,8 @@ void NetworkOpener::onMqttDataReceived(const char* topic, byte* payload, const u
|
||||
}
|
||||
}
|
||||
|
||||
if(!_preferences->getBool(preference_disable_non_json, false))
|
||||
{
|
||||
if(comparePrefixedPath(topic, mqtt_topic_keypad_command_action))
|
||||
{
|
||||
if(_keypadCommandReceivedReceivedCallback != nullptr)
|
||||
@@ -166,7 +186,9 @@ void NetworkOpener::onMqttDataReceived(const char* topic, byte* payload, const u
|
||||
{
|
||||
_keypadCommandEnabled = atoi(value);
|
||||
}
|
||||
else if(comparePrefixedPath(topic, mqtt_topic_query_config) && strcmp(value, "1") == 0)
|
||||
}
|
||||
|
||||
if(comparePrefixedPath(topic, mqtt_topic_query_config) && strcmp(value, "1") == 0)
|
||||
{
|
||||
_queryCommands = _queryCommands | QUERY_COMMAND_CONFIG;
|
||||
publishString(mqtt_topic_query_config, "0");
|
||||
@@ -573,8 +595,13 @@ void NetworkOpener::publishConfig(const NukiOpener::Config &config)
|
||||
|
||||
serializeJson(json, _buffer, _bufferSize);
|
||||
publishString(mqtt_topic_config_basic_json, _buffer);
|
||||
|
||||
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_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);
|
||||
publishString(mqtt_topic_config_advanced_json, _buffer);
|
||||
|
||||
if(!_preferences->getBool(preference_disable_non_json, false))
|
||||
{
|
||||
publishUInt(mqtt_topic_config_sound_level, config.soundLevel);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkOpener::publishRssi(const int &rssi)
|
||||
@@ -750,6 +781,8 @@ void NetworkOpener::publishKeypad(const std::list<NukiLock::KeypadEntry>& entrie
|
||||
serializeJson(json, _buffer, _bufferSize);
|
||||
publishString(mqtt_topic_keypad_json, _buffer);
|
||||
|
||||
if(!_preferences->getBool(preference_disable_non_json, false))
|
||||
{
|
||||
while(index < maxKeypadCodeCount)
|
||||
{
|
||||
NukiLock::KeypadEntry entry;
|
||||
@@ -761,6 +794,30 @@ void NetworkOpener::publishKeypad(const std::list<NukiLock::KeypadEntry>& entrie
|
||||
|
||||
++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);
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkOpener::publishTimeControl(const std::list<NukiOpener::TimeControlEntry>& timeControlEntries)
|
||||
@@ -842,6 +899,7 @@ void NetworkOpener::publishConfigCommandResult(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);
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
if(_preferences->getBool(preference_disable_non_json, false)) return;
|
||||
_keypadCommandReceivedReceivedCallback = keypadCommandReceivedReceivedCallback;
|
||||
}
|
||||
|
||||
@@ -928,6 +987,8 @@ void NetworkOpener::publishString(const char* topic, const char* value)
|
||||
|
||||
void NetworkOpener::publishKeypadEntry(const String topic, NukiLock::KeypadEntry entry)
|
||||
{
|
||||
if(_preferences->getBool(preference_disable_non_json, false)) return;
|
||||
|
||||
char codeName[sizeof(entry.name) + 1];
|
||||
memset(codeName, 0, sizeof(codeName));
|
||||
memcpy(codeName, entry.name, sizeof(entry.name));
|
||||
|
||||
@@ -32,7 +32,7 @@ NukiOpenerWrapper::NukiOpenerWrapper(const std::string& deviceName, NukiDeviceId
|
||||
|
||||
network->setLockActionReceivedCallback(nukiOpenerInst->onLockActionReceivedCallback);
|
||||
network->setConfigUpdateReceivedCallback(nukiOpenerInst->onConfigUpdateReceivedCallback);
|
||||
network->setKeypadCommandReceivedCallback(nukiOpenerInst->onKeypadCommandReceivedCallback);
|
||||
if(_preferences->getBool(preference_disable_non_json, false)) network->setKeypadCommandReceivedCallback(nukiOpenerInst->onKeypadCommandReceivedCallback);
|
||||
network->setKeypadJsonCommandReceivedCallback(nukiOpenerInst->onKeypadJsonCommandReceivedCallback);
|
||||
|
||||
_gpio->addCallback(NukiOpenerWrapper::gpioActionCallback);
|
||||
@@ -567,7 +567,7 @@ void NukiOpenerWrapper::updateKeypad(bool retrieved)
|
||||
}
|
||||
|
||||
uint keypadCount = entries.size();
|
||||
if(keypadCount > _maxKeypadCodeCount)
|
||||
if(keypadCount > _maxKeypadCodeCount && !_preferences->getBool(preference_disable_non_json, false))
|
||||
{
|
||||
_maxKeypadCodeCount = keypadCount;
|
||||
_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)
|
||||
{
|
||||
if(_preferences->getBool(preference_disable_non_json, false)) return;
|
||||
|
||||
if(!_preferences->getBool(preference_keypad_control_enabled))
|
||||
{
|
||||
_network->publishKeypadCommandResult("KeypadControlDisabled");
|
||||
|
||||
@@ -32,7 +32,7 @@ NukiWrapper::NukiWrapper(const std::string& deviceName, NukiDeviceId* deviceId,
|
||||
|
||||
network->setLockActionReceivedCallback(nukiInst->onLockActionReceivedCallback);
|
||||
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->setTimeControlCommandReceivedCallback(nukiInst->onTimeControlCommandReceivedCallback);
|
||||
|
||||
@@ -556,7 +556,7 @@ void NukiWrapper::updateKeypad(bool retrieved)
|
||||
}
|
||||
|
||||
uint keypadCount = entries.size();
|
||||
if(keypadCount > _maxKeypadCodeCount)
|
||||
if(keypadCount > _maxKeypadCodeCount && !_preferences->getBool(preference_disable_non_json, false))
|
||||
{
|
||||
_maxKeypadCodeCount = keypadCount;
|
||||
_preferences->putUInt(preference_lock_max_keypad_code_count, _maxKeypadCodeCount);
|
||||
@@ -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)
|
||||
{
|
||||
if(_preferences->getBool(preference_disable_non_json, false)) return;
|
||||
|
||||
if(!_preferences->getBool(preference_keypad_control_enabled))
|
||||
{
|
||||
_network->publishKeypadCommandResult("KeypadControlDisabled");
|
||||
|
||||
@@ -82,6 +82,7 @@
|
||||
#define preference_bootloop_counter (char*)"btlpcounter"
|
||||
#define preference_enable_bootloop_reset (char*)"enabtlprst"
|
||||
#define preference_buffer_size (char*)"buffsize"
|
||||
#define preference_disable_non_json (char*)"disnonjson"
|
||||
|
||||
class DebugPreferences
|
||||
{
|
||||
@@ -99,7 +100,7 @@ private:
|
||||
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_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_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_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_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
|
||||
|
||||
@@ -413,6 +413,11 @@ bool WebCfgServer::processArgs(String& message)
|
||||
_preferences->putBool(preference_check_updates, (value == "1"));
|
||||
configChanged = true;
|
||||
}
|
||||
else if(key == "DISNONJSON")
|
||||
{
|
||||
_preferences->putBool(preference_disable_non_json, (value == "1"));
|
||||
configChanged = true;
|
||||
}
|
||||
else if(key == "DHCPENA")
|
||||
{
|
||||
_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, "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, "DISNONJSON", "Disable some extraneous non-JSON topics", _preferences->getBool(preference_disable_non_json), "");
|
||||
response.concat("</table>");
|
||||
response.concat("* If no encryption is configured for the MQTT broker, leave empty. Only supported for Wi-Fi connections.<br><br>");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user