Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sfeakes committed Aug 25, 2024
1 parent cb605b9 commit 47820a1
Show file tree
Hide file tree
Showing 32 changed files with 544 additions and 179 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,22 @@ Designed to mimic AqualinkRS devices, used to fully configure the master control
# Updates in 2.3.8 (Dev)
* Code & Repo refactor
* Decoded more Pentair VSP pump status.
* Changed VSP pump status handling (display more in web UI)
* VSP Pump status & other attributes in HASSIO
* Dual temperature sensors supported
* Updated to serial_logger
* Changed VSP pump status handling (display more in web UI).
* VSP Pump status & other attributes in HASSIO.
* Dual temperature sensors supported.
* Updates to serial_logger.
* Changes to aqmanager for adding more options for decoding protocols.
* Support for packets changes from panels REV Yg
<!--
NEED TO FIX FOR THIS RELEASE.
* Pump by name and not ID.
* look at using 0x00 for no exit on serial errors / startup
<done> * MQTT ID is now using a lot longer name due to arm64/armhf
<done> * Ignore SWG 0 messages can now be removed since VSP is fixed.
<done> * Increase packet length due to below (also the print message)
Warning: RS Serial: Serial packet too large\
Warning: RS Serial: Read Jandy packet BAD PACKET To 0x33 of type Unknown '0x72' | HEX: 0x10|0x02|0x33|0x72|0x20|0x01|0x02|0x03|0x04|0x05|0x06|0x07|0x08|0x09|0x0a|0x0b|0x0c|0x0d|0x0e|0x0f|0x10|0x11|0x12|0x13|0x14|0x15|0x16|0x17|0x18|0x19|0x1.........\
-->

# Updates in Release 2.3.7
* Fix for Pentair VSP losing connection & bouncing SWG to 0 and back.
Expand Down
Binary file modified release/aqualinkd-arm64
Binary file not shown.
Binary file modified release/aqualinkd-armhf
Binary file not shown.
48 changes: 22 additions & 26 deletions release/aqualinkd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ rs485_frame_delay = 4
# Get rid of the startup warning message about no low latency. BETTER option is to buy a better adapter.
#ftdi_low_latency = no

# Stop the SWG bounce from displaying when using VSP.
#swg_zero_ignore_count = 20


