diff --git a/tasmota/xsns_83_neopool.ino b/tasmota/xsns_83_neopool.ino index 2bf87acd0..eb7ac25d4 100644 --- a/tasmota/xsns_83_neopool.ino +++ b/tasmota/xsns_83_neopool.ino @@ -58,7 +58,7 @@ #endif -#define NEOPOOL_READ_REGISTER 0x03 // Function code used to read register: Read Holding Registers +#define NEOPOOL_READ_REGISTER 0x04 // Function code used to read register: Read Input Registers #define NEOPOOL_WRITE_REGISTER 0x10 // Function code used to write register: Write Multiple Registers #define NEOPOOL_READ_TIMEOUT 25 // read data timeout in ms @@ -94,6 +94,7 @@ enum NeoPoolRegister { // GLOBAL page (0x02xx) MBF_SAVE_TO_EEPROM=0x02F0, // 0x02F0 A write operation to this register starts a EEPROM storage operation immediately. During the EEPROM storage procedure, the system may be unresponsive to MODBUS requests. The operation will last always less than 1 second. + MBF_EXEC=0x02F5, // 0x02F5 undocumented - immediately take over settings - a write operation to this register take over the previous written data // FACTORY page (0x03xx) MBF_PAR_VERSION=0x0300, // 0x0300* Software version of the PowerBox (unused) @@ -163,18 +164,18 @@ enum NeoPoolRegister { MBF_PAR_RELAY_MODE, // 0x0432 Behavior of the system when the dosing time is exceeded (see MBMSK_PAR_RELAY_MODE_* and MBV_PAR_RELAY_MODE_*) MBF_PAR_RELAY_ACTIVATION_DELAY, // 0x0433 Delay time in seconds for the pH pump when the measured pH value is outside the allowable pH setpoints. The system internally adds an extra time of 10 seconds to the value stored here. The pump starts the dosing operation once the condition of pH out of valid interval is maintained during the time specified in this register. MBF_PAR_TIMER_BLOCK_BASE, // 0x0434 This block of 180 registers holds the configuration of the system timers. The system has a set of 12 fully configurable timers, each one assigned to a specific function, described below: - MBF_PAR_TIMER_BLOCK_FILT_INT1=0x0434,//0x0434 Filtration interval 1 (15 register - see PAR_TIMER_BLOCK_OFF* for desc) - MBF_PAR_TIMER_BLOCK_FILT_INT2=0x0443,//0x0443 Filtration interval 2 (15 register - see PAR_TIMER_BLOCK_OFF* for desc) - MBF_PAR_TIMER_BLOCK_FILT_INT3=0x0452,//0x0452 Filtration interval 3 (15 register - see PAR_TIMER_BLOCK_OFF* for desc) - MBF_PAR_TIMER_BLOCK_AUX1_INT2=0x0461,//0x0461 Auxiliary relay 1 - 2. interval (15 register - see PAR_TIMER_BLOCK_OFF* for desc) - MBF_PAR_TIMER_BLOCK_LIGHT_INT=0x0470,//0x0470 Lighting interval (15 register - see PAR_TIMER_BLOCK_OFF* for desc) - MBF_PAR_TIMER_BLOCK_AUX2_INT2=0x047F,//0x047F Auxiliary relay 2 - 2. interval (15 register - see PAR_TIMER_BLOCK_OFF* for desc) - MBF_PAR_TIMER_BLOCK_AUX3_INT2=0x048E,//0x048E Auxiliary relay 3 - 2. interval (15 register - see PAR_TIMER_BLOCK_OFF* for desc) - MBF_PAR_TIMER_BLOCK_AUX4_INT2=0x049D,//0x049D Auxiliary relay 4 - 2. interval (15 register - see PAR_TIMER_BLOCK_OFF* for desc) - MBF_PAR_TIMER_BLOCK_AUX1_INT1=0x04AC,//0x04AC Auxiliary relay 1 - 1. interval (15 register - see PAR_TIMER_BLOCK_OFF* for desc) - MBF_PAR_TIMER_BLOCK_AUX2_INT1=0x04BB,//0x04BB Auxiliary relay 2 - 1. interval (15 register - see PAR_TIMER_BLOCK_OFF* for desc) - MBF_PAR_TIMER_BLOCK_AUX3_INT1=0x04CA,//0x04CA Auxiliary relay 3 - 1. interval (15 register - see PAR_TIMER_BLOCK_OFF* for desc) - MBF_PAR_TIMER_BLOCK_AUX4_INT1=0x04D9,//0x04D9 Auxiliary relay 4 - 1. interval (15 register - see PAR_TIMER_BLOCK_OFF* for desc) + MBF_PAR_TIMER_BLOCK_FILT_INT1=0x0434,//0x0434 Filtration interval 1 (15 register - see MBV_TIMER_OFFMB_* for desc) + MBF_PAR_TIMER_BLOCK_FILT_INT2=0x0443,//0x0443 Filtration interval 2 (15 register - see MBV_TIMER_OFFMB_* for desc) + MBF_PAR_TIMER_BLOCK_FILT_INT3=0x0452,//0x0452 Filtration interval 3 (15 register - see MBV_TIMER_OFFMB_* for desc) + MBF_PAR_TIMER_BLOCK_AUX1_INT2=0x0461,//0x0461 Auxiliary relay 1 - 2. interval (15 register - see MBV_TIMER_OFFMB_* for desc) + MBF_PAR_TIMER_BLOCK_LIGHT_INT=0x0470,//0x0470 Lighting interval (15 register - see MBV_TIMER_OFFMB_* for desc) + MBF_PAR_TIMER_BLOCK_AUX2_INT2=0x047F,//0x047F Auxiliary relay 2 - 2. interval (15 register - see MBV_TIMER_OFFMB_* for desc) + MBF_PAR_TIMER_BLOCK_AUX3_INT2=0x048E,//0x048E Auxiliary relay 3 - 2. interval (15 register - see MBV_TIMER_OFFMB_* for desc) + MBF_PAR_TIMER_BLOCK_AUX4_INT2=0x049D,//0x049D Auxiliary relay 4 - 2. interval (15 register - see MBV_TIMER_OFFMB_* for desc) + MBF_PAR_TIMER_BLOCK_AUX1_INT1=0x04AC,//0x04AC Auxiliary relay 1 - 1. interval (15 register - see MBV_TIMER_OFFMB_* for desc) + MBF_PAR_TIMER_BLOCK_AUX2_INT1=0x04BB,//0x04BB Auxiliary relay 2 - 1. interval (15 register - see MBV_TIMER_OFFMB_* for desc) + MBF_PAR_TIMER_BLOCK_AUX3_INT1=0x04CA,//0x04CA Auxiliary relay 3 - 1. interval (15 register - see MBV_TIMER_OFFMB_* for desc) + MBF_PAR_TIMER_BLOCK_AUX4_INT1=0x04D9,//0x04D9 Auxiliary relay 4 - 1. interval (15 register - see MBV_TIMER_OFFMB_* for desc) MBF_PAR_FILTVALVE_ENABLE=0x04E8, // 0x04E8 Filter cleaning functionality mode (0=off, 1=Besgo) MBF_PAR_FILTVALVE_MODE, // 0x04E9 Filter cleaning valve timing mode, possible modes: MBV_PAR_CTIMER_ENABLED, MBV_PAR_CTIMER_ALWAYS_ON, MBV_PAR_CTIMER_ALWAYS_OFF MBF_PAR_FILTVALVE_GPIO, // 0x04EA Relay associated with the filter cleaning function. default AUX2 (value 5) @@ -423,7 +424,7 @@ enum NeoPoolConstAndBitMask { MBV_TIMER_OFFMB_TIMER_PERIOD = 5, // Time in seconds between starting points (32-bit, LSB first), e.g. 86400 means daily MBV_TIMER_OFFMB_TIMER_INTERVAL = 7, // Time in seconds that the timer has to run when started (32-bit, LSB first) MBV_TIMER_OFFMB_TIMER_COUNTDOWN = 9, // Time remaining in seconds for the countdown mode (32-bit, LSB first) - MBV_TIMER_OFFMB_TIMER_FUNCTION = 11, // Function assigned to this timer, see + MBV_TIMER_OFFMB_TIMER_FUNCTION = 11, // Function assigned to this timer, see MBV_PAR_CTIMER_FCT_* MBV_TIMER_OFFMB_TIMER_WORK_TIME = 13, // Number of seconds that the timer has been operating // MBV_TIMER_OFFMB_TIMER_ENABLE working modes: MBV_PAR_CTIMER_DISABLE = 0, // Timer disabled @@ -482,12 +483,18 @@ enum NeoPoolConstAndBitMask { #include TasmotaModbus *NeoPoolModbus; +enum NeoPoolResult { + NEOPOOL_RESULT_DEC=false, + NEOPOOL_RESULT_HEX, + NEOPOOL_RESULT_MAX +}; +uint8_t neopool_result = NEOPOOL_RESULT_HEX; + bool neopool_active = false; volatile bool neopool_poll = true; uint8_t neopool_read_state = 0; uint8_t neopool_send_retry = 0; -uint8_t neopool_failed = 0; uint8_t neopool_failed_count = 0; #ifdef NEOPOOL_OPTIMIZE_READINGS bool neopool_first_read = true; @@ -507,11 +514,13 @@ struct NEOPOOL_REG { }; // NeoPool modbus function errors -#define NEOPOOL_OK 0 -#define NEOPOOL_ERROR_RW_DATA 1 -#define NEOPOOL_ERROR_TIMEOUT 2 -#define NEOPOOL_ERROR_OUT_OF_MEM 3 -#define NEOPOOL_ERROR_DEADLOCK 4 +enum NeoPoolModbusCode { + NEOPOOL_OK=0, + NEOPOOL_ERROR_RW_DATA, + NEOPOOL_ERROR_TIMEOUT, + NEOPOOL_ERROR_OUT_OF_MEM, + NEOPOOL_ERROR_DEADLOCK +}; #define D_NEOPOOL_NAME "NeoPool" @@ -558,15 +567,170 @@ const char kNeoPoolpHAlarms[] PROGMEM = #define D_STR_BIT "Bit" #endif // D_STR_BIT -const char HTTP_SNS_NEOPOOL_PH[] PROGMEM = "{s}%s " D_PH "{m}%s " "%s%s" "{e}"; -const char HTTP_SNS_NEOPOOL_TIME[] PROGMEM = "{s}%s " D_NEOPOOL_TIME "{m}%s" "{e}"; -const char HTTP_SNS_NEOPOOL_PPM_REDOX[] PROGMEM = "{s}%s " D_NEOPOOL_REDOX "{m}%s " D_UNIT_PARTS_PER_MILLION "{e}"; -const char HTTP_SNS_NEOPOOL_PPM_CHLORINE[] PROGMEM = "{s}%s " D_NEOPOOL_CHLORINE "{m}%s " D_UNIT_PARTS_PER_MILLION "{e}"; -const char HTTP_SNS_NEOPOOL_CONDUCTIVITY[] PROGMEM = "{s}%s " D_NEOPOOL_CONDUCTIVITY "{m}%s " D_UNIT_PERCENT "{e}"; -const char HTTP_SNS_NEOPOOL_IONIZATION[] PROGMEM = "{s}%s " D_NEOPOOL_IONIZATION "{m}%s " "%s%s" "{e}"; -const char HTTP_SNS_NEOPOOL_HYDROLYSIS[] PROGMEM = "{s}%s " D_NEOPOOL_HYDROLYSIS "{m}%s " "%s%s" "{e}"; -const char HTTP_SNS_NEOPOOL_FILT_MODE[] PROGMEM = "{s}%s " D_NEOPOOL_FILT_MODE "{m}%s" "{e}"; -const char HTTP_SNS_NEOPOOL_RELAY[] PROGMEM = "{s}%s " D_NEOPOOL_RELAY " %d %s" "{m}%s" "{e}"; +#define NEOPOOL_FMT_PH "%-2_f" +#define NEOPOOL_FMT_RX "%-2_f" +#define NEOPOOL_FMT_CL "%-2_f" +#define NEOPOOL_FMT_CD "%d" +#define NEOPOOL_FMT_ION "%1_f" +#define NEOPOOL_FMT_HIDRO "%1_f" + +#define HTTP_SNS_NEOPOOL_FLAGS "%s" +const char HTTP_SNS_NEOPOOL_TIME[] PROGMEM = "{s}%s " D_NEOPOOL_TIME "{m}%s" "{e}"; +const char HTTP_SNS_NEOPOOL_PH[] PROGMEM = "{s}%s " D_PH "{m}" NEOPOOL_FMT_PH " " " %s " "{e}"; +const char HTTP_SNS_NEOPOOL_REDOX[] PROGMEM = "{s}%s " D_NEOPOOL_REDOX "{m}" NEOPOOL_FMT_RX " " D_UNIT_MILLIVOLT "{e}"; +const char HTTP_SNS_NEOPOOL_PPM_CHLORINE[] PROGMEM = "{s}%s " D_NEOPOOL_CHLORINE "{m}" NEOPOOL_FMT_CL " " D_UNIT_PARTS_PER_MILLION "{e}"; +const char HTTP_SNS_NEOPOOL_CONDUCTIVITY[] PROGMEM = "{s}%s " D_NEOPOOL_CONDUCTIVITY "{m}" NEOPOOL_FMT_CD " " D_UNIT_PERCENT "{e}"; +const char HTTP_SNS_NEOPOOL_IONIZATION[] PROGMEM = "{s}%s " D_NEOPOOL_IONIZATION "{m}" NEOPOOL_FMT_ION " " "%s%s" "{e}"; +const char HTTP_SNS_NEOPOOL_HYDROLYSIS[] PROGMEM = "{s}%s " D_NEOPOOL_HYDROLYSIS "{m}" NEOPOOL_FMT_HIDRO " " D_UNIT_PERCENT HTTP_SNS_NEOPOOL_FLAGS "{e}"; +const char HTTP_SNS_NEOPOOL_FILT_MODE[] PROGMEM = "{s}%s " D_NEOPOOL_FILT_MODE "{m}%s" "{e}"; +const char HTTP_SNS_NEOPOOL_RELAY[] PROGMEM = "{s}%s " D_NEOPOOL_RELAY " %d %s" "{m}%s" "{e}"; + +/*********************************************************************************************\ + * Commands + * + * NPFiltration {} + * get/set manual filtration (state=0|1) + * get filtration state if is omitted, otherwise set new state + * + * NPFiltrationMode {} + * get/set filtration mode (mode=0..4|13) + * get mode if is omitted, otherwise set new mode + * + * NPTime {