diff --git a/sonoff/i18n.h b/sonoff/i18n.h index 766a2cd7e..58e1ba63d 100644 --- a/sonoff/i18n.h +++ b/sonoff/i18n.h @@ -517,7 +517,7 @@ const char S_JSON_DRIVER_INDEX_SVALUE[] PROGMEM = "{\"" D_CMND_DRIVE const char JSON_SNS_TEMP[] PROGMEM = ",\"%s\":{\"" D_JSON_TEMPERATURE "\":%s}"; const char JSON_SNS_TEMPHUM[] PROGMEM = ",\"%s\":{\"" D_JSON_TEMPERATURE "\":%s,\"" D_JSON_HUMIDITY "\":%s}"; -const char JSON_SNS_GNGPM[] PROGMEM = "%s,\"%s\":{\"" D_JSON_TOTAL_USAGE "\":%s,\"" D_JSON_FLOWRATE "\":%s}"; +const char JSON_SNS_GNGPM[] PROGMEM = ",\"%s\":{\"" D_JSON_TOTAL_USAGE "\":%s,\"" D_JSON_FLOWRATE "\":%s}"; const char S_LOG_I2C_FOUND_AT[] PROGMEM = D_LOG_I2C "%s " D_FOUND_AT " 0x%x"; diff --git a/sonoff/language/en-GB.h b/sonoff/language/en-GB.h index e8ba8f3fb..c1ee1ed5c 100644 --- a/sonoff/language/en-GB.h +++ b/sonoff/language/en-GB.h @@ -494,6 +494,9 @@ #define D_TX20_SOUTH "S" #define D_TX20_WEST "W" +//xsns_91_hre.ino +#define D_LOG_HRE "HRE: " + // sonoff_template.h - keep them as short as possible to be able to fit them in GUI drop down box #define D_SENSOR_NONE "None" #define D_SENSOR_USER "User" diff --git a/sonoff/xsns_91_hre.ino b/sonoff/xsns_91_hre.ino index d3410556b..c73d94338 100644 --- a/sonoff/xsns_91_hre.ino +++ b/sonoff/xsns_91_hre.ino @@ -131,7 +131,6 @@ void hreEvery50ms(void) static int read_counter = 0; // number of bytes in the current read static int parity_errors = 0; // Number of parity errors in current read static char buff[46]; // 8 char and a term - static char aux[46]; // 8 char and a term static char ch; static size_t i; @@ -144,8 +143,7 @@ void hreEvery50ms(void) sync_run = 0; sync_counter = 0; hre_state = hre_syncing; - snprintf_P(log_data, sizeof(log_data), PSTR("HRE: state:syncing")); - AddLog(LOG_LEVEL_DEBUG); + AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_syncing")); break; case hre_syncing: @@ -169,40 +167,34 @@ void hreEvery50ms(void) if (sync_counter > 1000) { hre_state = hre_sleep; - snprintf_P(log_data, sizeof(log_data), PSTR("HRE: sync error")); - AddLog(LOG_LEVEL_DEBUG); + AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE D_ERROR)); } break; // Start reading the data block case hre_read: - snprintf_P(log_data, sizeof(log_data), PSTR("HRE: sync_run:%d, sync_counter:%d"), sync_run, sync_counter); - AddLog(LOG_LEVEL_DEBUG); + AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE " sync_run:%d, sync_counter:%d"), sync_run, sync_counter); read_counter = 0; parity_errors = 0; curr_start = uptime; memset(buff, 0, sizeof(buff)); hre_state = hre_reading; - snprintf_P(log_data, sizeof(log_data), PSTR("HRE: state:reading")); - AddLog(LOG_LEVEL_DEBUG); + AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HRE "hre_state:hre_reading")); // So this is intended to fall through to the hre_reading section. // it seems that if there is much of a delay between getting the sync // bits and starting the read, the HRE won't output the message we // are looking for... case hre_reading: - //ch = hreReadChar(parity_errors); - //i = read_counter - 24; // The water usage reading starts 24 bytes into the block - //if (i>=0 && i 27) @@ -243,8 +233,8 @@ void hreShow(boolean json) { if (!hre_good) return; - - const char hre_types[] = "HRE"; + + const char *id = "HRE"; char usage[33]; char rate[33]; @@ -253,13 +243,13 @@ void hreShow(boolean json) if (json) { - snprintf_P(mqtt_data, sizeof(mqtt_data), JSON_SNS_GNGPM, mqtt_data, hre_types, usage, rate); + ResponseAppend_P(JSON_SNS_GNGPM, id, usage, rate); #ifdef USE_WEBSERVER } else { - snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_GALLONS, mqtt_data, hre_types, usage); - snprintf_P(mqtt_data, sizeof(mqtt_data), HTTP_SNS_GPM, mqtt_data, hre_types, rate); + WSContentSend_PD(HTTP_SNS_GALLONS, id, usage); + WSContentSend_PD(HTTP_SNS_GPM, id, rate); #endif // USE_WEBSERVER } }