mirror of
https://github.com/esphome/esphome.git
synced 2025-10-26 20:53:50 +00:00
[sensor] Convert LOG_SENSOR macro to function to reduce flash usage (#10290)
This commit is contained in:
@@ -12,26 +12,9 @@
|
||||
namespace esphome {
|
||||
namespace sensor {
|
||||
|
||||
#define LOG_SENSOR(prefix, type, obj) \
|
||||
if ((obj) != nullptr) { \
|
||||
ESP_LOGCONFIG(TAG, \
|
||||
"%s%s '%s'\n" \
|
||||
"%s State Class: '%s'\n" \
|
||||
"%s Unit of Measurement: '%s'\n" \
|
||||
"%s Accuracy Decimals: %d", \
|
||||
prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str(), prefix, \
|
||||
state_class_to_string((obj)->get_state_class()).c_str(), prefix, \
|
||||
(obj)->get_unit_of_measurement().c_str(), prefix, (obj)->get_accuracy_decimals()); \
|
||||
if (!(obj)->get_device_class().empty()) { \
|
||||
ESP_LOGCONFIG(TAG, "%s Device Class: '%s'", prefix, (obj)->get_device_class().c_str()); \
|
||||
} \
|
||||
if (!(obj)->get_icon().empty()) { \
|
||||
ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, (obj)->get_icon().c_str()); \
|
||||
} \
|
||||
if ((obj)->get_force_update()) { \
|
||||
ESP_LOGV(TAG, "%s Force Update: YES", prefix); \
|
||||
} \
|
||||
}
|
||||
void log_sensor(const char *tag, const char *prefix, const char *type, Sensor *obj);
|
||||
|
||||
#define LOG_SENSOR(prefix, type, obj) log_sensor(TAG, prefix, LOG_STR_LITERAL(type), obj)
|
||||
|
||||
#define SUB_SENSOR(name) \
|
||||
protected: \
|
||||
|
||||
Reference in New Issue
Block a user