Fix Hosted device ID for HA discovery
This commit is contained in:
@@ -5,8 +5,8 @@
|
|||||||
#define NUKI_HUB_VERSION "9.15"
|
#define NUKI_HUB_VERSION "9.15"
|
||||||
#define NUKI_HUB_VERSION_INT (uint32_t)915
|
#define NUKI_HUB_VERSION_INT (uint32_t)915
|
||||||
#define NUKI_HUB_BUILD "unknownbuildnr"
|
#define NUKI_HUB_BUILD "unknownbuildnr"
|
||||||
#define NUKI_HUB_DATE "2025-11-24"
|
#define NUKI_HUB_DATE "2026-01-09"
|
||||||
#define NUKI_HUB_DATE "2025-11-24"
|
#define NUKI_HUB_DATE "2026-01-09"
|
||||||
|
|
||||||
#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"
|
||||||
|
|||||||
@@ -3,7 +3,11 @@
|
|||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "PreferencesKeys.h"
|
#include "PreferencesKeys.h"
|
||||||
#include "MqttTopics.h"
|
#include "MqttTopics.h"
|
||||||
|
#if defined(CONFIG_ESP_HOSTED_ENABLE_BT_NIMBLE) || defined(CONFIG_ESP_WIFI_REMOTE_ENABLED)
|
||||||
|
#include "WiFi.h"
|
||||||
|
#else
|
||||||
#include "esp_mac.h"
|
#include "esp_mac.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
HomeAssistantDiscovery::HomeAssistantDiscovery(NetworkDevice* device, Preferences *preferences, char* buffer, size_t bufferSize)
|
HomeAssistantDiscovery::HomeAssistantDiscovery(NetworkDevice* device, Preferences *preferences, char* buffer, size_t bufferSize)
|
||||||
: _device(device),
|
: _device(device),
|
||||||
@@ -13,11 +17,34 @@ HomeAssistantDiscovery::HomeAssistantDiscovery(NetworkDevice* device, Preference
|
|||||||
{
|
{
|
||||||
_baseTopic = _preferences->getString(preference_mqtt_lock_path);
|
_baseTopic = _preferences->getString(preference_mqtt_lock_path);
|
||||||
_hostname = _preferences->getString(preference_hostname, "");
|
_hostname = _preferences->getString(preference_hostname, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void HomeAssistantDiscovery::setupHASS(int type, uint32_t nukiId, char* nukiName, const char* firmwareVersion, const char* hardwareVersion, bool hasDoorSensor, bool hasKeypad)
|
||||||
|
{
|
||||||
uint64_t savedDevId = _preferences->getULong64(preference_nukihub_id, 0);
|
uint64_t savedDevId = _preferences->getULong64(preference_nukihub_id, 0);
|
||||||
|
uint64_t curDevId;
|
||||||
|
|
||||||
|
#if defined(CONFIG_ESP_HOSTED_ENABLE_BT_NIMBLE) || defined(CONFIG_ESP_WIFI_REMOTE_ENABLED)
|
||||||
|
curDevId = 0;
|
||||||
|
std::string macString = std::string(WiFi.macAddress().c_str());
|
||||||
|
std::string::iterator i;
|
||||||
|
std::string::iterator end = macString.end();
|
||||||
|
|
||||||
|
for(i = macString.begin(); i != end; ++i) {
|
||||||
|
char let = *i;
|
||||||
|
if (let >= '0' && let <= '9') {
|
||||||
|
curDevId = curDevId*0xf + (let-'0');
|
||||||
|
} else if (let >= 'a' && let <= 'f') {
|
||||||
|
curDevId = curDevId*0xf + (let-'a'+10);
|
||||||
|
} else if (let >= 'A' && let <= 'F') {
|
||||||
|
curDevId = curDevId*0xf + (let-'A'+10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
uint8_t mac[8];
|
uint8_t mac[8];
|
||||||
esp_efuse_mac_get_default(mac);
|
esp_efuse_mac_get_default(mac);
|
||||||
uint64_t curDevId;
|
|
||||||
memcpy(&curDevId, &mac, 8);
|
memcpy(&curDevId, &mac, 8);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (savedDevId == 0)
|
if (savedDevId == 0)
|
||||||
{
|
{
|
||||||
@@ -57,10 +84,7 @@ HomeAssistantDiscovery::HomeAssistantDiscovery(NetworkDevice* device, Preference
|
|||||||
}
|
}
|
||||||
|
|
||||||
sprintf(_nukiHubUidString, "%" PRIu64, 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)
|
|
||||||
{
|
|
||||||
char uidString[20];
|
char uidString[20];
|
||||||
itoa(nukiId, uidString, 16);
|
itoa(nukiId, uidString, 16);
|
||||||
bool publishAuthData = _preferences->getBool(preference_publish_authdata, false);
|
bool publishAuthData = _preferences->getBool(preference_publish_authdata, false);
|
||||||
|
|||||||
Reference in New Issue
Block a user