# Enable AqualinkD scheduler.
# A version of cron that supports cron.d must be installed for the scheduler to work.
# If you used the install script and didn;t receive any cron warnings, you should be good to go.
Expand Down Expand Up @@ -228,28 +224,28 @@ use_panel_aux_labels=no
#
# Below is an example of how different Panels map into the buttons.
#
# | RS-6 Combo | RS-6 Only | RS-8 Combo | RS-2/6 Dual | RS-2/10 Dual | RS-16 Combo |
# --------------------------------------------------------------------------------------------
# Button_01 | Filter Pump | Filter Pump | Filter Pump | Filter Pump | Filter Pump | Filter Pump |
# Button_02 | Spa | Aux_1 | Spa | Spa | Spa | Spa |
# Button_03 | Aux 1 | Aux 2 | Aux 1 | Aux 1 | Aux 1 | Aux 1 |
# Button_04 | Aux 2 | Aux 3 | Aux 2 | Aux 2 | Aux 2 | Aux 2 |
# Button_05 | Aux 3 | Aux 4 | Aux 3 | Aux 3 | Aux 3 | Aux 3 |
# Button_06 | Aux 4 | Aux 5 | Aux 4 | Aux 4 | Aux 4 | Aux 4 |
# Button_07 | Aux 5 | Temp 1 | Aux 5 | Aux 5 | Aux 5 | Aux 5 |
# Button_08 | Pool Heater | Temp 2 | Aux 6 | Aux 6 | Aux 6 | Aux 6 |
# Button_09 | Spa Heater | Solar Heater | Aux 7 | Pool Heater | Aux B1 | Aux 7 |
# Button_10 | Solar Heater | | Pool Heater | Spa Heater | Aux B2 | Aux B1 |
# Button_11 | | | Spa Heater | Solar Heater | Aux B3 | Aux B2 |
# Button_12 | | | Solar Heater | | Aux B4 | Aux B3 |
# Button_13 | | | | | Pool Heater | Aux B4 |
# Button_14 | | | | | Spa Heater | Aux B5 |
# Button_15 | | | | | Solar Heater | Aux B6 |
# Button_16 | | | | | | Aux B7 |
# Button_17 | | | | | | Aux B8 |
# Button_18 | | | | | | Pool Heater |
# Button_19 | | | | | | Spa Heater |
# Button_20 | | | | | | Solar Heater |
# | RS-4 Combo | RS-6 Combo | RS-6 Only | RS-8 Combo | RS-2/6 Dual | RS-2/10 Dual | RS-16 Combo |
# ----------------------------------------------------------------------------------------------------------
# Button_01 | Filter Pump | Filter Pump | Filter Pump | Filter Pump | Filter Pump | Filter Pump | Filter Pump |
# Button_02 | Spa | Spa | Aux_1 | Spa | Spa | Spa | Spa |
# Button_03 | Aux 1 | Aux 1 | Aux 2 | Aux 1 | Aux 1 | Aux 1 | Aux 1 |
# Button_04 | Aux 2 | Aux 2 | Aux 3 | Aux 2 | Aux 2 | Aux 2 | Aux 2 |
# Button_05 | Aux 3 | Aux 3 | Aux 4 | Aux 3 | Aux 3 | Aux 3 | Aux 3 |
# Button_06 | Pool Heater | Aux 4 | Aux 5 | Aux 4 | Aux 4 | Aux 4 | Aux 4 |
# Button_07 | Spa Heater | Aux 5 | Temp 1 | Aux 5 | Aux 5 | Aux 5 | Aux 5 |
# Button_08 | Solar Heater | Pool Heater | Temp 2 | Aux 6 | Aux 6 | Aux 6 | Aux 6 |
# Button_09 | | Spa Heater | Solar Heater | Aux 7 | Pool Heater | Aux B1 | Aux 7 |
# Button_10 | | Solar Heater | | Pool Heater | Spa Heater | Aux B2 | Aux B1 |
# Button_11 | | | | Spa Heater | Solar Heater | Aux B3 | Aux B2 |
# Button_12 | | | | Solar Heater | | Aux B4 | Aux B3 |
# Button_13 | | | | | | Pool Heater | Aux B4 |
# Button_14 | | | | | | Spa Heater | Aux B5 |
# Button_15 | | | | | | Solar Heater | Aux B6 |
# Button_16 | | | | | | | Aux B7 |
# Button_17 | | | | | | | Aux B8 |
# Button_18 | | | | | | | Pool Heater |
# Button_19 | | | | | | | Spa Heater |
# Button_20 | | | | | | | Solar Heater |

#
# Optional, ( button_01_pumpID & button_01_pumpIndex )
Expand Down
Binary file modified release/serial_logger-arm64
Binary file not shown.
Binary file modified release/serial_logger-armhf
Binary file not shown.
6 changes: 6 additions & 0 deletions source/allbutton_aq_programmer.c
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,9 @@ void *set_allbutton_light_colormode( void *ptr )

if (i == LIGHT_COLOR_OPTIONS) {
LOG(ALLB_LOG, LOG_ERR, "Light Programming didn't receive color light mode message for '%s'\n",use_current_mode?"light program":mode_name);
} else {
// Set before we are called.
//updateButtonLightProgram(aq_data, val, btn);
}

cleanAndTerminateThread(threadCtrl);
Expand Down Expand Up @@ -624,6 +627,9 @@ void *set_allbutton_light_programmode( void *ptr )
}
//waitForButtonState(aq_data, &aq_data->aqbuttons[btn], ON, 2);

