From b5ce17112f7beef03d04fcb6f6da9c3dd939eba1 Mon Sep 17 00:00:00 2001 From: Thomas Hargrove Date: Wed, 9 Nov 2022 15:33:16 -0800 Subject: [PATCH] Fix for error on first command sent to S8 module --- .../tasmota_xsns_sensor/xsns_17_senseair.ino | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tasmota/tasmota_xsns_sensor/xsns_17_senseair.ino b/tasmota/tasmota_xsns_sensor/xsns_17_senseair.ino index ea6ba683b..de7d5a89b 100644 --- a/tasmota/tasmota_xsns_sensor/xsns_17_senseair.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_17_senseair.ino @@ -70,7 +70,7 @@ void Senseair250ms(void) // Every 250 mSec if (data_ready) { uint8_t error = SenseairModbus->Receive16BitRegister(&value); if (error) { - AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir response error %d"), error); + AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir read register %02X gave response error %d"), (uint16_t)start_addresses[senseair_read_state], error); } else { switch(senseair_read_state) { case 0: // 0x1A (26) READ_TYPE_LOW - S8: fe 04 02 01 77 ec 92 @@ -104,15 +104,16 @@ void Senseair250ms(void) // Every 250 mSec AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir temp adjustment %d"), value); break; } - } - senseair_read_state++; - if (2 == senseair_type) { // S8 - if (3 == senseair_read_state) { - senseair_read_state = 1; - } - } else { // K30, K70 - if (sizeof(start_addresses) == senseair_read_state) { - senseair_read_state = 1; + + senseair_read_state++; + if (2 == senseair_type) { // S8 + if (3 == senseair_read_state) { + senseair_read_state = 1; + } + } else { // K30, K70 + if (sizeof(start_addresses) == senseair_read_state) { + senseair_read_state = 1; + } } } }