From a39bb7b92f685e99343a2f99bc69fb293b5c4644 Mon Sep 17 00:00:00 2001 From: SenexCrenshaw <35600301+SenexCrenshaw@users.noreply.github.com> Date: Thu, 8 Apr 2021 11:06:54 -0400 Subject: [PATCH] Support custom build_flags for bme680_bsec (#1678) --- esphome/components/bme680_bsec/__init__.py | 2 +- esphome/components/bme680_bsec/bme680_bsec.cpp | 8 +++----- esphome/components/bme680_bsec/bme680_bsec.h | 12 +++++++----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/esphome/components/bme680_bsec/__init__.py b/esphome/components/bme680_bsec/__init__.py index f5028a90a3..8286029c3b 100644 --- a/esphome/components/bme680_bsec/__init__.py +++ b/esphome/components/bme680_bsec/__init__.py @@ -60,5 +60,5 @@ def to_code(config): var.set_state_save_interval(config[CONF_STATE_SAVE_INTERVAL].total_milliseconds) ) - cg.add_build_flag("-DUSING_BSEC") + cg.add_define("USING_BSEC") cg.add_library("BSEC Software Library", "1.6.1480") diff --git a/esphome/components/bme680_bsec/bme680_bsec.cpp b/esphome/components/bme680_bsec/bme680_bsec.cpp index 0efe4083ef..a463ff78c4 100644 --- a/esphome/components/bme680_bsec/bme680_bsec.cpp +++ b/esphome/components/bme680_bsec/bme680_bsec.cpp @@ -1,4 +1,4 @@ -#ifdef USING_BSEC + #include "bme680_bsec.h" #include "esphome/core/log.h" @@ -7,7 +7,7 @@ namespace esphome { namespace bme680_bsec { - +#ifdef USING_BSEC static const char *TAG = "bme680_bsec.sensor"; static const std::string IAQ_ACCURACY_STATES[4] = {"Stabilizing", "Uncertain", "Calibrating", "Calibrated"}; @@ -391,8 +391,6 @@ void BME680BSECComponent::save_state_(uint8_t accuracy) { ESP_LOGI(TAG, "Saved state"); } - +#endif } // namespace bme680_bsec } // namespace esphome - -#endif diff --git a/esphome/components/bme680_bsec/bme680_bsec.h b/esphome/components/bme680_bsec/bme680_bsec.h index ce35e21c9a..4a71e1d23b 100644 --- a/esphome/components/bme680_bsec/bme680_bsec.h +++ b/esphome/components/bme680_bsec/bme680_bsec.h @@ -1,4 +1,4 @@ -#ifdef USING_BSEC + #pragma once @@ -7,11 +7,15 @@ #include "esphome/components/text_sensor/text_sensor.h" #include "esphome/components/i2c/i2c.h" #include "esphome/core/preferences.h" -#include #include +#ifdef USING_BSEC +#include +#endif + namespace esphome { namespace bme680_bsec { +#ifdef USING_BSEC enum IAQMode { IAQ_MODE_STATIC = 0, @@ -99,8 +103,6 @@ class BME680BSECComponent : public Component, public i2c::I2CDevice { sensor::Sensor *co2_equivalent_sensor_; sensor::Sensor *breath_voc_equivalent_sensor_; }; - +#endif } // namespace bme680_bsec } // namespace esphome - -#endif