// set before we are called
//updateButtonLightProgram(aq_data, val, btn);

cleanAndTerminateThread(threadCtrl);

// just stop compiler error, ptr is not valid as it's just been freed
Expand Down
2 changes: 2 additions & 0 deletions source/aq_mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
#define PUMP_MODE_TOPIC "/Mode"
#define PUMP_STATUS_TOPIC "/Status"
#define PUMP_PPC_TOPIC "/PPC"

#define LIGHT_PROGRAM_TOPIC "/program"
/*
#define AIR_TEMPERATURE "Air"
#define POOL_TEMPERATURE "Pool_Water"
Expand Down
32 changes: 31 additions & 1 deletion source/aq_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "serialadapter.h"
#include "aq_timer.h"
#include "allbutton_aq_programmer.h"
#include "rs_msg_utils.h"

void initPanelButtons(struct aqualinkdata *aqdata, bool rspda, int size, bool combo, bool dual);
void programDeviceLightMode(struct aqualinkdata *aqdata, int value, int button);
Expand Down Expand Up @@ -60,6 +61,8 @@ uint8_t getPanelSupport( char *rev_string, int rev_len)
// Rev >=Q == iaqualink touch protocol.
// REv >= P == chemlink
// Rev >= HH serial adapter.

// Rev Yg (and maybe before) has Pump label (not number), and also Virtual Device called Label Auxiliraries
if (REV[0] >= 81) // Q in ascii
supported |= RSP_SUP_IAQT;

Expand Down Expand Up @@ -752,6 +755,9 @@ void programDeviceLightMode(struct aqualinkdata *aqdata, int value, int button)
sprintf(buf, "%-5d%-5d%-5d",value, button, light->lightType);
aq_programmer(AQ_SET_LIGHTCOLOR_MODE, buf, aqdata);
}

// Use function so can be called from programming thread if we decide to in future.
updateButtonLightProgram(aqdata, value, button);
}

/*
Expand Down Expand Up @@ -794,7 +800,12 @@ bool panel_device_request(struct aqualinkdata *aqdata, action_type type, int dev
start_timer(aqdata, deviceIndex, value);
break;
case LIGHT_MODE:
programDeviceLightMode(aqdata, value, deviceIndex);
if (value <= 0) {
// Consider this a bad/malformed request to turn the light off.
panel_device_request(aqdata, ON_OFF, deviceIndex, 0, source);
} else {
programDeviceLightMode(aqdata, value, deviceIndex);
}
break;
case POOL_HTR_SETOINT:
case SPA_HTR_SETOINT:
Expand All @@ -819,8 +830,27 @@ bool panel_device_request(struct aqualinkdata *aqdata, action_type type, int dev
}


// Programmable light has been updated, so update the status in AqualinkD
void updateButtonLightProgram(struct aqualinkdata *aqdata, int value, int button)
{
int i;
clight_detail *light = NULL;

for (i=0; i < aqdata->num_lights; i++) {
if (&aqdata->aqbuttons[button] == aqdata->lights[i].button) {
// Found the programmable light
light = &aqdata->lights[i];
break;
}
}

if (light == NULL) {
LOG(PANL_LOG,LOG_ERR, "Button not found for light button index=%d\n",button);
return;
}

light->currentValue = value;
}


#ifdef DO_NOT_COMPILE
Expand Down
2 changes: 2 additions & 0 deletions source/aq_panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const char* getPanelString();

bool panel_device_request(struct aqualinkdata *aqdata, action_type type, int deviceIndex, int value, request_source source);

void updateButtonLightProgram(struct aqualinkdata *aqdata, int value, int button);

void changePanelToMode_Only();
void addPanelOneTouchInterface();
void addPanelIAQTouchInterface();
Expand Down
15 changes: 10 additions & 5 deletions source/aq_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ bool check_jandy_checksum(unsigned char* packet, int length)
LOG(RSSD_LOG,LOG_INFO, "Ignoring bad checksum, seems to be bug in Jandy protocol\n");
if (getLogLevel(RSSD_LOG) >= LOG_DEBUG) {
static char buf[1000];
beautifyPacket(buf,packet,length,true);
beautifyPacket(buf,1000, packet,length,true);
LOG(RSSD_LOG,LOG_DEBUG, "Packetin question %s\n",buf);
}
return true;
Expand Down Expand Up @@ -1128,17 +1128,20 @@ int get_packet(int fd, unsigned char* packet)
// Break out of the loop if we exceed maximum packet
// length.
if (index >= AQ_MAXPKTLEN) {
LOG(RSSD_LOG,LOG_WARNING, "Serial packet too large\n");
LOG(RSSD_LOG,LOG_WARNING, "Serial packet too large for buffer, stopped reading\n");
logPacketError(packet, index);
//log_packet(LOG_WARNING, "Bad receive packet ", packet, index);
return AQSERR_2LARGE;
break;
}
}

// Clean out rest of buffer, make sure their is nothing else
/* Doesn't work for shit due to probe message speed, need to come back and re-think
*/

