mirror of
https://github.com/esphome/esphome.git
synced 2025-07-28 14:16:40 +00:00
Streamline setup() logging (g, h, i) (#8927)
This commit is contained in:
parent
18653f8f69
commit
0ce03ae26b
@ -14,7 +14,7 @@ namespace gcja5 {
|
||||
|
||||
static const char *const TAG = "gcja5";
|
||||
|
||||
void GCJA5Component::setup() { ESP_LOGCONFIG(TAG, "Setting up gcja5..."); }
|
||||
void GCJA5Component::setup() { ESP_LOGCONFIG(TAG, "Running setup"); }
|
||||
|
||||
void GCJA5Component::loop() {
|
||||
const uint32_t now = App.get_loop_component_start_time();
|
||||
|
@ -34,7 +34,7 @@ void GDK101Component::update() {
|
||||
|
||||
void GDK101Component::setup() {
|
||||
uint8_t data[2];
|
||||
ESP_LOGCONFIG(TAG, "Setting up GDK101...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
// first, reset the sensor
|
||||
if (!this->reset_sensor_(data)) {
|
||||
this->status_set_error("Reset failed!");
|
||||
|
@ -8,7 +8,7 @@ namespace gpio {
|
||||
static const char *const TAG = "gpio.one_wire";
|
||||
|
||||
void GPIOOneWireBus::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up 1-wire bus...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
this->t_pin_->setup();
|
||||
this->t_pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP);
|
||||
// clear bus with 480µs high, otherwise initial reset in search might fail
|
||||
|
@ -8,7 +8,7 @@ static const char *const TAG = "switch.gpio";
|
||||
|
||||
float GPIOSwitch::get_setup_priority() const { return setup_priority::HARDWARE; }
|
||||
void GPIOSwitch::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up GPIO Switch '%s'...", this->name_.c_str());
|
||||
ESP_LOGCONFIG(TAG, "Running setup for '%s'", this->name_.c_str());
|
||||
|
||||
bool initial_state = this->get_initial_state_with_restore_mode().value_or(false);
|
||||
|
||||
|
@ -33,8 +33,7 @@ bool GroveGasMultichannelV2Component::read_sensor_(uint8_t address, sensor::Sens
|
||||
}
|
||||
|
||||
void GroveGasMultichannelV2Component::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up Grove Multichannel Gas Sensor V2...");
|
||||
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
// Before reading sensor values, must preheat sensor
|
||||
if (!(this->write_bytes(GROVE_GAS_MC_V2_HEAT_ON, {}))) {
|
||||
this->mark_failed();
|
||||
|
@ -24,7 +24,7 @@ void GroveMotorDriveTB6612FNG::dump_config() {
|
||||
}
|
||||
|
||||
void GroveMotorDriveTB6612FNG::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up Grove Motor Drive TB6612FNG ...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
if (!this->standby()) {
|
||||
this->mark_failed();
|
||||
return;
|
||||
|
@ -25,7 +25,7 @@ static const size_t MAX_BUTTONS = 4; // max number of buttons scanned
|
||||
|
||||
void GT911Touchscreen::setup() {
|
||||
i2c::ErrorCode err;
|
||||
ESP_LOGCONFIG(TAG, "Setting up GT911 Touchscreen...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
if (this->reset_pin_ != nullptr) {
|
||||
this->reset_pin_->setup();
|
||||
this->reset_pin_->digital_write(false);
|
||||
|
@ -10,7 +10,7 @@ static const char *const TAG = "switch.hbridge";
|
||||
|
||||
float HBridgeSwitch::get_setup_priority() const { return setup_priority::HARDWARE; }
|
||||
void HBridgeSwitch::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up H-Bridge Switch '%s'...", this->name_.c_str());
|
||||
ESP_LOGCONFIG(TAG, "Running setup for '%s'", this->name_.c_str());
|
||||
|
||||
optional<bool> initial_state = this->get_initial_state_with_restore_mode();
|
||||
|
||||
|
@ -13,7 +13,7 @@ static const uint8_t HDC1080_CMD_TEMPERATURE = 0x00;
|
||||
static const uint8_t HDC1080_CMD_HUMIDITY = 0x01;
|
||||
|
||||
void HDC1080Component::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up HDC1080...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
const uint8_t data[2] = {
|
||||
0b00000000, // resolution 14bit for both humidity and temperature
|
||||
|
@ -11,7 +11,7 @@ static const uint32_t HLW8012_CLOCK_FREQUENCY = 3579000;
|
||||
|
||||
void HLW8012Component::setup() {
|
||||
float reference_voltage = 0;
|
||||
ESP_LOGCONFIG(TAG, "Setting up HLW8012...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
this->sel_pin_->setup();
|
||||
this->sel_pin_->digital_write(this->current_mode_);
|
||||
this->cf_store_.pulse_counter_setup(this->cf_pin_);
|
||||
|
@ -11,7 +11,7 @@ static const uint8_t PM_2_5_VALUE_INDEX = 6;
|
||||
static const uint8_t PM_10_0_VALUE_INDEX = 7;
|
||||
|
||||
void HM3301Component::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up HM3301...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
if (i2c::ERROR_OK != this->write(&SELECT_COMM_CMD, 1)) {
|
||||
error_code_ = ERROR_COMM;
|
||||
this->mark_failed();
|
||||
|
@ -22,7 +22,7 @@ static const uint8_t HMC5883L_REGISTER_IDENTIFICATION_B = 0x0B;
|
||||
static const uint8_t HMC5883L_REGISTER_IDENTIFICATION_C = 0x0C;
|
||||
|
||||
void HMC5883LComponent::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up HMC5583L...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
uint8_t id[3];
|
||||
if (!this->read_byte(HMC5883L_REGISTER_IDENTIFICATION_A, &id[0]) ||
|
||||
!this->read_byte(HMC5883L_REGISTER_IDENTIFICATION_B, &id[1]) ||
|
||||
|
@ -7,7 +7,7 @@ namespace hte501 {
|
||||
static const char *const TAG = "hte501";
|
||||
|
||||
void HTE501Component::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up HTE501...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
uint8_t address[] = {0x70, 0x29};
|
||||
this->write(address, 2, false);
|
||||
uint8_t identification[9];
|
||||
|
@ -18,7 +18,7 @@ static const uint8_t HTU21D_READHEATER_REG_CMD = 0x11; /**< Read Heater Control
|
||||
static const uint8_t HTU21D_REG_HTRE_BIT = 0x02; /**< Control Register Heater Bit */
|
||||
|
||||
void HTU21DComponent::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up HTU21D...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
if (!this->write_bytes(HTU21D_REGISTER_RESET, nullptr, 0)) {
|
||||
this->mark_failed();
|
||||
|
@ -75,7 +75,7 @@ uint8_t compute_crc(uint32_t value) {
|
||||
* I2C.
|
||||
*/
|
||||
void HTU31DComponent::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up esphome/components/htu31d HTU31D...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
if (!this->reset_()) {
|
||||
this->mark_failed();
|
||||
|
@ -8,7 +8,7 @@ namespace hx711 {
|
||||
static const char *const TAG = "hx711";
|
||||
|
||||
void HX711Sensor::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up HX711 '%s'...", this->name_.c_str());
|
||||
ESP_LOGCONFIG(TAG, "Running setup for '%s'", this->name_.c_str());
|
||||
this->sck_pin_->setup();
|
||||
this->dout_pin_->setup();
|
||||
this->sck_pin_->digital_write(false);
|
||||
|
@ -39,7 +39,7 @@ void HydreonRGxxComponent::dump_config() {
|
||||
}
|
||||
|
||||
void HydreonRGxxComponent::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up hydreon_rgxx...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
while (this->available() != 0) {
|
||||
this->read();
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace i2c {
|
||||
static const char *const TAG = "i2c.arduino";
|
||||
|
||||
void ArduinoI2CBus::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
recover_();
|
||||
|
||||
#if defined(USE_ESP32)
|
||||
|
@ -18,7 +18,7 @@ namespace i2c {
|
||||
static const char *const TAG = "i2c.idf";
|
||||
|
||||
void IDFI2CBus::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up I2C bus...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
static i2c_port_t next_port = I2C_NUM_0;
|
||||
port_ = next_port;
|
||||
#if SOC_HP_I2C_NUM > 1
|
||||
|
@ -14,18 +14,17 @@ static const uint8_t I2S_NUM_MAX = SOC_I2S_NUM; // because IDF 5+ took this awa
|
||||
#endif
|
||||
|
||||
void I2SAudioComponent::setup() {
|
||||
static i2s_port_t next_port_num = I2S_NUM_0;
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
static i2s_port_t next_port_num = I2S_NUM_0;
|
||||
if (next_port_num >= I2S_NUM_MAX) {
|
||||
ESP_LOGE(TAG, "Too many I2S Audio components!");
|
||||
ESP_LOGE(TAG, "Too many I2S Audio components");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
|
||||
this->port_ = next_port_num;
|
||||
next_port_num = (i2s_port_t) (next_port_num + 1);
|
||||
|
||||
ESP_LOGCONFIG(TAG, "Setting up I2S Audio...");
|
||||
}
|
||||
|
||||
} // namespace i2s_audio
|
||||
|
@ -120,7 +120,7 @@ void I2SAudioMediaPlayer::set_volume_(float volume, bool publish) {
|
||||
}
|
||||
|
||||
void I2SAudioMediaPlayer::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up Audio...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
this->state = media_player::MEDIA_PLAYER_STATE_IDLE;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ enum MicrophoneEventGroupBits : uint32_t {
|
||||
};
|
||||
|
||||
void I2SAudioMicrophone::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up I2S Audio Microphone...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
#ifdef USE_I2S_LEGACY
|
||||
#if SOC_I2S_SUPPORTS_ADC
|
||||
if (this->adc_) {
|
||||
|
@ -99,7 +99,7 @@ static const std::vector<int16_t> Q15_VOLUME_SCALING_FACTORS = {
|
||||
19508, 20665, 21891, 23189, 24565, 26022, 27566, 29201, 30933, 32767};
|
||||
|
||||
void I2SAudioSpeaker::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up I2S Audio Speaker...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
this->event_group_ = xEventGroupCreate();
|
||||
|
||||
|
@ -34,7 +34,7 @@ static const uint8_t INA219_REGISTER_CURRENT = 0x04;
|
||||
static const uint8_t INA219_REGISTER_CALIBRATION = 0x05;
|
||||
|
||||
void INA219Component::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up INA219...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
// Config Register
|
||||
// 0bx000000000000000 << 15 RESET Bit (1 -> trigger reset)
|
||||
if (!this->write_byte_16(INA219_REGISTER_CONFIG, 0x8000)) {
|
||||
|
@ -37,7 +37,7 @@ static const uint16_t INA226_ADC_TIMES[] = {140, 204, 332, 588, 1100, 2116, 4156
|
||||
static const uint16_t INA226_ADC_AVG_SAMPLES[] = {1, 4, 16, 64, 128, 256, 512, 1024};
|
||||
|
||||
void INA226Component::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up INA226...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
ConfigurationRegister config;
|
||||
|
||||
|
@ -35,7 +35,7 @@ static const uint8_t INA260_REGISTER_MANUFACTURE_ID = 0xFE;
|
||||
static const uint8_t INA260_REGISTER_DEVICE_ID = 0xFF;
|
||||
|
||||
void INA260Component::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up INA260...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
// Reset device on setup
|
||||
if (!this->write_byte_16(INA260_REGISTER_CONFIG, 0x8000)) {
|
||||
|
@ -50,7 +50,7 @@ static bool check_model_and_device_match(INAModel model, uint16_t dev_id) {
|
||||
}
|
||||
|
||||
void INA2XX::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up INA2xx...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
if (!this->reset_config_()) {
|
||||
ESP_LOGE(TAG, "Reset failed, check connection");
|
||||
|
@ -22,7 +22,7 @@ static const uint8_t INA3221_REGISTER_CHANNEL3_BUS_VOLTAGE = 0x06;
|
||||
// A0 = SCL -> 0x43
|
||||
|
||||
void INA3221Component::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up INA3221...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
// Config Register
|
||||
// 0bx000000000000000 << 15 RESET Bit (1 -> trigger reset)
|
||||
if (!this->write_byte_16(INA3221_REGISTER_CONFIG, 0x8000)) {
|
||||
|
@ -66,7 +66,7 @@ void InternalTemperatureSensor::update() {
|
||||
esp_err_t result = temperature_sensor_get_celsius(tsensNew, &temperature);
|
||||
success = (result == ESP_OK);
|
||||
if (!success) {
|
||||
ESP_LOGE(TAG, "Failed to get temperature: %d", result);
|
||||
ESP_LOGE(TAG, "Reading failed (%d)", result);
|
||||
}
|
||||
#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
#endif // USE_ESP32_VARIANT
|
||||
@ -103,20 +103,20 @@ void InternalTemperatureSensor::setup() {
|
||||
(defined(USE_ESP32_VARIANT_ESP32C3) || defined(USE_ESP32_VARIANT_ESP32C6) || defined(USE_ESP32_VARIANT_ESP32S2) || \
|
||||
defined(USE_ESP32_VARIANT_ESP32S3) || defined(USE_ESP32_VARIANT_ESP32H2) || defined(USE_ESP32_VARIANT_ESP32C2) || \
|
||||
defined(USE_ESP32_VARIANT_ESP32P4))
|
||||
ESP_LOGCONFIG(TAG, "Setting up temperature sensor...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
temperature_sensor_config_t tsens_config = TEMPERATURE_SENSOR_CONFIG_DEFAULT(-10, 80);
|
||||
|
||||
esp_err_t result = temperature_sensor_install(&tsens_config, &tsensNew);
|
||||
if (result != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to install temperature sensor: %d", result);
|
||||
ESP_LOGE(TAG, "Install failed (%d)", result);
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
|
||||
result = temperature_sensor_enable(tsensNew);
|
||||
if (result != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to enable temperature sensor: %d", result);
|
||||
ESP_LOGE(TAG, "Enabling failed (%d)", result);
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user