Fix intermediate state

This commit is contained in:
iranl
2024-11-11 20:07:14 +01:00
parent f97593eea7
commit 6acfadef8d
6 changed files with 16 additions and 14 deletions

View File

@@ -4,7 +4,7 @@
#define NUKI_HUB_VERSION "9.02" #define NUKI_HUB_VERSION "9.02"
#define NUKI_HUB_BUILD "unknownbuildnr" #define NUKI_HUB_BUILD "unknownbuildnr"
#define NUKI_HUB_DATE "2024-11-08" #define NUKI_HUB_DATE "2024-11-11"
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest" #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" #define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"

View File

@@ -272,9 +272,8 @@ void NukiOpenerWrapper::update()
} }
if(_statusUpdated || _nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs || (queryCommands & QUERY_COMMAND_LOCKSTATE) > 0) if(_statusUpdated || _nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs || (queryCommands & QUERY_COMMAND_LOCKSTATE) > 0)
{ {
updateKeyTurnerState(); _statusUpdated = updateKeyTurnerState();
_nextLockStateUpdateTs = ts + _intervalLockstate * 1000; _nextLockStateUpdateTs = ts + _intervalLockstate * 1000;
_statusUpdated = false;
_network->publishStatusUpdated(_statusUpdated); _network->publishStatusUpdated(_statusUpdated);
} }
if(_network->mqttConnectionState() == 2) if(_network->mqttConnectionState() == 2)
@@ -418,8 +417,9 @@ void NukiOpenerWrapper::unpair()
_paired = false; _paired = false;
} }
void NukiOpenerWrapper::updateKeyTurnerState() bool NukiOpenerWrapper::updateKeyTurnerState()
{ {
bool updateStatus = false;
Nuki::CmdResult result = (Nuki::CmdResult)-1; Nuki::CmdResult result = (Nuki::CmdResult)-1;
int retryCount = 0; int retryCount = 0;
@@ -445,7 +445,7 @@ void NukiOpenerWrapper::updateKeyTurnerState()
{ {
_nextLockStateUpdateTs = espMillis() + _retryDelay; _nextLockStateUpdateTs = espMillis() + _retryDelay;
} }
return; return false;
} }
_retryLockstateCount = 0; _retryLockstateCount = 0;
@@ -491,6 +491,7 @@ void NukiOpenerWrapper::updateKeyTurnerState()
postponeBleWatchdog(); postponeBleWatchdog();
Log->println(F("Done querying opener state")); Log->println(F("Done querying opener state"));
return updateStatus;
} }
void NukiOpenerWrapper::updateBatteryState() void NukiOpenerWrapper::updateBatteryState()

View File

@@ -60,7 +60,7 @@ private:
void onTimeControlCommandReceived(const char* value); void onTimeControlCommandReceived(const char* value);
void onAuthCommandReceived(const char* value); void onAuthCommandReceived(const char* value);
void updateKeyTurnerState(); bool updateKeyTurnerState();
void updateBatteryState(); void updateBatteryState();
void updateConfig(); void updateConfig();
void updateAuthData(bool retrieved); void updateAuthData(bool retrieved);

View File

@@ -291,8 +291,7 @@ void NukiWrapper::update()
if(_nukiOfficial->getStatusUpdated() || _statusUpdated || _nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs || (queryCommands & QUERY_COMMAND_LOCKSTATE) > 0) if(_nukiOfficial->getStatusUpdated() || _statusUpdated || _nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs || (queryCommands & QUERY_COMMAND_LOCKSTATE) > 0)
{ {
Log->println("Updating Lock state based on status, timer or query"); Log->println("Updating Lock state based on status, timer or query");
updateKeyTurnerState(); _statusUpdated = updateKeyTurnerState();
_statusUpdated = false;
_nextLockStateUpdateTs = ts + _intervalLockstate * 1000; _nextLockStateUpdateTs = ts + _intervalLockstate * 1000;
_network->publishStatusUpdated(_statusUpdated); _network->publishStatusUpdated(_statusUpdated);
} }
@@ -427,8 +426,9 @@ void NukiWrapper::unpair()
_paired = false; _paired = false;
} }
void NukiWrapper::updateKeyTurnerState() bool NukiWrapper::updateKeyTurnerState()
{ {
bool updateStatus = false;
Nuki::CmdResult result = (Nuki::CmdResult)-1; Nuki::CmdResult result = (Nuki::CmdResult)-1;
int retryCount = 0; int retryCount = 0;
@@ -460,7 +460,7 @@ void NukiWrapper::updateKeyTurnerState()
Log->println("ms"); Log->println("ms");
_nextLockStateUpdateTs = espMillis() + _retryDelay; _nextLockStateUpdateTs = espMillis() + _retryDelay;
} }
return; return false;
} }
_retryLockstateCount = 0; _retryLockstateCount = 0;
@@ -489,7 +489,7 @@ void NukiWrapper::updateKeyTurnerState()
} }
else if(!_nukiOfficial->getOffConnected() && espMillis() < _statusUpdatedTs + 10000) else if(!_nukiOfficial->getOffConnected() && espMillis() < _statusUpdatedTs + 10000)
{ {
_statusUpdated = true; updateStatus = true;
Log->println(F("Lock: Keep updating status on intermediate lock state")); Log->println(F("Lock: Keep updating status on intermediate lock state"));
} }
@@ -501,6 +501,7 @@ void NukiWrapper::updateKeyTurnerState()
postponeBleWatchdog(); postponeBleWatchdog();
Log->println(F("Done querying lock state")); Log->println(F("Done querying lock state"));
return updateStatus;
} }
void NukiWrapper::updateBatteryState() void NukiWrapper::updateBatteryState()

View File

@@ -65,7 +65,7 @@ private:
void onAuthCommandReceived(const char* value); void onAuthCommandReceived(const char* value);
void onGpioActionReceived(const GpioAction& action, const int& pin); void onGpioActionReceived(const GpioAction& action, const int& pin);
void updateKeyTurnerState(); bool updateKeyTurnerState();
void updateBatteryState(); void updateBatteryState();
void updateConfig(); void updateConfig();
void updateAuthData(bool retrieved); void updateAuthData(bool retrieved);

View File

@@ -4063,10 +4063,10 @@ esp_err_t WebCfgServer::buildInfoHtml(PsychicRequest *request)
if(esp_psram_get_size() > 0) if(esp_psram_get_size() > 0)
{ {
response.print("\nPSRAM Available: Yes"); response.print("\nPSRAM Available: Yes");
response.print("\nTotal PSRAM: ");
response.print(esp_psram_get_size());
response.print("\nFree PSRAM: "); response.print("\nFree PSRAM: ");
response.print((esp_get_free_heap_size() - ESP.getFreeHeap())); response.print((esp_get_free_heap_size() - ESP.getFreeHeap()));
response.print("\nTotal PSRAM: ");
response.print(esp_psram_get_size());
response.print("\nTotal free heap: "); response.print("\nTotal free heap: ");
response.print(esp_get_free_heap_size()); response.print(esp_get_free_heap_size());
} }