mirror of
https://github.com/esphome/esphome.git
synced 2025-11-20 08:46:01 +00:00
[sensor] ESP8266: Use LogString for state_class_to_string() to save RAM (#10617)
This commit is contained in:
@@ -17,7 +17,8 @@ void log_sensor(const char *tag, const char *prefix, const char *type, Sensor *o
|
||||
"%s State Class: '%s'\n"
|
||||
"%s Unit of Measurement: '%s'\n"
|
||||
"%s Accuracy Decimals: %d",
|
||||
prefix, type, obj->get_name().c_str(), prefix, state_class_to_string(obj->get_state_class()), prefix,
|
||||
prefix, type, obj->get_name().c_str(), prefix,
|
||||
LOG_STR_ARG(state_class_to_string(obj->get_state_class())), prefix,
|
||||
obj->get_unit_of_measurement_ref().c_str(), prefix, obj->get_accuracy_decimals());
|
||||
|
||||
if (!obj->get_device_class_ref().empty()) {
|
||||
@@ -33,17 +34,17 @@ void log_sensor(const char *tag, const char *prefix, const char *type, Sensor *o
|
||||
}
|
||||
}
|
||||
|
||||
const char *state_class_to_string(StateClass state_class) {
|
||||
const LogString *state_class_to_string(StateClass state_class) {
|
||||
switch (state_class) {
|
||||
case STATE_CLASS_MEASUREMENT:
|
||||
return "measurement";
|
||||
return LOG_STR("measurement");
|
||||
case STATE_CLASS_TOTAL_INCREASING:
|
||||
return "total_increasing";
|
||||
return LOG_STR("total_increasing");
|
||||
case STATE_CLASS_TOTAL:
|
||||
return "total";
|
||||
return LOG_STR("total");
|
||||
case STATE_CLASS_NONE:
|
||||
default:
|
||||
return "";
|
||||
return LOG_STR("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user