exxamalte / esphome-customisations

ESPHome customisations.
Apache License 2.0
20 stars 8 forks source link

VEML6075 sensor: sensor.h:14:19: error: 'TAG' was not declared in this scope #3

Closed exxamalte closed 2 years ago

exxamalte commented 2 years ago

When using just the VEML6075 custom code on its own, compiling the code fails with the following error:

In file included from src/esphome/components/sensor/sensor.h:3:0,
                 from src/esphome/core/application.h:15,
                 from src/esphome/components/api/api_connection.h:4,
                 from src/esphome.h:2,
                 from src/main.cpp:3:
src/veml6075_sensor.h: In member function 'virtual void VEML6075Sensor::setup()':
src/esphome/components/sensor/sensor.h:14:19: error: 'TAG' was not declared in this scope
     ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
                   ^
src/esphome/core/log.h:97:45: note: in definition of macro 'esph_log_config'
   esp_log_printf_(ESPHOME_LOG_LEVEL_CONFIG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__)
                                             ^
src/esphome/components/sensor/sensor.h:14:5: note: in expansion of macro 'ESP_LOGCONFIG'
     ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
     ^
src/veml6075_sensor.h:21:7: note: in expansion of macro 'LOG_SENSOR'
       LOG_SENSOR("  ", "UVA", this->uva_sensor);
       ^
src/esphome/components/sensor/sensor.h:14:19: error: 'TAG' was not declared in this scope
     ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
                   ^
src/esphome/core/log.h:97:45: note: in definition of macro 'esph_log_config'
   esp_log_printf_(ESPHOME_LOG_LEVEL_CONFIG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__)
                                             ^
src/esphome/components/sensor/sensor.h:14:5: note: in expansion of macro 'ESP_LOGCONFIG'
     ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
     ^
src/veml6075_sensor.h:22:7: note: in expansion of macro 'LOG_SENSOR'
       LOG_SENSOR("  ", "UVB", this->uvb_sensor);
       ^
src/esphome/components/sensor/sensor.h:14:19: error: 'TAG' was not declared in this scope
     ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
                   ^
src/esphome/core/log.h:97:45: note: in definition of macro 'esph_log_config'
   esp_log_printf_(ESPHOME_LOG_LEVEL_CONFIG, tag, __LINE__, ESPHOME_LOG_FORMAT(format), ##__VA_ARGS__)
                                             ^
src/esphome/components/sensor/sensor.h:14:5: note: in expansion of macro 'ESP_LOGCONFIG'
     ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, LOG_STR_LITERAL(type), (obj)->get_name().c_str()); \
     ^
src/veml6075_sensor.h:23:7: note: in expansion of macro 'LOG_SENSOR'
       LOG_SENSOR("  ", "UVI", this->uvi_sensor);
       ^
Compiling .pioenvs/esp_weather_station/lib0eb/WiFi/WiFiSTA.cpp.o
*** [.pioenvs/esp_weather_station/src/main.cpp.o] Error 1

The reason for this is that the component itself does not define TAG due to conflicts with other custom components. However, when used on its own, the TAG definition is missing.