mirror of https://github.com/sfeakes/AqualinkD.git
release update
parent
210d199e88
commit
ccf700f0a9
|
@ -61,7 +61,8 @@ Designed to mimic AqualinkRS6 All Button keypad, and just like the keypad you ca
|
|||
* http://aqualink.ip/old <- (If you prefer the old UI, this is not maintained)
|
||||
* http://aqualink.ip/simple.html <- (Anothr opion if you don't like the above)
|
||||
* http://aqualink.ip/simulator.html <- (RS8 All Button Control Panel simulator)
|
||||
## Update in Release 1.2.1
|
||||
## Update in Release 1.2.2
|
||||
* Support for Spa OR Pool OLNY mode with setpoints, (previous setpoints expected Spa & Pool mode)
|
||||
* Added support for MQTT Last Will Message
|
||||
* Fix spelling errors will effect your conficuration, and the install.sh script will not overwrite.
|
||||
* Please compare /var/www/aqualinkd/config.js to the new one, you will need to manualy edit or overide
|
||||
|
|
|
@ -114,19 +114,31 @@ int setpoint_check(int type, int value, struct aqualinkdata *aqdata)
|
|||
int rtn = value;
|
||||
int max = 0;
|
||||
int min = 0;
|
||||
char *type_msg;
|
||||
|
||||
switch(type) {
|
||||
case POOL_HTR_SETOINT:
|
||||
case SPA_HTR_SETOINT:
|
||||
if ( aqdata->temp_units == CELSIUS ) {
|
||||
type_msg = (aqdata->single_device?"Temp1":"Pool");
|
||||
if ( aqdata->temp_units == CELSIUS ) {
|
||||
max = HEATER_MAX_C;
|
||||
min = HEATER_MIN_C;
|
||||
min = (aqdata->single_device?HEATER_MIN_C:HEATER_MIN_C-1);
|
||||
} else {
|
||||
max = HEATER_MAX_F;
|
||||
min = (aqdata->single_device?HEATER_MIN_F:HEATER_MIN_F-1);
|
||||
}
|
||||
break;
|
||||
case SPA_HTR_SETOINT:
|
||||
type_msg = (aqdata->single_device?"Temp2":"Spa");
|
||||
if ( aqdata->temp_units == CELSIUS ) {
|
||||
max = (aqdata->single_device?HEATER_MAX_C:HEATER_MAX_C-1);
|
||||
min = HEATER_MIN_C;
|
||||
} else {
|
||||
max = (aqdata->single_device?HEATER_MAX_F:HEATER_MAX_F-1);
|
||||
min = HEATER_MIN_F;
|
||||
}
|
||||
break;
|
||||
case FREEZE_SETPOINT:
|
||||
type_msg = "Freeze protect";
|
||||
if ( aqdata->temp_units == CELSIUS ) {
|
||||
max = FREEZE_PT_MAX_C;
|
||||
min = FREEZE_PT_MIN_C;
|
||||
|
@ -136,9 +148,13 @@ int setpoint_check(int type, int value, struct aqualinkdata *aqdata)
|
|||
}
|
||||
break;
|
||||
case SWG_SETPOINT:
|
||||
type_msg = "Salt Water Generator";
|
||||
max = SWG_PERCENT_MAX;
|
||||
min = SWG_PERCENT_MIN;
|
||||
break;
|
||||
default:
|
||||
type_msg = "Unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
if (rtn > max)
|
||||
|
@ -151,6 +167,11 @@ int setpoint_check(int type, int value, struct aqualinkdata *aqdata)
|
|||
if (0 != ( rtn % 5) )
|
||||
rtn = ((rtn + 5) / 10) * 10;
|
||||
}
|
||||
|
||||
if (rtn != value)
|
||||
logMessage(LOG_WARNING, "Setpoint of %d for %s is outside range, using %d\n",value,type_msg,rtn);
|
||||
else
|
||||
logMessage(LOG_NOTICE, "Setting setpoint of %s to %d\n",type_msg,rtn);
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
|
|
@ -131,6 +131,8 @@
|
|||
#define LNG_MSG_WATER_TEMP1_SET "TEMP1 (HIGH TEMP) IS SET TO"
|
||||
#define LNG_MSG_WATER_TEMP2_SET "TEMP2 (LOW TEMP) IS SET TO"
|
||||
|
||||
#define LNG_MSG_FREEZE_PROTECTION_ACTIVATED "FREEZE PROTECTION ACTIVATED"
|
||||
|
||||
#define MSG_SWG_PCT "AQUAPURE" // AquaPure 55%
|
||||
#define MSG_SWG_PPM "SALT" // Salt 3000 PPM
|
||||
#define MSG_SWG_PCT_LEN 8
|
||||
|
|
|
@ -94,6 +94,7 @@ struct aqualinkdata
|
|||
unsigned char ar_swg_status;
|
||||
int swg_delayed_percent;
|
||||
bool simulate_panel;
|
||||
aqledstate frz_protect_state;
|
||||
//bool last_msg_was_status;
|
||||
//bool ar_swg_connected;
|
||||
};
|
||||
|
|
36
aqualinkd.c
36
aqualinkd.c
|
@ -185,7 +185,7 @@ void setUnits(char *msg)
|
|||
else
|
||||
_aqualink_data.temp_units = UNKNOWN;
|
||||
|
||||
logMessage(LOG_INFO, "Temp Units set to %d (F=0, C=1, Unknown=3)", _aqualink_data.temp_units);
|
||||
logMessage(LOG_INFO, "Temp Units set to %d (F=0, C=1, Unknown=3)", _aqualink_data.temp_units);
|
||||
}
|
||||
|
||||
|
||||
|
@ -236,6 +236,7 @@ void processMessage(char *message)
|
|||
else if(stristr(msg, LNG_MSG_FREEZE_PROTECTION_SET) != NULL) {
|
||||
//logMessage(LOG_DEBUG, "frz protect long message: %s", &message[28]);
|
||||
_aqualink_data.frz_protect_set_point = atoi(message+28);
|
||||
_aqualink_data.frz_protect_state = ENABLE;
|
||||
|
||||
if (_aqualink_data.temp_units == UNKNOWN)
|
||||
setUnits(msg);
|
||||
|
@ -266,18 +267,38 @@ void processMessage(char *message)
|
|||
_aqualink_data.spa_temp = atoi(msg+MSG_WATER_TEMP_LEN);
|
||||
if (_aqualink_data.temp_units == UNKNOWN)
|
||||
setUnits(msg);
|
||||
|
||||
if (_aqualink_data.single_device != true) {
|
||||
_aqualink_data.single_device = true;
|
||||
logMessage(LOG_NOTICE, "AqualinkD set to 'Pool OR Spa Only' mode\n");
|
||||
}
|
||||
}
|
||||
else if(stristr(msg, LNG_MSG_WATER_TEMP1_SET) != NULL) {
|
||||
_aqualink_data.pool_htr_set_point = atoi(message+28);
|
||||
|
||||
if (_aqualink_data.temp_units == UNKNOWN)
|
||||
setUnits(msg);
|
||||
|
||||
if (_aqualink_data.single_device != true) {
|
||||
_aqualink_data.single_device = true;
|
||||
logMessage(LOG_NOTICE, "AqualinkD set to 'Pool OR Spa Only' mode\n");
|
||||
}
|
||||
}
|
||||
else if(stristr(msg, LNG_MSG_WATER_TEMP2_SET) != NULL) {
|
||||
_aqualink_data.spa_htr_set_point = atoi(message+27);
|
||||
|
||||
if (_aqualink_data.temp_units == UNKNOWN)
|
||||
setUnits(msg);
|
||||
|
||||
if (_aqualink_data.single_device != true) {
|
||||
_aqualink_data.single_device = true;
|
||||
logMessage(LOG_NOTICE, "AqualinkD set to 'Pool OR Spa Only' mode\n");
|
||||
}
|
||||
}
|
||||
else if (stristr(msg, LNG_MSG_FREEZE_PROTECTION_ACTIVATED) != NULL) {
|
||||
// ADD Code Set FREEZE protection on (from enabeled).
|
||||
// Need to figure out a way to turn know when it's off though before uncommeting.
|
||||
//_aqualink_data.frz_protect_state = ON;
|
||||
}
|
||||
else if(msg[2] == '/' && msg[5] == '/' && msg[8] == ' ') {// date in format '08/29/16 MON'
|
||||
strcpy(_aqualink_data.date, msg);
|
||||
|
@ -581,12 +602,12 @@ bool process_packet(unsigned char* packet, int length)
|
|||
_aqualink_data.spa_temp = TEMP_UNKNOWN;
|
||||
//_aqualink_data.spa_temp = _config_parameters.report_zero_spa_temp?-18:TEMP_UNKNOWN;
|
||||
}
|
||||
else if (_aqualink_data.aqbuttons[SPA_INDEX].led->state == OFF)
|
||||
else if (_aqualink_data.aqbuttons[SPA_INDEX].led->state == OFF && _aqualink_data.single_device != true)
|
||||
{
|
||||
//_aqualink_data.spa_temp = _config_parameters.report_zero_spa_temp?-18:TEMP_UNKNOWN;
|
||||
_aqualink_data.spa_temp = TEMP_UNKNOWN;
|
||||
}
|
||||
else if (_aqualink_data.aqbuttons[SPA_INDEX].led->state == ON)
|
||||
else if (_aqualink_data.aqbuttons[SPA_INDEX].led->state == ON && _aqualink_data.single_device != true)
|
||||
{
|
||||
_aqualink_data.pool_temp = TEMP_UNKNOWN;
|
||||
}
|
||||
|
@ -634,6 +655,7 @@ void action_delayed_request()
|
|||
snprintf(sval, 9, "%d", _aqualink_data.unactioned.value);
|
||||
|
||||
if (_aqualink_data.unactioned.type == POOL_HTR_SETOINT) {
|
||||
_aqualink_data.unactioned.value = setpoint_check(POOL_HTR_SETOINT, _aqualink_data.unactioned.value, &_aqualink_data);
|
||||
if ( _aqualink_data.pool_htr_set_point != _aqualink_data.unactioned.value ) {
|
||||
aq_programmer(AQ_SET_POOL_HEATER_TEMP, sval, &_aqualink_data);
|
||||
logMessage(LOG_NOTICE, "Setting pool heater setpoint to %d\n",_aqualink_data.unactioned.value);
|
||||
|
@ -641,6 +663,7 @@ void action_delayed_request()
|
|||
logMessage(LOG_NOTICE, "Pool heater setpoint is already %d, not changing\n",_aqualink_data.unactioned.value);
|
||||
}
|
||||
} else if (_aqualink_data.unactioned.type == SPA_HTR_SETOINT) {
|
||||
_aqualink_data.unactioned.value = setpoint_check(SPA_HTR_SETOINT, _aqualink_data.unactioned.value, &_aqualink_data);
|
||||
if ( _aqualink_data.spa_htr_set_point != _aqualink_data.unactioned.value ) {
|
||||
aq_programmer(AQ_SET_SPA_HEATER_TEMP, sval, &_aqualink_data);
|
||||
logMessage(LOG_NOTICE, "Setting spa heater setpoint to %d\n",_aqualink_data.unactioned.value);
|
||||
|
@ -648,6 +671,7 @@ void action_delayed_request()
|
|||
logMessage(LOG_NOTICE, "Spa heater setpoint is already %d, not changing\n",_aqualink_data.unactioned.value);
|
||||
}
|
||||
} else if (_aqualink_data.unactioned.type == FREEZE_SETPOINT) {
|
||||
_aqualink_data.unactioned.value = setpoint_check(FREEZE_SETPOINT, _aqualink_data.unactioned.value, &_aqualink_data);
|
||||
if ( _aqualink_data.frz_protect_set_point != _aqualink_data.unactioned.value ) {
|
||||
aq_programmer(AQ_SET_FRZ_PROTECTION_TEMP, sval, &_aqualink_data);
|
||||
logMessage(LOG_NOTICE, "Setting freeze protect to %d\n",_aqualink_data.unactioned.value);
|
||||
|
@ -655,13 +679,14 @@ void action_delayed_request()
|
|||
logMessage(LOG_NOTICE, "Freeze setpoint is already %d, not changing\n",_aqualink_data.unactioned.value);
|
||||
}
|
||||
} else if (_aqualink_data.unactioned.type == SWG_SETPOINT) {
|
||||
_aqualink_data.unactioned.value = setpoint_check(SWG_SETPOINT, _aqualink_data.unactioned.value, &_aqualink_data);
|
||||
if (_aqualink_data.ar_swg_status == SWG_STATUS_OFF ) {
|
||||
// SWG is off, can't set %, so delay the set until it's on.
|
||||
_aqualink_data.swg_delayed_percent = _aqualink_data.unactioned.value;
|
||||
} else {
|
||||
if ( _aqualink_data.swg_percent != _aqualink_data.unactioned.value ) {
|
||||
aq_programmer(AQ_SET_SWG_PERCENT, sval, &_aqualink_data);
|
||||
logMessage(LOG_NOTICE, "Setting SWG % to %d\n",_aqualink_data.unactioned.value);
|
||||
logMessage(LOG_NOTICE, "Setting SWG %% to %d\n",_aqualink_data.unactioned.value);
|
||||
} else {
|
||||
logMessage(LOG_NOTICE, "SWG % is already %d, not changing\n",_aqualink_data.unactioned.value);
|
||||
}
|
||||
|
@ -827,6 +852,7 @@ void main_loop() {
|
|||
_aqualink_data.swg_delayed_percent = TEMP_UNKNOWN;
|
||||
_aqualink_data.temp_units = UNKNOWN;
|
||||
_aqualink_data.single_device = false;
|
||||
_aqualink_data.frz_protect_state = OFF;
|
||||
|
||||
|
||||
if (!start_net_services(&mgr, &_aqualink_data, &_config_parameters)) {
|
||||
|
@ -936,7 +962,7 @@ void main_loop() {
|
|||
char sval[10];
|
||||
snprintf(sval, 9, "%d", _aqualink_data.swg_delayed_percent);
|
||||
aq_programmer(AQ_SET_SWG_PERCENT, sval, &_aqualink_data);
|
||||
logMessage(LOG_NOTICE, "Setting SWG % to %d, from delayed message\n",_aqualink_data.swg_delayed_percent);
|
||||
logMessage(LOG_NOTICE, "Setting SWG %% to %d, from delayed message\n",_aqualink_data.swg_delayed_percent);
|
||||
_aqualink_data.swg_delayed_percent = TEMP_UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -813,11 +813,12 @@ void action_mqtt_message(struct mg_connection *nc, struct mg_mqtt_message *msg)
|
|||
if (strncmp(pt1, BTN_POOL_HTR, strlen(BTN_POOL_HTR)) == 0) {
|
||||
_aqualink_data->unactioned.value = setpoint_check(POOL_HTR_SETOINT, val, _aqualink_data);
|
||||
_aqualink_data->unactioned.type = POOL_HTR_SETOINT;
|
||||
/*
|
||||
if (val != _aqualink_data->unactioned.value) {
|
||||
logMessage(LOG_ERR, "MQTT: request to set Pool Heater to %.2fc/%df, is outside range, using to %d\n", value, val, _aqualink_data->unactioned.value);
|
||||
} else {
|
||||
logMessage(LOG_INFO, "MQTT: request to set Pool Heater to %.2fc, setting to %d\n", value, val);
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
if (val <= HEATER_MAX && val >= MEATER_MIN) {
|
||||
logMessage(LOG_INFO, "MQTT: request to set pool heater setpoint to %.2fc\n", value);
|
||||
|
@ -829,11 +830,12 @@ void action_mqtt_message(struct mg_connection *nc, struct mg_mqtt_message *msg)
|
|||
} else if (strncmp(pt1, BTN_SPA_HTR, strlen(BTN_SPA_HTR)) == 0) {
|
||||
_aqualink_data->unactioned.value = setpoint_check(SPA_HTR_SETOINT, val, _aqualink_data);
|
||||
_aqualink_data->unactioned.type = SPA_HTR_SETOINT;
|
||||
/*
|
||||
if (val != _aqualink_data->unactioned.value) {
|
||||
logMessage(LOG_ERR, "MQTT: request to set Spa Heater to %.2fc/%df, is outside range, using to %d\n", value, val, _aqualink_data->unactioned.value);
|
||||
} else {
|
||||
logMessage(LOG_INFO, "MQTT: request to set Spa Heater to %.2fc, setting to %d\n", value, val);
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
if (val <= HEATER_MAX && val >= MEATER_MIN) {
|
||||
logMessage(LOG_INFO, "MQTT: request to set spa heater setpoint to %.2fc\n", value);
|
||||
|
@ -845,11 +847,12 @@ void action_mqtt_message(struct mg_connection *nc, struct mg_mqtt_message *msg)
|
|||
} else if (strncmp(pt1, FREEZE_PROTECT, strlen(FREEZE_PROTECT)) == 0) {
|
||||
_aqualink_data->unactioned.value = setpoint_check(FREEZE_SETPOINT, val, _aqualink_data);
|
||||
_aqualink_data->unactioned.type = FREEZE_SETPOINT;
|
||||
/*
|
||||
if (val != _aqualink_data->unactioned.value) {
|
||||
logMessage(LOG_ERR, "MQTT: request to set freeze protect to %.2fc/%df is outside range, using %d\n", value, val, _aqualink_data->unactioned.value);
|
||||
} else {
|
||||
logMessage(LOG_INFO, "MQTT: request to set spa heater setpoint to %.2fc\n", value);
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
if (val <= FREEZE_PT_MAX && val >= FREEZE_PT_MIN) {
|
||||
logMessage(LOG_INFO, "MQTT: request to set freeze protect to %.2fc\n", value);
|
||||
|
@ -867,11 +870,12 @@ void action_mqtt_message(struct mg_connection *nc, struct mg_mqtt_message *msg)
|
|||
int val = round(degCtoF(value));
|
||||
_aqualink_data->unactioned.value = setpoint_check(SWG_SETPOINT, val, _aqualink_data);
|
||||
_aqualink_data->unactioned.type = SWG_SETPOINT;
|
||||
/*
|
||||
if (val != _aqualink_data->unactioned.value) {
|
||||
logMessage(LOG_ERR, "MQTT: request to set SWG to %.2fc/%df, is outside range, using to %d\n", value, val, _aqualink_data->unactioned.value);
|
||||
} else {
|
||||
logMessage(LOG_INFO, "MQTT: request to set SWG to %.2fc, setting to %d\n", value, val);
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
int val = round(degCtoF(value));
|
||||
if (0 != ( val % 5) )
|
||||
|
@ -902,11 +906,12 @@ void action_mqtt_message(struct mg_connection *nc, struct mg_mqtt_message *msg)
|
|||
}
|
||||
_aqualink_data->unactioned.value = setpoint_check(SWG_SETPOINT, val, _aqualink_data);
|
||||
_aqualink_data->unactioned.type = SWG_SETPOINT;
|
||||
/*
|
||||
if (val != _aqualink_data->unactioned.value) {
|
||||
logMessage(LOG_ERR, "MQTT: request to set SWG to %.2fc/%df, is outside range, using to %d\n", value, val, _aqualink_data->unactioned.value);
|
||||
} else {
|
||||
logMessage(LOG_INFO, "MQTT: request to set SWG to %.2fc, setting to %d\n", value, val);
|
||||
}
|
||||
}*/
|
||||
/*
|
||||
// Convert number to nearest 5, since those are the incruments, NSF check 100 or 101
|
||||
if (0 != (val % 5) )
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue