mirror of https://github.com/sfeakes/AqualinkD.git
first
parent
71a9617d57
commit
2b56496f67
|
@ -6,6 +6,8 @@
|
|||
#define AIR_TEMP_TOPIC "Temperature/Air"
|
||||
#define POOL_TEMP_TOPIC "Temperature/Pool"
|
||||
#define SPA_TEMP_TOPIC "Temperature/Spa"
|
||||
//#define POOL_SETPT_TOPIC "Pool_Heater/setpoint"
|
||||
//#define SPA_SETPT_TOPIC "Spa_Heater/setpoint"
|
||||
#define SWG_PERCENT_TOPIC "SWG/Percent"
|
||||
#define SWG_PERCENT_F_TOPIC "SWG/Percent_f"
|
||||
#define SWG_PPM_TOPIC "SWG/PPM"
|
||||
|
|
|
@ -250,9 +250,9 @@ bool setAqualinkNumericField(struct aqualinkdata *aq_data, char *value_label, in
|
|||
bool setAqualinkNumericField_new(struct aqualinkdata *aq_data, char *value_label, int value, int increment)
|
||||
{
|
||||
logMessage(LOG_DEBUG,"Setting menu item '%s' to %d\n",value_label, value);
|
||||
char leading[10]; // description of the field (POOL, SPA, FRZ)
|
||||
//char leading[10]; // description of the field (POOL, SPA, FRZ)
|
||||
int current_val; // integer value of the current set point
|
||||
char trailing[10]; // the degrees and scale
|
||||
//char trailing[10]; // the degrees and scale
|
||||
char searchBuf[20];
|
||||
|
||||
sprintf(searchBuf, "^%s", value_label);
|
||||
|
|
|
@ -109,7 +109,9 @@
|
|||
#define MSG_SWG_PPM_LEN 4
|
||||
|
||||
|
||||
/* AQUAPURE SWG */
|
||||
|
||||
#define SWG_STATUS_OFF 0xFF
|
||||
|
||||
typedef enum {
|
||||
ON,
|
||||
|
|
42
aqualinkd.c
42
aqualinkd.c
|
@ -262,6 +262,20 @@ void processMessage_OLD(char *message)
|
|||
kick_aq_program_thread(&_aqualink_data);
|
||||
}
|
||||
*/
|
||||
void setUnits(char *msg)
|
||||
{
|
||||
//logMessage(LOG_INFO, "Getting temp from %s, looking at %c", msg, msg[strlen(msg)-1]);
|
||||
|
||||
if (msg[strlen(msg)-1] == 'F')
|
||||
_aqualink_data.temp_units = FAHRENHEIT;
|
||||
else if (msg[strlen(msg)-1] == 'C')
|
||||
_aqualink_data.temp_units = CELSIUS;
|
||||
else
|
||||
_aqualink_data.temp_units = UNKNOWN;
|
||||
|
||||
logMessage(LOG_INFO, "Temp Units set to %d (F=0, C=1, Unknown=3)", _aqualink_data.temp_units);
|
||||
}
|
||||
|
||||
|
||||
void processMessage(char *message)
|
||||
{
|
||||
|
@ -292,26 +306,35 @@ void processMessage(char *message)
|
|||
else if(stristr(msg, LNG_MSG_POOL_TEMP_SET) != NULL) {
|
||||
//logMessage(LOG_DEBUG, "pool htr long message: %s", &message[20]);
|
||||
_aqualink_data.pool_htr_set_point = atoi(message+20);
|
||||
|
||||
if (_aqualink_data.temp_units == UNKNOWN)
|
||||
setUnits(msg);
|
||||
}
|
||||
else if(stristr(msg, LNG_MSG_SPA_TEMP_SET) != NULL) {
|
||||
//logMessage(LOG_DEBUG, "spa htr long message: %s", &message[19]);
|
||||
_aqualink_data.spa_htr_set_point = atoi(message+19);
|
||||
|
||||
if (_aqualink_data.temp_units == UNKNOWN)
|
||||
setUnits(msg);
|
||||
}
|
||||
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);
|
||||
|
||||
if (_aqualink_data.temp_units == UNKNOWN)
|
||||
setUnits(msg);
|
||||
}
|
||||
else if(strncasecmp(msg, MSG_AIR_TEMP, MSG_AIR_TEMP_LEN) == 0) {
|
||||
_aqualink_data.air_temp = atoi(msg+8);
|
||||
if (msg[strlen(msg)-1] == 'F')
|
||||
_aqualink_data.temp_units = FAHRENHEIT;
|
||||
else if (msg[strlen(msg)-1] == 'C')
|
||||
_aqualink_data.temp_units = CELSIUS;
|
||||
else
|
||||
_aqualink_data.temp_units = UNKNOWN;
|
||||
|
||||
if (_aqualink_data.temp_units == UNKNOWN)
|
||||
setUnits(msg);
|
||||
}
|
||||
else if(strncasecmp(msg, MSG_POOL_TEMP, MSG_POOL_TEMP_LEN) == 0) {
|
||||
_aqualink_data.pool_temp = atoi(msg+9);
|
||||
|
||||
if (_aqualink_data.temp_units == UNKNOWN)
|
||||
setUnits(msg);
|
||||
/* NSF add config option to support
|
||||
if (_config_parameters.spa_temp_follow_pool == true && _aqualink_data.aqbuttons[SPA_INDEX].led->state == OFF ) {
|
||||
_aqualink_data.spa_temp = _aqualink_data.pool_temp
|
||||
|
@ -530,7 +553,7 @@ 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) {
|
||||
if (_aqualink_data.ar_swg_status != 0x00 ) {
|
||||
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 {
|
||||
|
@ -695,8 +718,9 @@ void main_loop() {
|
|||
_aqualink_data.unactioned.type = NO_ACTION;
|
||||
_aqualink_data.swg_percent = TEMP_UNKNOWN;
|
||||
_aqualink_data.swg_ppm = TEMP_UNKNOWN;
|
||||
_aqualink_data.ar_swg_status = 0xFF;
|
||||
_aqualink_data.ar_swg_status = SWG_STATUS_OFF;
|
||||
_aqualink_data.swg_delayed_percent = TEMP_UNKNOWN;
|
||||
_aqualink_data.temp_units = UNKNOWN;
|
||||
|
||||
|
||||
if (!start_net_services(&mgr, &_aqualink_data, &_config_parameters)) {
|
||||
|
@ -769,7 +793,7 @@ void main_loop() {
|
|||
}
|
||||
interestedInNextAck = false;
|
||||
} else if (interestedInNextAck == true && packet_buffer[PKT_DEST] != 0x00) {
|
||||
_aqualink_data.ar_swg_status = 0xFF;
|
||||
_aqualink_data.ar_swg_status = SWG_STATUS_OFF;
|
||||
interestedInNextAck = false;
|
||||
} else if (packet_buffer[PKT_DEST] == 0x50) {
|
||||
interestedInNextAck = true;
|
||||
|
|
|
@ -343,7 +343,7 @@ void mqtt_broadcast_aqualinkstate(struct mg_connection *nc)
|
|||
send_domoticz_mqtt_status_message(nc, _aqualink_config->dzidx_swg_status, 4, "CHECK PCB");
|
||||
send_mqtt_int_msg(nc, SWG_TOPIC, SWG_OFF);
|
||||
break;
|
||||
case 0xFF: // THIS IS OUR OFF STATUS, NOT AQUAPURE
|
||||
case SWG_STATUS_OFF: // THIS IS OUR OFF STATUS, NOT AQUAPURE
|
||||
send_domoticz_mqtt_status_message(nc, _aqualink_config->dzidx_swg_status, 0, "OFF");
|
||||
send_mqtt_int_msg(nc, SWG_TOPIC, SWG_OFF);
|
||||
break;
|
||||
|
@ -445,6 +445,23 @@ void action_web_request(struct mg_connection *nc, struct http_message *http_msg)
|
|||
aq_programmer(AQ_GET_DIAGNOSTICS_MODEL, NULL, _aqualink_data);
|
||||
mg_send_head(nc, 200, strlen(GET_RTN_OK), "Content-Type: text/plain");
|
||||
mg_send(nc, GET_RTN_OK, strlen(GET_RTN_OK));
|
||||
} else if (strcmp(command, "swg_percent") == 0) {
|
||||
char value[20];
|
||||
mg_get_http_var(&http_msg->query_string, "value", value, sizeof(value));
|
||||
int val = atoi(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 if (strcmp(command, "pool_htr_set_pnt") == 0) {
|
||||
} else if (strcmp(command, "spa_htr_set_pnt") == 0) {
|
||||
} else if (strcmp(command, "frz_protect_set_pnt") == 0) {
|
||||
} else {
|
||||
int i;
|
||||
for (i = 0; i < TOTAL_BUTTONS; i++) {
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue