Change to GitHub API URL
This commit is contained in:
2
Config.h
2
Config.h
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#define NUKI_HUB_VERSION "8.32-pre-3"
|
#define NUKI_HUB_VERSION "8.32-pre-3"
|
||||||
#define GITHUB_LATEST_RELEASE_URL "https://github.com/technyon/nuki_hub/releases/latest"
|
#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_QOS_LEVEL 1
|
||||||
#define MQTT_CLEAN_SESSIONS false
|
#define MQTT_CLEAN_SESSIONS false
|
||||||
|
|||||||
28
Network.cpp
28
Network.cpp
@@ -11,7 +11,6 @@
|
|||||||
Network* Network::_inst = nullptr;
|
Network* Network::_inst = nullptr;
|
||||||
unsigned long Network::_ignoreSubscriptionsTs = 0;
|
unsigned long Network::_ignoreSubscriptionsTs = 0;
|
||||||
bool _versionPublished = false;
|
bool _versionPublished = false;
|
||||||
const char* headerKeys[] = {"location"};
|
|
||||||
|
|
||||||
RTC_NOINIT_ATTR char WiFi_fallbackDetect[14];
|
RTC_NOINIT_ATTR char WiFi_fallbackDetect[14];
|
||||||
|
|
||||||
@@ -363,16 +362,20 @@ bool Network::update()
|
|||||||
{
|
{
|
||||||
_lastUpdateCheckTs = ts;
|
_lastUpdateCheckTs = ts;
|
||||||
|
|
||||||
https.collectHeaders(headerKeys, 1);
|
https.useHTTP10(true);
|
||||||
https.setFollowRedirects(HTTPC_DISABLE_FOLLOW_REDIRECTS);
|
https.begin(GITHUB_LATEST_RELEASE_API_URL);
|
||||||
https.begin(GITHUB_LATEST_RELEASE_URL);
|
|
||||||
|
|
||||||
int httpResponseCode = https.GET();
|
int httpResponseCode = https.GET();
|
||||||
|
|
||||||
if (httpResponseCode==302) {
|
if (httpResponseCode == HTTP_CODE_OK || httpResponseCode == HTTP_CODE_MOVED_PERMANENTLY) {
|
||||||
_latestVersion = https.header("location");
|
DynamicJsonDocument doc(6144);
|
||||||
_latestVersion.replace(GITHUB_RELEASE_TAG_URL, "");
|
DeserializationError jsonError = deserializeJson(doc, https.getStream());
|
||||||
publishString(_maintenancePathPrefix, mqtt_topic_info_nuki_hub_latest, _latestVersion.c_str());
|
|
||||||
|
if (!jsonError) {
|
||||||
|
_latestVersion = doc["tag_name"];
|
||||||
|
_latestVersionUrl = doc["assets"][0]["browser_download_url"];
|
||||||
|
publishString(_maintenancePathPrefix, mqtt_topic_info_nuki_hub_latest, _latestVersion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
https.end();
|
https.end();
|
||||||
@@ -663,11 +666,16 @@ int Network::mqttConnectionState()
|
|||||||
return _mqttConnectionState;
|
return _mqttConnectionState;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Network::latestHubVersion()
|
const char* Network::latestHubVersion()
|
||||||
{
|
{
|
||||||
return _latestVersion;
|
return _latestVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* Network::latestHubVersionUrl()
|
||||||
|
{
|
||||||
|
return _latestVersionUrl;
|
||||||
|
}
|
||||||
|
|
||||||
bool Network::encryptionSupported()
|
bool Network::encryptionSupported()
|
||||||
{
|
{
|
||||||
return _device->supportsEncryption();
|
return _device->supportsEncryption();
|
||||||
@@ -1043,8 +1051,6 @@ void Network::publishHASSConfigAdditionalButtons(char *deviceType, const char *b
|
|||||||
{ "pl_prs", "lockNgoUnlatch" }});
|
{ "pl_prs", "lockNgoUnlatch" }});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//json["cmd_t"] = String("~") + String(mqtt_topic_lock_action);
|
|
||||||
void Network::publishHASSConfigBatLevel(char *deviceType, const char *baseTopic, char *name, char *uidString)
|
void Network::publishHASSConfigBatLevel(char *deviceType, const char *baseTopic, char *name, char *uidString)
|
||||||
{
|
{
|
||||||
String discoveryTopic = _preferences->getString(preference_mqtt_hass_discovery);
|
String discoveryTopic = _preferences->getString(preference_mqtt_hass_discovery);
|
||||||
|
|||||||
@@ -63,7 +63,8 @@ public:
|
|||||||
void publishPresenceDetection(char* csv);
|
void publishPresenceDetection(char* csv);
|
||||||
|
|
||||||
int mqttConnectionState(); // 0 = not connected; 1 = connected; 2 = connected and mqtt processed
|
int mqttConnectionState(); // 0 = not connected; 1 = connected; 2 = connected and mqtt processed
|
||||||
String latestHubVersion();
|
const char* _latestVersion;
|
||||||
|
const char* _latestVersionUrl;
|
||||||
bool encryptionSupported();
|
bool encryptionSupported();
|
||||||
const String networkDeviceName() const;
|
const String networkDeviceName() const;
|
||||||
|
|
||||||
|
|||||||
@@ -616,7 +616,7 @@ void WebCfgServer::buildHtml(String& response)
|
|||||||
String _latestVersion = _network->latestHubVersion();
|
String _latestVersion = _network->latestHubVersion();
|
||||||
|
|
||||||
//if (_latestVersion.toFloat() > atof(NUKI_HUB_VERSION) || (_latestVersion.toFloat() == atof(NUKI_HUB_VERSION) && _latestVersion.c_str() != NUKI_HUB_VERSION)) {
|
//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>");
|
response.concat("</table><br><br>");
|
||||||
|
|||||||
Reference in New Issue
Block a user