mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
Fix MQTT discovery for sensor state_class (#2331)
This commit is contained in:
parent
2e49039c01
commit
64341d1d18
2 changed files with 6 additions and 6 deletions
|
@ -6,15 +6,15 @@ namespace sensor {
|
||||||
|
|
||||||
static const char *const TAG = "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) {
|
switch (state_class) {
|
||||||
case STATE_CLASS_MEASUREMENT:
|
case STATE_CLASS_MEASUREMENT:
|
||||||
return LOG_STR("measurement");
|
return "measurement";
|
||||||
case STATE_CLASS_TOTAL_INCREASING:
|
case STATE_CLASS_TOTAL_INCREASING:
|
||||||
return LOG_STR("total_increasing");
|
return "total_increasing";
|
||||||
case STATE_CLASS_NONE:
|
case STATE_CLASS_NONE:
|
||||||
default:
|
default:
|
||||||
return LOG_STR("");
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace sensor {
|
||||||
if (!(obj)->get_device_class().empty()) { \
|
if (!(obj)->get_device_class().empty()) { \
|
||||||
ESP_LOGCONFIG(TAG, "%s Device Class: '%s'", prefix, (obj)->get_device_class().c_str()); \
|
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 Unit of Measurement: '%s'", prefix, (obj)->get_unit_of_measurement().c_str()); \
|
||||||
ESP_LOGCONFIG(TAG, "%s Accuracy Decimals: %d", prefix, (obj)->get_accuracy_decimals()); \
|
ESP_LOGCONFIG(TAG, "%s Accuracy Decimals: %d", prefix, (obj)->get_accuracy_decimals()); \
|
||||||
if (!(obj)->get_icon().empty()) { \
|
if (!(obj)->get_icon().empty()) { \
|
||||||
|
@ -37,7 +37,7 @@ enum StateClass : uint8_t {
|
||||||
STATE_CLASS_TOTAL_INCREASING = 2,
|
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.
|
/** Base-class for all sensors.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue