diff --git a/src/src/Helpers/StringConverter_Numerical.cpp b/src/src/Helpers/StringConverter_Numerical.cpp index 99e6412ecb..cbcf4d4b76 100644 --- a/src/src/Helpers/StringConverter_Numerical.cpp +++ b/src/src/Helpers/StringConverter_Numerical.cpp @@ -116,6 +116,17 @@ String trimTrailingZeros(const String& value) { } +/** + * Helper: Convert an integer to string, but return an empty string for 0, to save a little space in settings + */ +String toStringNoZero(int64_t value) { + if (value != 0) { + return toString(value, 0); + } else { + return EMPTY_STRING; + } +} + #if FEATURE_USE_DOUBLE_AS_ESPEASY_RULES_FLOAT_TYPE String doubleToString(const double& value, unsigned int decimalPlaces, bool trimTrailingZeros_b) { // This has been fixed in ESP32 code, not (yet) in ESP8266 code diff --git a/src/src/Helpers/StringConverter_Numerical.h b/src/src/Helpers/StringConverter_Numerical.h index f2a20bea0a..5e993e2531 100644 --- a/src/src/Helpers/StringConverter_Numerical.h +++ b/src/src/Helpers/StringConverter_Numerical.h @@ -30,6 +30,8 @@ String ll2String(int64_t value, String trimTrailingZeros(const String& value); +String toStringNoZero(int64_t value); + #if FEATURE_USE_DOUBLE_AS_ESPEASY_RULES_FLOAT_TYPE String doubleToString(const double& value, unsigned int decimalPlaces = 2,