Fix MQTT discovery for sensor state_class (#2331)

This commit is contained in:
Paul Monigatti 2021-09-20 04:30:41 +12:00 committed by GitHub
parent 2e49039c01
commit 64341d1d18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View file

@ -6,15 +6,15 @@ namespace sensor {
static const char *const TAG = "sensor";
const LogString *state_class_to_string(StateClass state_class) {
std::string state_class_to_string(StateClass state_class) {
switch (state_class) {
case STATE_CLASS_MEASUREMENT:
return LOG_STR("measurement");
return "measurement";
case STATE_CLASS_TOTAL_INCREASING:
return LOG_STR("total_increasing");
return "total_increasing";
case STATE_CLASS_NONE:
default:
return LOG_STR("");
return "";
}
}

View file

@ -14,7 +14,7 @@ namespace sensor {
if (!(obj)->get_device_class().empty()) { \
ESP_LOGCONFIG(TAG, "%s Device Class: '%s'", prefix, (obj)->get_device_class().c_str()); \
} \
ESP_LOGCONFIG(TAG, "%s State Class: '%s'", prefix, LOG_STR_ARG(state_class_to_string((obj)->get_state_class()))); \
ESP_LOGCONFIG(TAG, "%s State Class: '%s'", prefix, state_class_to_string((obj)->get_state_class()).c_str()); \
ESP_LOGCONFIG(TAG, "%s Unit of Measurement: '%s'", prefix, (obj)->get_unit_of_measurement().c_str()); \
ESP_LOGCONFIG(TAG, "%s Accuracy Decimals: %d", prefix, (obj)->get_accuracy_decimals()); \
if (!(obj)->get_icon().empty()) { \
@ -37,7 +37,7 @@ enum StateClass : uint8_t {
STATE_CLASS_TOTAL_INCREASING = 2,
};
const LogString *state_class_to_string(StateClass state_class);
std::string state_class_to_string(StateClass state_class);
/** Base-class for all sensors.
*