// Report any unusual size packets.
if (index >= AQ_MAXPKTLEN_WARNING) {
LOG(RSSD_LOG,LOG_WARNING, "Serial packet seems too large at length %d\n", index);
logPacketError(packet, index);
}

//LOG(RSSD_LOG,LOG_DEBUG, "Serial checksum, length %d got 0x%02hhx expected 0x%02hhx\n", index, packet[index-3], generate_checksum(packet, index));
if (jandyPacketStarted) {
Expand All @@ -1156,6 +1159,8 @@ int get_packet(int fd, unsigned char* packet)
return AQSERR_CHKSUM;
}
}


/*
if (generate_checksum(packet, index) != packet[index-3]){
LOG(RSSD_LOG,LOG_WARNING, "Serial read bad checksum, ignoring\n");
Expand Down
34 changes: 33 additions & 1 deletion source/aq_serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,32 @@ const char *getJandyDeviceName(emulation_type etype);
#define JANDY_DEC_CHEM_MIN 128 // 0x80
#define JANDY_DEC_CHEM_MAX 131 // 0x83

/*
//===== Device ID's =====//
//=========================================================================//
DEV_MASTER_MASK = 0x00; // MASTER(S???0 00-03 0b0 0000 0XX //
DEV_CTL_MASK = 0x08; // HOME CONTROLLER (RS-8?) 08-0b 0b0 0001 0XX //
// 0x10; // XXXXX DEVICE 10-13 0b0 0010 0XX //
// 0x18; // XXXXX DEVICE 18-1b 0b0 0011 0XX //
DEV_SPA_MASK = 0x20; // SPA DEVICE 20-23 0b0 0100 0XX //
DEV_RPC_MASK = 0x28; // REMOTE POWER CENTER DEVICE 28-2b 0b0 0101 0XX //
DEV_AQUALINK_MASK = 0x30; // AQUALINK DEVICE 30-33 0b0 0110 0XX //
DEV_LX_HTR_MASK = 0x38; // LX HEATER 38-3b 0b0 0111 0XX //
DEV_ONETOUCH_MASK = 0x40; // XXXXX ONE TOUCH DEVICE 40-43 0b0 1000 0XX //
// 0x48; // XXXXX DEVICE 48-4b 0b0 1001 0XX //
DEV_AQUARITE_MASK = 0x50; // AQUARITE DEVICE 50-53 0b0 1010 0XX //
DEV_PCDOCK_MASK = 0x58; // PCDOCK DEVICE 58-5b 0b0 1011 0XX //
DEV_PDA_JDA_MASK = 0x60; // AQUAPALM DEVICE 60-63 0b0 1100 0XX //
DEV_LXI_LRZE_MASK = 0x68; // LXi/LZRE DEVICE 68-6b 0b0 1101 0XX //
DEV_HEATPUMP_MASK = 0x70; // HEAT PUMP DEVICE 70-73 0b0 1110 0XX //
JANDY_EPUMP_MASK = 0x78; // EPUMP DEVICE 78-7b 0b0 1111 0XX //
DEV_CHEMLINK_MASK = 0x80; // CHEMLINK DEVICE 80-83 0b1 0000 0XX //
Heater 0x88; // XXXXX DEVICE 88-8b 0b1 0001 0XX //
// 0x90; // XXXXX DEVICE 90-93 0b1 0010 0XX //
// 0x98; // XXXXX DEVICE 98-9b 0b1 0011 0XX //
DEV_AQUALINK_2_MASK = 0xA0; // AQUALINK 2 A0-A3 0b1 0100 0XX //
DEV_UNKNOWN_MASK = 0xF8; // Unknown mask, used to reset values
*/

