Skip to content

Commit

Permalink
Merge pull request #602 from iranl/fix-webserver-disable
Browse files Browse the repository at this point in the history
Fix endless reboot on webserver disable + Fix HA ID
  • Loading branch information
iranl authored Jan 8, 2025
2 parents 84a6648 + a6cc9fa commit 96d561a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define NUKI_HUB_VERSION "9.07"
#define NUKI_HUB_VERSION_INT (uint32_t)907
#define NUKI_HUB_BUILD "unknownbuildnr"
#define NUKI_HUB_DATE "2025-01-07"
#define NUKI_HUB_DATE "2025-01-08"

#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"
Expand Down
2 changes: 1 addition & 1 deletion src/HomeAssistantDiscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ HomeAssistantDiscovery::HomeAssistantDiscovery(NetworkDevice* device, Preference
delay(3000);
}

sprintf(_nukiHubUidString, "%u", curDevId);
sprintf(_nukiHubUidString, "%" PRIu64, curDevId);
}

void HomeAssistantDiscovery::setupHASS(int type, uint32_t nukiId, char* nukiName, const char* firmwareVersion, const char* hardwareVersion, bool hasDoorSensor, bool hasKeypad)
Expand Down
12 changes: 3 additions & 9 deletions src/NukiNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,6 @@ bool NukiNetwork::update()
_device->mqttDisconnect(true);
}

if(!_webEnabled)
{
forceEnableWebServer = true;
}
if(_restartOnDisconnect && espMillis() > 60000)
{
restartEsp(RestartReason::RestartOnDisconnectWatchdog);
Expand Down Expand Up @@ -926,7 +922,7 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
delay(200);
restartEsp(RestartReason::RequestedViaMqtt);
}
else if(comparePrefixedPath(topic, mqtt_topic_update) && strcmp(data, "1") == 0 && _preferences->getBool(preference_update_from_mqtt, false))
else if(comparePrefixedPath(topic, mqtt_topic_update) && strcmp(data, "1") == 0 && _preferences->getBool(preference_update_from_mqtt, false) && !mqttRecentlyConnected())
{
Log->println(("Update requested via MQTT."));

Expand Down Expand Up @@ -1031,7 +1027,7 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
Log->println(("Failed to retrieve OTA manifest, OTA update aborted."));
}
}
else if(comparePrefixedPath(topic, mqtt_topic_webserver_action))
else if(comparePrefixedPath(topic, mqtt_topic_webserver_action) && !mqttRecentlyConnected())
{
if(strcmp(data, "") == 0 ||
strcmp(data, "--") == 0)
Expand All @@ -1046,8 +1042,7 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
return;
}
Log->println(("Webserver enabled, restarting."));
_preferences->putBool(preference_webserver_enabled, true);

_preferences->putBool(preference_webserver_enabled, true);
}
else if (strcmp(data, "0") == 0)
{
Expand All @@ -1058,7 +1053,6 @@ void NukiNetwork::onMqttDataReceived(const char* topic, byte* payload, const uns
Log->println(("Webserver disabled, restarting."));
_preferences->putBool(preference_webserver_enabled, false);
}

clearWifiFallback();
delay(200);
restartEsp(RestartReason::ReconfigureWebServer);
Expand Down

0 comments on commit 96d561a

Please sign in to comment.