Change to GitHub API URL

This commit is contained in:
iranl
2024-02-08 20:50:16 +01:00
parent 4fde6d3ebb
commit 83eeaf7f6d
4 changed files with 21 additions and 14 deletions

View File

@@ -2,7 +2,7 @@
#define NUKI_HUB_VERSION "8.32-pre-3"
#define GITHUB_LATEST_RELEASE_URL "https://github.com/technyon/nuki_hub/releases/latest"
#define GITHUB_RELEASE_TAG_URL "https://github.com/technyon/nuki_hub/releases/tag/"
#define GITHUB_LATEST_RELEASE_API_URL "https://api.github.com/repos/technyon/nuki_hub/releases/latest"
#define MQTT_QOS_LEVEL 1
#define MQTT_CLEAN_SESSIONS false

View File

@@ -11,7 +11,6 @@
Network* Network::_inst = nullptr;
unsigned long Network::_ignoreSubscriptionsTs = 0;
bool _versionPublished = false;
const char* headerKeys[] = {"location"};
RTC_NOINIT_ATTR char WiFi_fallbackDetect[14];
@@ -363,16 +362,20 @@ bool Network::update()
{
_lastUpdateCheckTs = ts;
https.collectHeaders(headerKeys, 1);
https.setFollowRedirects(HTTPC_DISABLE_FOLLOW_REDIRECTS);
https.begin(GITHUB_LATEST_RELEASE_URL);
https.useHTTP10(true);
https.begin(GITHUB_LATEST_RELEASE_API_URL);
int httpResponseCode = https.GET();
if (httpResponseCode==302) {
_latestVersion = https.header("location");
_latestVersion.replace(GITHUB_RELEASE_TAG_URL, "");
publishString(_maintenancePathPrefix, mqtt_topic_info_nuki_hub_latest, _latestVersion.c_str());
if (httpResponseCode == HTTP_CODE_OK || httpResponseCode == HTTP_CODE_MOVED_PERMANENTLY) {
DynamicJsonDocument doc(6144);
DeserializationError jsonError = deserializeJson(doc, https.getStream());
if (!jsonError) {
_latestVersion = doc["tag_name"];
_latestVersionUrl = doc["assets"][0]["browser_download_url"];
publishString(_maintenancePathPrefix, mqtt_topic_info_nuki_hub_latest, _latestVersion);
}
}
https.end();
@@ -663,11 +666,16 @@ int Network::mqttConnectionState()
return _mqttConnectionState;
}
String Network::latestHubVersion()
const char* Network::latestHubVersion()
{
return _latestVersion;
}
const char* Network::latestHubVersionUrl()
{
return _latestVersionUrl;
}
bool Network::encryptionSupported()
{
return _device->supportsEncryption();
@@ -1043,8 +1051,6 @@ void Network::publishHASSConfigAdditionalButtons(char *deviceType, const char *b
{ "pl_prs", "lockNgoUnlatch" }});
}
//json["cmd_t"] = String("~") + String(mqtt_topic_lock_action);
void Network::publishHASSConfigBatLevel(char *deviceType, const char *baseTopic, char *name, char *uidString)
{
String discoveryTopic = _preferences->getString(preference_mqtt_hass_discovery);

View File

@@ -63,7 +63,8 @@ public:
void publishPresenceDetection(char* csv);
int mqttConnectionState(); // 0 = not connected; 1 = connected; 2 = connected and mqtt processed
String latestHubVersion();
const char* _latestVersion;
const char* _latestVersionUrl;
bool encryptionSupported();
const String networkDeviceName() const;

View File

@@ -616,7 +616,7 @@ void WebCfgServer::buildHtml(String& response)
String _latestVersion = _network->latestHubVersion();
//if (_latestVersion.toFloat() > atof(NUKI_HUB_VERSION) || (_latestVersion.toFloat() == atof(NUKI_HUB_VERSION) && _latestVersion.c_str() != NUKI_HUB_VERSION)) {
printParameter(response, "Latest Firmware", _latestVersion.c_str(), GITHUB_LATEST_RELEASE_URL);
printParameter(response, "Latest Firmware", _latestVersion, GITHUB_LATEST_RELEASE_URL);
//}
response.concat("</table><br><br>");