From 84b9c9fb69dcd5f65e0d4bf51ab439bba915f042 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 19 Mar 2026 10:26:21 -1000 Subject: [PATCH] [mhz19] Fix unused function warning for detection_range_to_log_string Guard detection_range_to_log_string() with #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG so it is compiled out when the log level is below DEBUG, matching its callers (ESP_LOGD and ESP_LOGCONFIG) which are also compiled out at that level. Fixes https://github.com/esphome/esphome/issues/14975 --- esphome/components/mhz19/mhz19.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/esphome/components/mhz19/mhz19.cpp b/esphome/components/mhz19/mhz19.cpp index bccea7d423a..ff518808d9e 100644 --- a/esphome/components/mhz19/mhz19.cpp +++ b/esphome/components/mhz19/mhz19.cpp @@ -16,6 +16,7 @@ static const uint8_t MHZ19_COMMAND_DETECTION_RANGE_0_2000PPM[] = {0xFF, 0x01, 0x static const uint8_t MHZ19_COMMAND_DETECTION_RANGE_0_5000PPM[] = {0xFF, 0x01, 0x99, 0x00, 0x00, 0x00, 0x13, 0x88}; static const uint8_t MHZ19_COMMAND_DETECTION_RANGE_0_10000PPM[] = {0xFF, 0x01, 0x99, 0x00, 0x00, 0x00, 0x27, 0x10}; +#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG static const LogString *detection_range_to_log_string(MHZ19DetectionRange range) { switch (range) { case MHZ19_DETECTION_RANGE_0_2000PPM: @@ -28,6 +29,7 @@ static const LogString *detection_range_to_log_string(MHZ19DetectionRange range) return LOG_STR("default"); } } +#endif uint8_t mhz19_checksum(const uint8_t *command) { uint8_t sum = 0;