diff --git a/release/aqualinkd-amd64 b/release/aqualinkd-amd64 index a8fa402..1ea34c3 100755 Binary files a/release/aqualinkd-amd64 and b/release/aqualinkd-amd64 differ diff --git a/release/aqualinkd-arm64 b/release/aqualinkd-arm64 index e568f5e..6ddceae 100755 Binary files a/release/aqualinkd-arm64 and b/release/aqualinkd-arm64 differ diff --git a/release/aqualinkd-armhf b/release/aqualinkd-armhf index 36c46e0..2bc05fe 100755 Binary files a/release/aqualinkd-armhf and b/release/aqualinkd-armhf differ diff --git a/source/color_lights.c b/source/color_lights.c index ccaf0fe..c2c6e6a 100644 --- a/source/color_lights.c +++ b/source/color_lights.c @@ -157,6 +157,10 @@ void setColorLightsPanelVersion(uint8_t supported) const char *light_mode_name(clight_type type, int index, emulation_type protocol) { + if (index <= 0 || index > LIGHT_COLOR_OPTIONS ){ + return ""; + } + // Rename any modes depending on emulation type if (protocol == ALLBUTTON) { if (strcmp(_color_light_options[type][index],"Afternoon Skies") == 0) { @@ -192,6 +196,15 @@ bool isShowMode(const char *mode) return false; } +void set_currentlight_value(clight_detail *light, int index) +{ + // We want to leave the last color, so if 0 don't do anything, but set to 0 if bad value + if (index < 0 || index > LIGHT_COLOR_OPTIONS) + light->currentValue = 0; + else if (index > 0 && index < LIGHT_COLOR_OPTIONS) + light->currentValue = index; +} + int build_color_lights_js(struct aqualinkdata *aqdata, char* buffer, int size) { memset(&buffer[0], 0, size); diff --git a/source/color_lights.h b/source/color_lights.h index 4d5f1a7..eee2723 100644 --- a/source/color_lights.h +++ b/source/color_lights.h @@ -27,7 +27,7 @@ typedef enum clight_type { //const char *light_mode_name(clight_type type, int index); const char *light_mode_name(clight_type type, int index, emulation_type protocol); int build_color_lights_js(struct aqualinkdata *aqdata, char* buffer, int size); - +void set_currentlight_value(clight_detail *light, int index); //char *_color_light_options_[LIGHT_COLOR_TYPES][LIGHT_COLOR_OPTIONS][LIGHT_COLOR_NAME]; diff --git a/source/json_messages.c b/source/json_messages.c index 510e253..cdf095e 100644 --- a/source/json_messages.c +++ b/source/json_messages.c @@ -33,6 +33,7 @@ #include "aq_timer.h" #include "aq_programmer.h" #include "rs_msg_utils.h" +#include "color_lights.h" //#define test_message "{\"type\": \"status\",\"version\": \"8157 REV MMM\",\"date\": \"09/01/16 THU\",\"time\": \"1:16 PM\",\"temp_units\": \"F\",\"air_temp\": \"96\",\"pool_temp\": \"86\",\"spa_temp\": \" \",\"battery\": \"ok\",\"pool_htr_set_pnt\": \"85\",\"spa_htr_set_pnt\": \"99\",\"freeze_protection\": \"off\",\"frz_protect_set_pnt\": \"0\",\"leds\": {\"pump\": \"on\",\"spa\": \"off\",\"aux1\": \"off\",\"aux2\": \"off\",\"aux3\": \"off\",\"aux4\": \"off\",\"aux5\": \"off\",\"aux6\": \"off\",\"aux7\": \"off\",\"pool_heater\": \"off\",\"spa_heater\": \"off\",\"solar_heater\": \"off\"}}" //#define test_labels "{\"type\": \"aux_labels\",\"aux1_label\": \"Cleaner\",\"aux2_label\": \"Waterfall\",\"aux3_label\": \"Spa Blower\",\"aux4_label\": \"Pool Light\",\"aux5_label\": \"Spa Light\",\"aux6_label\": \"Unassigned\",\"aux7_label\": \"Unassigned\"}" @@ -706,7 +707,31 @@ printf("Pump Type %d\n",aqdata->pumps[i].pumpType); length--; length += sprintf(buffer+length, "}"); + length += sprintf(buffer+length, ",\"light_program\":{" ); + for (i=0; i < aqdata->num_lights; i++) + { + length += sprintf(buffer+length, "\"%s\": \"%s\",", aqdata->lights[i].button->name, light_mode_name(aqdata->lights[i].lightType, aqdata->lights[i].currentValue, RSSADAPTER) ); + } + if (buffer[length-1] == ',') + length--; + length += sprintf(buffer+length, "}"); +/* + for (i=0; i < aqdata->num_lights; i++) + { + length += sprintf(buffer+length, ",\"Plight_%d\":{\"name\":\"%s\",\"id\":\"%s\", \"type\":\"%d\", \"value\":\"%d\", \"state\":\"%s\"}", + i+1, + aqdata->lights[i].button->label, + aqdata->lights[i].button->name, + aqdata->lights[i].lightType, + aqdata->lights[i].currentValue, + LED2text(aqdata->lights[i].RSSDstate) + ); + } + */ + //if (buffer[length-1] == ',') + // length--; + //length += sprintf(buffer+length, "}"); length += sprintf(buffer+length, "}" ); diff --git a/source/serialadapter.c b/source/serialadapter.c index 25df4aa..ef3242e 100644 --- a/source/serialadapter.c +++ b/source/serialadapter.c @@ -364,17 +364,9 @@ bool process_rssadapter_packet(unsigned char *packet, int length, struct aqualin #endif // Set the color index. (packet[6] - RSSD_COLOR_LIGHT_OFFSET)-1 if (aq_data->lights[i].lightType != LC_DIMMER) { - int color_index = (packet[6] - RSSD_COLOR_LIGHT_OFFSET); - if (color_index <= 0 || color_index > LIGHT_COLOR_OPTIONS) - color_index = 0; - //LOG(RSSA_LOG,LOG_DEBUG,"Color index %d\n",color_index); - aq_data->lights[i].currentValue = color_index; + set_currentlight_value(&aq_data->lights[i], (packet[6] - RSSD_COLOR_LIGHT_OFFSET)); } else if (aq_data->lights[i].lightType == LC_DIMMER) { - int dimmer_index = (packet[6] - RSSD_DIMMER_LIGHT_OFFSET) / 25; - if (dimmer_index < 0 || dimmer_index > 4) - dimmer_index = 0; - //LOG(RSSA_LOG,LOG_DEBUG,"Dimmer index %d\n",dimmer_index); - aq_data->lights[i].currentValue = dimmer_index; + set_currentlight_value(&aq_data->lights[i], (packet[6] - RSSD_DIMMER_LIGHT_OFFSET) / 25); } } } diff --git a/web/controller.html b/web/controller.html index 79215e1..26cdff8 100644 --- a/web/controller.html +++ b/web/controller.html @@ -2166,6 +2166,12 @@ for (var obj in data.timer_durations) { setTileOnText(obj.toString(),"Timer "+toHoursAndMinutes(data.timer_durations[obj])); } + + for (var obj in data.light_program) { + if (data.light_program[obj] != "") { + setTileOnText(obj.toString(),data.light_program[obj]); + } + } if (data.swg_boost_msg != null ) {