Fixed bug that all locks are triggered at the same time.

This commit is contained in:
2026-03-27 16:33:22 +01:00
parent 7322653882
commit 6b6e9f5f9c
2 changed files with 20 additions and 6 deletions

View File

@@ -5,8 +5,8 @@
#define NUKI_HUB_VERSION "9.15"
#define NUKI_HUB_VERSION_INT (uint32_t)915
#define NUKI_HUB_BUILD "unknownbuildnr"
#define NUKI_HUB_DATE "2026-03-20"
#define NUKI_HUB_DATE "2026-03-20"
#define NUKI_HUB_DATE "2026-03-27"
#define NUKI_HUB_DATE "2026-03-27"
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"

View File

@@ -14,9 +14,22 @@ extern bool forceEnableWebServer;
extern const uint8_t x509_crt_imported_bundle_bin_start[] asm("_binary_x509_crt_bundle_start");
extern const uint8_t x509_crt_imported_bundle_bin_end[] asm("_binary_x509_crt_bundle_end");
static String normalizedLockMqttName(Preferences* preferences, const char* prefKey)
static const char* defaultLockMqttNameForSlot(uint8_t lockSlot)
{
String in = preferences->getString(prefKey, "lock");
switch(lockSlot)
{
case 2:
return "lock2";
case 3:
return "lock3";
default:
return "lock";
}
}
static String normalizedLockMqttName(Preferences* preferences, const char* prefKey, const char* fallback)
{
String in = preferences->getString(prefKey, fallback);
in.trim();
in.toLowerCase();
@@ -33,7 +46,7 @@ static String normalizedLockMqttName(Preferences* preferences, const char* prefK
if(out.length() < 3 || out.length() > 32)
{
return String("lock");
return String(fallback);
}
return out;
@@ -67,9 +80,10 @@ void NukiNetworkLock::initialize()
_saveLogEnabled = true;
}
const char* defaultMqttName = defaultLockMqttNameForSlot(_lockSlot);
String mqttPath = _preferences->getString(preference_mqtt_lock_path, "");
mqttPath.concat("/");
mqttPath.concat(normalizedLockMqttName(_preferences, mqttNamePreferenceKey()));
mqttPath.concat(normalizedLockMqttName(_preferences, mqttNamePreferenceKey(), defaultMqttName));
size_t len = mqttPath.length();
for(int i=0; i < len; i++)