Various changes after testing new HA features

This commit is contained in:
Gunnar Skjold
2023-04-01 07:31:40 +02:00
parent f214af3595
commit 71e0f13f0e
9 changed files with 56 additions and 38 deletions

View File

@@ -35,16 +35,20 @@ public:
deviceUid = hostname; // Maybe configurable in the future?
if(strlen(config.discoveryHostname) > 0) {
snprintf_P(buf, 128, PSTR("http://%s.local/"), config.discoveryHostname);
String deviceUrl = String(buf);
if(strncmp_P(config.discoveryHostname, PSTR("http"), 4) == 0) {
deviceUrl = String(config.discoveryHostname);
} else {
snprintf_P(buf, 128, PSTR("http://%s/"), config.discoveryHostname);
deviceUrl = String(buf);
}
} else {
snprintf_P(buf, 128, PSTR("http://%s.local/"), hostname);
String deviceUrl = String(buf);
deviceUrl = String(buf);
}
if(strlen(config.discoveryTopic) > 0) {
discoveryTopic = String(config.discoveryTopic);
if(!discoveryTopic.endsWith("/")) discoveryTopic += "/";
if(strlen(config.discoveryPrefix) > 0) {
snprintf_P(buf, 128, PSTR("%s/sensor/"), config.discoveryPrefix);
discoveryTopic = String(buf);
} else {
discoveryTopic = "homeassistant/sensor/";
}