pull/42/head
shaun feakes 2018-09-16 11:41:33 -05:00
parent 227cd34ce3
commit fcb78ffa67
5 changed files with 18 additions and 87 deletions

View File

@ -110,7 +110,7 @@ Below are varified versions (But should work with any AqualinkRS) :-
| Version | Notes |
| --- | --- |
| Jandy Aqualink 6524 REV GG | Everything working except water temp |
| Jandy Aqualink 6524 REV GG | Everything working |
| Jandy AquaLinkRS 8157 REV JJ | Everything working |
| Jandy AquaLinkRS 8157 REV MMM | Everything working |
| Jandy AquaLinkRS B0029221 REV T | Everything working |

View File

View File

@ -194,6 +194,7 @@ void processMessage(char *message)
char *msg;
static bool _initWithRS = false;
static bool _gotREV = false;
static int freeze_msg_count = 0;
// NSF replace message with msg
msg = stripwhitespace(message);
strcpy(_aqualink_data.last_message, msg);
@ -213,6 +214,13 @@ void processMessage(char *message)
//_aqualink_data.display_message = NULL;
_aqualink_data.last_display_message[0] = '\0';
}
// If we have more than 10 messages without "FREE PROTECT ACTIVATED" assume it's off.
if (_aqualink_data.frz_protect_state == ON && freeze_msg_count++ > 10) {
_aqualink_data.frz_protect_state = ENABLE;
freeze_msg_count = 0;
}
//else
//_aqualink_data.display_last_message = false;
@ -296,7 +304,8 @@ void processMessage(char *message)
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;
_aqualink_data.frz_protect_state = ON;
freeze_msg_count = 0;
}
else if(msg[2] == '/' && msg[5] == '/' && msg[8] == ' ') {// date in format '08/29/16 MON'
strcpy(_aqualink_data.date, msg);
@ -703,6 +712,7 @@ int main(int argc, char *argv[]) {
int i;
char *cfgFile = DEFAULT_CONFIG_FILE;
int cmdln_loglevel = -1;
// struct lws_context_creation_info info;
@ -724,6 +734,8 @@ int main(int argc, char *argv[]) {
_config_parameters.deamonize = false;
} else if (strcmp(argv[i], "-c") == 0) {
cfgFile = argv[++i];
} else if (strcmp(argv[i], "-v") == 0) {
cmdln_loglevel = LOG_DEBUG;
}
}
@ -731,6 +743,9 @@ int main(int argc, char *argv[]) {
readCfg(&_config_parameters, &_aqualink_data, cfgFile);
if (cmdln_loglevel != -1)
_config_parameters.log_level = cmdln_loglevel;
setLoggingPrms(_config_parameters.log_level, _config_parameters.deamonize, _config_parameters.log_file);
logMessage(LOG_NOTICE, "%s v%s\n", AQUALINKD_NAME, AQUALINKD_VERSION);

View File

@ -337,7 +337,7 @@ void mqtt_broadcast_aqualinkstate(struct mg_connection *nc)
if (_aqualink_data->frz_protect_set_point != TEMP_UNKNOWN && _aqualink_data->frz_protect_set_point != _last_mqtt_aqualinkdata.frz_protect_set_point) {
_last_mqtt_aqualinkdata.frz_protect_set_point = _aqualink_data->frz_protect_set_point;
send_mqtt_setpoint_msg(nc, FREEZE_PROTECT, _aqualink_data->frz_protect_set_point);
send_mqtt_string_msg(nc, FREEZE_PROTECT, MQTT_OFF); // Blindly send off, maybe change this in future if we can read whn freeze protect is active.
send_mqtt_string_msg(nc, FREEZE_PROTECT, _aqualink_data->frz_protect_state==ON?MQTT_ON:MQTT_OFF);
send_mqtt_string_msg(nc, FREEZE_PROTECT_ENABELED, MQTT_ON);
/*
send_mqtt_string_msg(nc, FREEZE_PROTECT_ENABELED, MQTT_ON);
@ -813,82 +813,16 @@ 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);
_aqualink_data->unactioned.type = POOL_HTR_SETOINT;
} else {
logMessage(LOG_ERR, "MQTT: request to set pool heater setpoint to %.2fc is outside of range\n", value);
send_mqtt_setpoint_msg(nc, BTN_POOL_HTR, _aqualink_data->pool_htr_set_point);
}*/
} 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);
_aqualink_data->unactioned.type = SPA_HTR_SETOINT;
} else {
logMessage(LOG_ERR, "MQTT: request to set spa heater setpoint to %.2fc is outside of range\n", value);
send_mqtt_setpoint_msg(nc, BTN_SPA_HTR, _aqualink_data->spa_htr_set_point);
} */
} 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);
_aqualink_data->unactioned.type = FREEZE_SETPOINT;
} else {
if (val > FREEZE_PT_MAX)
_aqualink_data->unactioned.value = FREEZE_PT_MAX;
else
_aqualink_data->unactioned.value = FREEZE_PT_MIN;
logMessage(LOG_ERR, "MQTT: request to set freeze protect to %.2fc/%df is outside range using %df\n", value, val, _aqualink_data->unactioned.value);
_aqualink_data->unactioned.type = FREEZE_SETPOINT;
}
*/
} else if (strncmp(pt1, "SWG", 3) == 0) { // If we get SWG percent as setpoint message.
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) )
val = _aqualink_data->unactioned.value = ((val + 5) / 10) * 10;
if (val > SWG_PERCENT_MAX) {
_aqualink_data->unactioned.value = SWG_PERCENT_MAX;
} else if ( val < SWG_PERCENT_MIN) {
_aqualink_data->unactioned.value = SWG_PERCENT_MIN;
}
logMessage(LOG_INFO, "MQTT: request to set SWG to %.2fc, setting to %d\n", value, val);
_aqualink_data->unactioned.type = SWG_SETPOINT;
*/
} else {
// Not sure what the setpoint is, ignore.
logMessage(LOG_DEBUG, "MQTT: ignoring %.*s don't recognise button setpoint\n", msg->topic.len, msg->topic.p);
@ -906,24 +840,6 @@ 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) )
val = _aqualink_data->unactioned.value = ((val + 5) / 10) * 10;
if (val > SWG_PERCENT_MAX) {
_aqualink_data->unactioned.value = SWG_PERCENT_MAX;
} else if ( val < SWG_PERCENT_MIN) {
_aqualink_data->unactioned.value = SWG_PERCENT_MIN;
}
logMessage(LOG_INFO, "MQTT: request to set SWG to %.2fc, setting to %d\n", value, val);
_aqualink_data->unactioned.type = SWG_SETPOINT;*/
} else if (pt2 != NULL && (strncmp(pt2, "set", 3) == 0) && (strncmp(pt2, "setpoint", 8) != 0)) {
// Must be a switch on / off
for (i=0; i < TOTAL_BUTTONS; i++) {

Binary file not shown.