diff --git a/aqualinkd.c b/aqualinkd.c index e35ac824..315bbb3f 100644 --- a/aqualinkd.c +++ b/aqualinkd.c @@ -1230,6 +1230,7 @@ int main(int argc, char *argv[]) LOG(AQUA_LOG,LOG_NOTICE, "Config idx spa thermostat = %d\n", _aqconfig_.dzidx_spa_thermostat); */ LOG(AQUA_LOG,LOG_NOTICE, "Config habridge_server = %s\n", _aqconfig_.habridge_server); + LOG(AQUA_LOG,LOG_NOTICE, "Config habridge_user = %s\n", _aqconfig_.habridge_user); LOG(AQUA_LOG,LOG_NOTICE, "Config deamonize = %s\n", bool2text(_aqconfig_.deamonize)); LOG(AQUA_LOG,LOG_NOTICE, "Config log_file = %s\n", _aqconfig_.log_file); LOG(AQUA_LOG,LOG_NOTICE, "Config enable scheduler = %s\n", bool2text(_aqconfig_.enable_scheduler)); diff --git a/config.c b/config.c index 78817e61..8d5a8ca0 100644 --- a/config.c +++ b/config.c @@ -94,6 +94,7 @@ void init_parameters (struct aqconfig * parms) parms->mqtt_user = DEFAULT_MQTT_USER; parms->mqtt_passwd = DEFAULT_MQTT_PASSWD; parms->habridge_server = NULL; + parms->habridge_user = NULL; parms->dzidx_air_temp = TEMP_UNKNOWN; parms->dzidx_pool_water_temp = TEMP_UNKNOWN; parms->dzidx_spa_water_temp = TEMP_UNKNOWN; @@ -440,6 +441,9 @@ bool setConfigValue(struct aqualinkdata *aqdata, char *param, char *value) { } else if (strncasecmp(param, "habridge_server", 15) == 0) { _aqconfig_.habridge_server = cleanalloc(value); rtn=true; + } else if (strncasecmp(param, "habridge_user", 13) == 0) { + _aqconfig_.habridge_user = cleanalloc(value); + rtn=true; } else if (strncasecmp(param, "air_temp_dzidx", 14) == 0) { _aqconfig_.dzidx_air_temp = strtoul(value, NULL, 10); rtn=true; @@ -865,6 +869,7 @@ bool writeCfg (struct aqualinkdata *aqdata) fprintf(fp, "\n#** HA Bridge Configuration **\n"); writeCharValue(fp, "habridge_server", config_parameters->habridge_server); + writeCharValue(fp, "habridge_user", config_parameters->habridge_user); fprintf(fp, "\n#** General **\n"); fprintf(fp, "convert_mqtt_temp_to_c = %s\n", bool2text(_aqconfig_.convert_mqtt_temp)); diff --git a/config.h b/config.h index a6ad714a..306d6495 100644 --- a/config.h +++ b/config.h @@ -51,6 +51,7 @@ struct aqconfig char *mqtt_user; char *mqtt_passwd; char *habridge_server; + char *habridge_user; char mqtt_ID[MQTT_ID_LEN]; int dzidx_air_temp; int dzidx_pool_water_temp; diff --git a/net_services_habridge.c b/net_services_habridge.c index 317e20db..f68ac9fe 100644 --- a/net_services_habridge.c +++ b/net_services_habridge.c @@ -30,8 +30,6 @@ struct habridge_updater_data //static const char *s_url = // "http://127.0.0.1:8080/api/username/lights/1/bridgeupdatestate"; -//static struct aqualinkdata _last_habridge_aqualinkdata; - void* habridge_updater_routine(void* data) { int ret = 0; @@ -64,8 +62,9 @@ void* habridge_updater_routine(void* data) on_value = "true"; } snprintf(cmd_buff, sizeof(cmd_buff), - "curl -sS -X PUT -d '{\"on\": %s}' http://%s/api/username/lights/%d/bridgeupdatestate > /dev/null", - on_value, aqconfig->habridge_server, aqdata->aqbuttons[i].hab_id); + "curl -sS -X PUT -d '{\"on\": %s}' 'http://%s/api/%s/lights/%d/bridgeupdatestate' > /dev/null", + on_value, aqconfig->habridge_server, + aqconfig->habridge_user, aqdata->aqbuttons[i].hab_id); LOG(NET_LOG, LOG_DEBUG, "habridge_updater_routine %s\n", cmd_buff); if ((ret = system(cmd_buff))) {