diff --git a/src/httpserver/http_fns.c b/src/httpserver/http_fns.c
index 5f11e5be0..93f247947 100644
--- a/src/httpserver/http_fns.c
+++ b/src/httpserver/http_fns.c
@@ -1256,41 +1256,6 @@ void get_Relay_PWM_Count(int *relayCount, int *pwmCount){
}
}
-/// @brief Sends HomeAssistant discovery MQTT messages.
-/// @param request
-/// @return
-int http_fn_ha_discovery(http_request_t *request) {
- int i;
- char topic[32];
- int relayCount=0;
- int pwmCount=0;
-
- http_setup(request, httpMimeTypeText);
- get_Relay_PWM_Count(&relayCount, &pwmCount);
-
- if ((relayCount == 0) && (pwmCount == 0)) {
- poststr(request, NULL);
- return 0;
-}
-
-/// @brief Computes the Relay and PWM count.
-/// @param relayCount
-/// @param pwmCount
-void get_Relay_PWM_Count(int *relayCount, int *pwmCount){
- (*relayCount) = 0;
- (*pwmCount) = 0;
-
- for(int i = 0; i < PLATFORM_GPIO_MAX; i++) {
- int role = PIN_GetPinRoleForPinIndex(i);
- if(role == IOR_Relay || role == IOR_Relay_n || role == IOR_LED || role == IOR_LED_n) {
- (*relayCount)++;
- }
- else if(role == IOR_PWM || role == IOR_PWM_n) {
- (*pwmCount)++;
- }
- }
-}
-
/// @brief Sends HomeAssistant discovery MQTT messages.
/// @param request
/// @return
@@ -1327,7 +1292,7 @@ int http_fn_ha_discovery(http_request_t *request) {
if(pwmCount > 0) {
char tmp[64];
- const char *baseName = CFG_GetShortDeviceName();
+ const char *shortDeviceName = CFG_GetShortDeviceName();
for(i = 0; i < CHANNEL_MAX; i++) {
if(h_isChannelPWM(i)) {
@@ -1336,7 +1301,7 @@ int http_fn_ha_discovery(http_request_t *request) {
cJSON_AddStringToObject(dev_info->root, "on_cmd_type", "brightness"); //on_command_type
cJSON_AddNumberToObject(dev_info->root, "bri_scl", 99); //brightness_scale
- sprintf(tmp,"%s/%i/set",baseName,i);
+ sprintf(tmp,"%s/%i/set",shortDeviceName,i);
cJSON_AddStringToObject(dev_info->root, "bri_cmd_t", tmp); //brightness_command_topic
MQTT_QueuePublish(topic, dev_info->channel, hass_build_discovery_json(dev_info), OBK_PUBLISH_FLAG_RETAIN);
@@ -1352,6 +1317,8 @@ int http_fn_ha_discovery(http_request_t *request) {
int http_fn_ha_cfg(http_request_t *request) {
int relayCount = 0;
int pwmCount = 0;
+ const char *shortDeviceName;
+ const char *clientId;
int i;
char mqttAdded = 0;
char *uniq_id;
@@ -1437,15 +1404,10 @@ int http_fn_ha_cfg(http_request_t *request) {
}
poststr(request,"");
-
- poststr(request, HomeAssistantDiscoveryScript);
poststr(request,"