// PACKET DEFINES Jandy
#define NUL 0x00
Expand Down Expand Up @@ -94,12 +120,18 @@ const char *getJandyDeviceName(emulation_type etype);

#define AQ_MINPKTLEN 5
//#define AQ_MAXPKTLEN 64
#define AQ_MAXPKTLEN 128 // Max 79 bytes so far, so 128 is a guess at the moment, just seen large packets from iAqualink
//#define AQ_MAXPKTLEN 128 // Max 79 bytes so far, so 128 is a guess at the moment, just seen large packets from iAqualink
#define AQ_MAXPKTLEN 256 // Still getting this at 128, so temp increase to 256 and print message over 128 in aq_serial.c
#define AQ_PSTLEN 5
#define AQ_MSGLEN 16
#define AQ_MSGLONGLEN 128
#define AQ_TADLEN 13

// For printing warning & debug messages for packets.
// The below are related to AQ_MAXPKTLEN
#define AQ_MAXPKTLEN_WARNING 128 // Print warning message if over this
//#define AQ_PACKET_PRINT_BUFFER 1400 // Must be at least AQ_MAXPKTLEN * 5 + 100

/* COMMANDS */
#define CMD_PROBE 0x00
#define CMD_ACK 0x01
Expand Down
6 changes: 5 additions & 1 deletion source/aqualink.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ typedef struct aqualinkkey
#define VS_PUMP (1 << 0)
#define PROGRAM_LIGHT (1 << 1)
#define TIMER_ACTIVE (1 << 2)
//#define DIMMER_LIGHT (1 << 3) // NOT USED YET
//#define DIMMER_LIGHT (1 << 3) // NOT USED (Use PROGRAM_LIGHT or type LC_DIMMER)

//typedef struct ProgramThread ProgramThread; // Definition is later

Expand Down Expand Up @@ -212,6 +212,7 @@ typedef struct clightd
{
clight_type lightType;
aqkey *button;
int currentValue;
} clight_detail;


Expand Down Expand Up @@ -282,6 +283,9 @@ struct aqualinkdata

#ifdef AQ_MANAGER
volatile bool run_slogger;
int slogger_packets;
bool slogger_debug;
char slogger_ids[20];
#endif

#ifdef AQ_RS16
Expand Down
18 changes: 14 additions & 4 deletions source/aqualinkd.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,6 @@ int startup(char *self, char *cfgFile)
_aqualink_data.total_buttons = 12;
*/


if (_cmdln_loglevel != -1)
_aqconfig_.log_level = _cmdln_loglevel;

Expand Down Expand Up @@ -635,10 +634,10 @@ int startup(char *self, char *cfgFile)
LOG(AQUA_LOG,LOG_NOTICE, "Read JXi heater direct = %s\n", bool2text(READ_RSDEV_JXI));
LOG(AQUA_LOG,LOG_NOTICE, "Read LX heater direct = %s\n", bool2text(READ_RSDEV_LX));
LOG(AQUA_LOG,LOG_NOTICE, "Read Chem Feeder direct = %s\n", bool2text(READ_RSDEV_CHEM));

