Limit relays to physical count

This commit is contained in:
Norbert Richter 2022-03-01 10:27:00 +01:00
parent 9636e67af7
commit 4fd592b21b
No known key found for this signature in database
GPG Key ID: 6628701A626FA674

View File

@ -555,6 +555,8 @@ enum NeoPoolConstAndBitMask {
#include <TasmotaModbus.h> #include <TasmotaModbus.h>
TasmotaModbus *NeoPoolModbus; TasmotaModbus *NeoPoolModbus;
#define NEOPOOL_RELAY_MAX 7 // Number of relais build-in
enum NeoPoolResult { enum NeoPoolResult {
NEOPOOL_RESULT_DEC = false, NEOPOOL_RESULT_DEC = false,
NEOPOOL_RESULT_HEX, NEOPOOL_RESULT_HEX,
@ -1445,7 +1447,7 @@ void NeoPoolShow(bool json)
// Relays // Relays
ResponseAppend_P(PSTR(",\"" D_NEOPOOL_JSON_RELAY "\":{\"" D_NEOPOOL_JSON_STATE "\":[")); ResponseAppend_P(PSTR(",\"" D_NEOPOOL_JSON_RELAY "\":{\"" D_NEOPOOL_JSON_STATE "\":["));
for(uint16_t i = 0; i < 8; i++) { for(uint16_t i = 0; i < NEOPOOL_RELAY_MAX; i++) {
ResponseAppend_P(PSTR("%s%d"), i ? PSTR(",") : PSTR(""), (NeoPoolGetData(MBF_RELAY_STATE) >> i) & 1); ResponseAppend_P(PSTR("%s%d"), i ? PSTR(",") : PSTR(""), (NeoPoolGetData(MBF_RELAY_STATE) >> i) & 1);
} }
ResponseAppend_P(PSTR("]")); ResponseAppend_P(PSTR("]"));
@ -1636,7 +1638,7 @@ void NeoPoolShow(bool json)
WSContentSend_PD(HTTP_SNS_NEOPOOL_FILT_MODE, neopool_type, stemp); WSContentSend_PD(HTTP_SNS_NEOPOOL_FILT_MODE, neopool_type, stemp);
// Relays // Relays
for (uint32_t i = 0; i < 8; i++) { for (uint32_t i = 0; i < NEOPOOL_RELAY_MAX; i++) {
char sdesc[24]; char sdesc[24];
memset(sdesc, 0, nitems(sdesc)); memset(sdesc, 0, nitems(sdesc));
memset(stemp, 0, nitems(stemp)); memset(stemp, 0, nitems(stemp));
@ -1982,7 +1984,7 @@ void CmndNeopoolLight(void)
NeopoolResponseError(); NeopoolResponseError();
return; return;
} }
if (neopool_light_relay >= 1 && neopool_light_relay <= 8) { if (neopool_light_relay >= 1 && neopool_light_relay <= NEOPOOL_RELAY_MAX) {
// get/set light // get/set light
if (1 == params_cnt && XdrvMailbox.payload >= 0 && XdrvMailbox.payload < nitems(timer_val)) { if (1 == params_cnt && XdrvMailbox.payload >= 0 && XdrvMailbox.payload < nitems(timer_val)) {
if (POWER_TOGGLE == timer_val[XdrvMailbox.payload]) { if (POWER_TOGGLE == timer_val[XdrvMailbox.payload]) {