From 7dcf19c59fe2e82aeecbbf2e1f8b80cc797d0048 Mon Sep 17 00:00:00 2001 From: proddy Date: Fri, 3 May 2019 18:42:53 +0200 Subject: [PATCH] SM100 changes --- src/ems-esp.cpp | 8 ++++---- src/ems.cpp | 12 ++++++------ src/my_config.h | 2 +- src/test_data.h | 4 +++- src/version.h | 2 +- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/ems-esp.cpp b/src/ems-esp.cpp index e1af1e483..0f2749bd4 100644 --- a/src/ems-esp.cpp +++ b/src/ems-esp.cpp @@ -729,18 +729,18 @@ void publishValues(bool force) { doc.clear(); JsonObject rootSM = doc.to(); - rootSM[SM_COLLECTORTEMP] = _short_to_char(s, EMS_Other.SMcollectorTemp); - rootSM[SM_BOTTOMTEMP] = _short_to_char(s, EMS_Other.SMbottomTemp); - if (abs(EMS_Other.SMcollectorTemp) < EMS_VALUE_SHORT_NOTSET) rootSM[SM_COLLECTORTEMP] = (double)EMS_Other.SMcollectorTemp / 10; + if (abs(EMS_Other.SMbottomTemp) < EMS_VALUE_SHORT_NOTSET) rootSM[SM_BOTTOMTEMP] = (double)EMS_Other.SMbottomTemp / 10; if (EMS_Other.SMpumpModulation != EMS_VALUE_INT_NOTSET) rootSM[SM_PUMPMODULATION] = EMS_Other.SMpumpModulation; - rootSM[SM_PUMP] = _bool_to_char(s, EMS_Other.SMpump); + if (EMS_Other.SMpump != EMS_VALUE_INT_NOTSET) { + rootSM[SM_PUMP] = _bool_to_char(s, EMS_Other.SMpump); + } if (abs(EMS_Other.SMEnergyLastHour) < EMS_VALUE_SHORT_NOTSET) rootSM[SM_ENERGYLASTHOUR] = (double)EMS_Other.SMEnergyLastHour / 10; diff --git a/src/ems.cpp b/src/ems.cpp index 8fbdf0105..2a84f5728 100644 --- a/src/ems.cpp +++ b/src/ems.cpp @@ -709,7 +709,7 @@ void _ems_readTelegram(uint8_t * telegram, uint8_t length) { return; } - // fill in the rest of the Telegram + // fill in the rest of the telegram EMS_RxTelegram.src = telegram[0] & 0x7F; // removing 8th bit as we deal with both reads and writes here EMS_RxTelegram.dest = telegram[1] & 0x7F; // remove 8th bit (don't care if read or write) EMS_RxTelegram.offset = telegram[3]; // offset is always 4th byte @@ -1323,12 +1323,12 @@ void _process_SM10Monitor(_EMS_RxTelegram * EMS_RxTelegram) { * SM100Monitor - type 0x0262 EMS+ */ void _process_SM100Monitor(_EMS_RxTelegram * EMS_RxTelegram) { - if (EMS_RxTelegram->data_length <= 2) { - EMS_Other.SMcollectorTemp = _toShort(0); // collector temp from SM100, is *10 - } - if (EMS_RxTelegram->data_length > 2) { - EMS_Other.SMbottomTemp = _toShort(2); // bottom temp from SM100, is *10 + EMS_Other.SMcollectorTemp = _toShort(0); // collector temp from SM100, is *10 + EMS_Other.SMbottomTemp = _toShort(2); // bottom temp from SM100, is *10 + } else { + // only one value sent, assume its the collector temp + EMS_Other.SMcollectorTemp = _toShort(0); // collector temp from SM100, is *10 } EMS_Other.SM = true; diff --git a/src/my_config.h b/src/my_config.h index 7b507b8b7..b2713a2a0 100644 --- a/src/my_config.h +++ b/src/my_config.h @@ -50,7 +50,7 @@ // MQTT for SM10/SM100 Solar Module #define TOPIC_SM_DATA "sm_data" // topic name -#define SM_COLLECTORTEMP "temp" // collector temp +#define SM_COLLECTORTEMP "collectortemp" // collector temp #define SM_BOTTOMTEMP "bottomtemp" // bottom temp #define SM_PUMPMODULATION "pumpmodulation" // pump modulation #define SM_PUMP "pump" // pump active diff --git a/src/test_data.h b/src/test_data.h index 5390976d9..532487099 100644 --- a/src/test_data.h +++ b/src/test_data.h @@ -40,7 +40,9 @@ static const char * TEST_DATA[] = { "10 48 F9 00 FF 01 6C 08 4F 00 00 00 02 00 00 00 02 00 03 00 03 00 03 00 02", // test 35 - F9 "48 90 F9 00 11 FF 01 6D 08", // test 36 - F9 "10 48 F9 00 FF 01 6D 08", // test 37 - F9 - "10 00 F7 00 FF 01 B9 35 19" // test 38 - F7 + "10 00 F7 00 FF 01 B9 35 19", // test 38 - F7 + "30 00 FF 00 02 62 00 E7 01 AE 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00", // test 39 - SM100 + "30 00 FF 00 02 62 00 E4" // test 40 - SM100 }; diff --git a/src/version.h b/src/version.h index 479be1694..c52568742 100644 --- a/src/version.h +++ b/src/version.h @@ -6,5 +6,5 @@ #pragma once #define APP_NAME "EMS-ESP" -#define APP_VERSION "1.7.0b12" +#define APP_VERSION "1.7.0b13" #define APP_HOSTNAME "ems-esp"