/*
if (READ_RSDEV_SWG && _aqconfig_.swg_zero_ignore != DEFAULT_SWG_ZERO_IGNORE_COUNT)
LOG(AQUA_LOG,LOG_NOTICE, "Ignore SWG 0 msg count = %d\n", _aqconfig_.swg_zero_ignore);

*/
if (_aqconfig_.ftdi_low_latency == true)
LOG(AQUA_LOG,LOG_NOTICE, "Serial FTDI low latency = %s\n", bool2text(_aqconfig_.ftdi_low_latency));

Expand Down Expand Up @@ -874,6 +873,10 @@ void main_loop()
_aqualink_data.pumps[i].pressureCurve = TEMP_UNKNOWN;
}

for (i=0; i < MAX_LIGHTS; i++) {
_aqualink_data.lights[i].currentValue = TEMP_UNKNOWN;
}

if (_aqconfig_.force_swg == true) {
//_aqualink_data.ar_swg_device_status = SWG_STATUS_OFF;
_aqualink_data.swg_led_state = OFF;
Expand Down Expand Up @@ -1137,8 +1140,15 @@ void main_loop()
if (_aqualink_data.run_slogger) {
LOG(AQUA_LOG,LOG_WARNING, "Starting serial_logger, this will take some time!\n");
broadcast_aqualinkstate_error(CONNECTION_RUNNING_SLOG);
serial_logger(rs_fd, _aqconfig_.serial_port, getSystemLogLevel());

if (_aqualink_data.slogger_debug)
addDebugLogMask(SLOG_LOG);

serial_logger(rs_fd, _aqconfig_.serial_port, _aqualink_data.slogger_debug?LOG_DEBUG:getSystemLogLevel(), _aqualink_data.slogger_packets, _aqualink_data.slogger_ids);
_aqualink_data.run_slogger = false;

if (_aqualink_data.slogger_debug)
removeDebugLogMask(SLOG_LOG);
}
#endif

Expand Down
6 changes: 5 additions & 1 deletion source/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void init_parameters (struct aqconfig * parms)
parms->force_frzprotect_setpoints = false;
parms->force_chem_feeder = false;
//parms->swg_pool_and_spa = false;
parms->swg_zero_ignore = DEFAULT_SWG_ZERO_IGNORE_COUNT;
//parms->swg_zero_ignore = DEFAULT_SWG_ZERO_IGNORE_COUNT;
parms->display_warnings_web = false;

parms->log_protocol_packets = false; // Read & Write as packets write to file
Expand Down Expand Up @@ -244,6 +244,8 @@ char *generate_mqtt_id(char *buf, int len) {
strncpy(buf, basename(__progname), len);
i = strlen(buf);

if ( i > 9) { i=9; } // cut down to 9 characters (aqualinkd)

if (i < len) {
buf[i++] = '_';
// If we can't get MAC to pad mqtt id then use PID
Expand Down Expand Up @@ -603,9 +605,11 @@ bool setConfigValue(struct aqualinkdata *aqdata, char *param, char *value) {
} else if (strncasecmp (param, "debug_RSProtocol_packets", 24) == 0) {
_aqconfig_.log_protocol_packets = text2bool(value);
rtn=true;
/*
} else if (strncasecmp (param, "swg_zero_ignore_count", 21) == 0) {
_aqconfig_.swg_zero_ignore = strtoul(value, NULL, 10);
rtn=true;
*/
} else if (strncasecmp (param, "display_warnings_in_web", 23) == 0) {
_aqconfig_.display_warnings_web = text2bool(value);
rtn=true;
Expand Down
Loading

0 comments on commit 47820a1

Please sign in to comment.