From 8ff742d9ab61f2c6cb04df09bc0e792d0ba478a6 Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Wed, 23 Oct 2019 14:43:41 +0200 Subject: [PATCH] Implement more dump_configs (#791) --- esphome/components/as3935_i2c/as3935_i2c.cpp | 4 ++++ esphome/components/as3935_i2c/as3935_i2c.h | 3 +++ esphome/components/bang_bang/bang_bang_climate.cpp | 8 ++++++++ esphome/components/bang_bang/bang_bang_climate.h | 1 + esphome/components/binary_sensor/binary_sensor.h | 4 ++-- esphome/components/captive_portal/captive_portal.cpp | 1 + esphome/components/captive_portal/captive_portal.h | 1 + esphome/components/climate/climate.h | 5 +++++ esphome/components/climate_ir/climate_ir.cpp | 10 ++++++++++ esphome/components/climate_ir/climate_ir.h | 1 + esphome/components/cover/cover.h | 6 +++--- esphome/components/dfplayer/dfplayer.cpp | 4 ++++ esphome/components/dfplayer/dfplayer.h | 1 + esphome/components/display/display_buffer.h | 4 ++-- .../components/esp32_ble_beacon/esp32_ble_beacon.cpp | 5 +++++ .../components/esp32_ble_beacon/esp32_ble_beacon.h | 1 + esphome/components/ntc/ntc.cpp | 6 +++--- esphome/components/ntc/ntc.h | 12 ++++++------ esphome/components/pzem004t/pzem004t.cpp | 6 ++++++ esphome/components/pzem004t/pzem004t.h | 2 ++ esphome/components/pzemac/pzemac.cpp | 9 +++++++++ esphome/components/pzemac/pzemac.h | 2 ++ esphome/components/pzemdc/pzemdc.cpp | 7 +++++++ esphome/components/pzemdc/pzemdc.h | 2 ++ esphome/components/sensor/sensor.h | 12 ++++++------ esphome/components/sim800l/sim800l.cpp | 4 ++++ esphome/components/sim800l/sim800l.h | 1 + esphome/components/switch/switch.h | 8 ++++---- esphome/components/text_sensor/text_sensor.h | 6 +++--- esphome/components/uptime/uptime_sensor.cpp | 1 + esphome/components/uptime/uptime_sensor.h | 1 + script/ci-custom.py | 1 + 32 files changed, 110 insertions(+), 29 deletions(-) diff --git a/esphome/components/as3935_i2c/as3935_i2c.cpp b/esphome/components/as3935_i2c/as3935_i2c.cpp index 7792bd3e29..a522116815 100644 --- a/esphome/components/as3935_i2c/as3935_i2c.cpp +++ b/esphome/components/as3935_i2c/as3935_i2c.cpp @@ -31,6 +31,10 @@ uint8_t I2CAS3935Component::read_register(uint8_t reg) { } return value; } +void I2CAS3935Component::dump_config() { + AS3935Component::dump_config(); + LOG_I2C_DEVICE(this); +} } // namespace as3935_i2c } // namespace esphome diff --git a/esphome/components/as3935_i2c/as3935_i2c.h b/esphome/components/as3935_i2c/as3935_i2c.h index 0f4167fc64..1d16397bdf 100644 --- a/esphome/components/as3935_i2c/as3935_i2c.h +++ b/esphome/components/as3935_i2c/as3935_i2c.h @@ -10,6 +10,9 @@ namespace esphome { namespace as3935_i2c { class I2CAS3935Component : public as3935::AS3935Component, public i2c::I2CDevice { + public: + void dump_config() override; + protected: void write_register(uint8_t reg, uint8_t mask, uint8_t bits, uint8_t start_position) override; uint8_t read_register(uint8_t reg) override; diff --git a/esphome/components/bang_bang/bang_bang_climate.cpp b/esphome/components/bang_bang/bang_bang_climate.cpp index 17c5c0bc48..978abae52a 100644 --- a/esphome/components/bang_bang/bang_bang_climate.cpp +++ b/esphome/components/bang_bang/bang_bang_climate.cpp @@ -145,6 +145,14 @@ Trigger<> *BangBangClimate::get_cool_trigger() const { return this->cool_trigger void BangBangClimate::set_supports_cool(bool supports_cool) { this->supports_cool_ = supports_cool; } Trigger<> *BangBangClimate::get_heat_trigger() const { return this->heat_trigger_; } void BangBangClimate::set_supports_heat(bool supports_heat) { this->supports_heat_ = supports_heat; } +void BangBangClimate::dump_config() { + LOG_CLIMATE("", "Bang Bang Climate", this); + ESP_LOGCONFIG(TAG, " Supports HEAT: %s", YESNO(this->supports_heat_)); + ESP_LOGCONFIG(TAG, " Supports COOL: %s", YESNO(this->supports_cool_)); + ESP_LOGCONFIG(TAG, " Supports AWAY mode: %s", YESNO(this->supports_away_)); + ESP_LOGCONFIG(TAG, " Default Target Temperature Low: %.1f°C", this->normal_config_.default_temperature_low); + ESP_LOGCONFIG(TAG, " Default Target Temperature High: %.1f°C", this->normal_config_.default_temperature_high); +} BangBangClimateTargetTempConfig::BangBangClimateTargetTempConfig() = default; BangBangClimateTargetTempConfig::BangBangClimateTargetTempConfig(float default_temperature_low, diff --git a/esphome/components/bang_bang/bang_bang_climate.h b/esphome/components/bang_bang/bang_bang_climate.h index 0a79c1d7af..84bcd51f34 100644 --- a/esphome/components/bang_bang/bang_bang_climate.h +++ b/esphome/components/bang_bang/bang_bang_climate.h @@ -21,6 +21,7 @@ class BangBangClimate : public climate::Climate, public Component { public: BangBangClimate(); void setup() override; + void dump_config() override; void set_sensor(sensor::Sensor *sensor); Trigger<> *get_idle_trigger() const; diff --git a/esphome/components/binary_sensor/binary_sensor.h b/esphome/components/binary_sensor/binary_sensor.h index 51c7a57ff6..577e87258c 100644 --- a/esphome/components/binary_sensor/binary_sensor.h +++ b/esphome/components/binary_sensor/binary_sensor.h @@ -10,9 +10,9 @@ namespace binary_sensor { #define LOG_BINARY_SENSOR(prefix, type, obj) \ if (obj != nullptr) { \ - ESP_LOGCONFIG(TAG, prefix type " '%s'", obj->get_name().c_str()); \ + ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, type, obj->get_name().c_str()); \ if (!obj->get_device_class().empty()) { \ - ESP_LOGCONFIG(TAG, prefix " Device Class: '%s'", obj->get_device_class().c_str()); \ + ESP_LOGCONFIG(TAG, "%s Device Class: '%s'", prefix, obj->get_device_class().c_str()); \ } \ } diff --git a/esphome/components/captive_portal/captive_portal.cpp b/esphome/components/captive_portal/captive_portal.cpp index 1b533b570e..83f85d354c 100644 --- a/esphome/components/captive_portal/captive_portal.cpp +++ b/esphome/components/captive_portal/captive_portal.cpp @@ -166,6 +166,7 @@ float CaptivePortal::get_setup_priority() const { // Before WiFi return setup_priority::WIFI + 1.0f; } +void CaptivePortal::dump_config() { ESP_LOGCONFIG(TAG, "Captive Portal:"); } CaptivePortal *global_captive_portal = nullptr; diff --git a/esphome/components/captive_portal/captive_portal.h b/esphome/components/captive_portal/captive_portal.h index 4b1717d157..cbc3ba6ccc 100644 --- a/esphome/components/captive_portal/captive_portal.h +++ b/esphome/components/captive_portal/captive_portal.h @@ -18,6 +18,7 @@ class CaptivePortal : public AsyncWebHandler, public Component { public: CaptivePortal(web_server_base::WebServerBase *base); void setup() override; + void dump_config() override; void loop() override { if (this->dns_server_ != nullptr) this->dns_server_->processNextRequest(); diff --git a/esphome/components/climate/climate.h b/esphome/components/climate/climate.h index 70c6bef13b..4dd872bbed 100644 --- a/esphome/components/climate/climate.h +++ b/esphome/components/climate/climate.h @@ -9,6 +9,11 @@ namespace esphome { namespace climate { +#define LOG_CLIMATE(prefix, type, obj) \ + if (obj != nullptr) { \ + ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, type, obj->get_name().c_str()); \ + } + class Climate; /** This class is used to encode all control actions on a climate device. diff --git a/esphome/components/climate_ir/climate_ir.cpp b/esphome/components/climate_ir/climate_ir.cpp index 3d8b97e131..995e5a7ba5 100644 --- a/esphome/components/climate_ir/climate_ir.cpp +++ b/esphome/components/climate_ir/climate_ir.cpp @@ -1,8 +1,11 @@ #include "climate_ir.h" +#include "esphome/core/log.h" namespace esphome { namespace climate { +static const char *TAG = "climate_ir"; + climate::ClimateTraits ClimateIR::traits() { auto traits = climate::ClimateTraits(); traits.set_supports_current_temperature(this->sensor_ != nullptr); @@ -52,6 +55,13 @@ void ClimateIR::control(const climate::ClimateCall &call) { this->transmit_state(); this->publish_state(); } +void ClimateIR::dump_config() { + LOG_CLIMATE("", "IR Climate", this); + ESP_LOGCONFIG(TAG, " Min. Temperature: %.1f°C", this->minimum_temperature_); + ESP_LOGCONFIG(TAG, " Max. Temperature: %.1f°C", this->maximum_temperature_); + ESP_LOGCONFIG(TAG, " Supports HEAT: %s", YESNO(this->supports_heat_)); + ESP_LOGCONFIG(TAG, " Supports COOL: %s", YESNO(this->supports_cool_)); +} } // namespace climate } // namespace esphome diff --git a/esphome/components/climate_ir/climate_ir.h b/esphome/components/climate_ir/climate_ir.h index 85f56c6b6b..51ced6b900 100644 --- a/esphome/components/climate_ir/climate_ir.h +++ b/esphome/components/climate_ir/climate_ir.h @@ -25,6 +25,7 @@ class ClimateIR : public climate::Climate, public Component, public remote_base: } void setup() override; + void dump_config() override; void set_transmitter(remote_transmitter::RemoteTransmitterComponent *transmitter) { this->transmitter_ = transmitter; } diff --git a/esphome/components/cover/cover.h b/esphome/components/cover/cover.h index 12011e1b4c..839cf9207e 100644 --- a/esphome/components/cover/cover.h +++ b/esphome/components/cover/cover.h @@ -13,13 +13,13 @@ const extern float COVER_CLOSED; #define LOG_COVER(prefix, type, obj) \ if (obj != nullptr) { \ - ESP_LOGCONFIG(TAG, prefix type " '%s'", obj->get_name().c_str()); \ + ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, type, obj->get_name().c_str()); \ auto traits_ = obj->get_traits(); \ if (traits_.get_is_assumed_state()) { \ - ESP_LOGCONFIG(TAG, prefix " Assumed State: YES"); \ + ESP_LOGCONFIG(TAG, "%s Assumed State: YES", prefix); \ } \ if (!obj->get_device_class().empty()) { \ - ESP_LOGCONFIG(TAG, prefix " Device Class: '%s'", obj->get_device_class().c_str()); \ + ESP_LOGCONFIG(TAG, "%s Device Class: '%s'", prefix, obj->get_device_class().c_str()); \ } \ } diff --git a/esphome/components/dfplayer/dfplayer.cpp b/esphome/components/dfplayer/dfplayer.cpp index 9589a907c4..5ce4998796 100644 --- a/esphome/components/dfplayer/dfplayer.cpp +++ b/esphome/components/dfplayer/dfplayer.cpp @@ -115,6 +115,10 @@ void DFPlayer::loop() { this->read_pos_++; } } +void DFPlayer::dump_config() { + ESP_LOGCONFIG(TAG, "DFPlayer:"); + this->check_uart_settings(9600); +} } // namespace dfplayer } // namespace esphome diff --git a/esphome/components/dfplayer/dfplayer.h b/esphome/components/dfplayer/dfplayer.h index 2cb9eea4eb..86efd62138 100644 --- a/esphome/components/dfplayer/dfplayer.h +++ b/esphome/components/dfplayer/dfplayer.h @@ -52,6 +52,7 @@ class DFPlayer : public uart::UARTDevice, public Component { void random() { this->send_cmd_(0x18); } bool is_playing() { return is_playing_; } + void dump_config() override; void add_on_finished_playback_callback(std::function callback) { this->on_finished_playback_callback_.add(std::move(callback)); diff --git a/esphome/components/display/display_buffer.h b/esphome/components/display/display_buffer.h index 57b95eee29..b12fad8c8a 100644 --- a/esphome/components/display/display_buffer.h +++ b/esphome/components/display/display_buffer.h @@ -84,8 +84,8 @@ using display_writer_t = std::function; #define LOG_DISPLAY(prefix, type, obj) \ if (obj != nullptr) { \ ESP_LOGCONFIG(TAG, prefix type); \ - ESP_LOGCONFIG(TAG, prefix " Rotations: %d °", obj->rotation_); \ - ESP_LOGCONFIG(TAG, prefix " Dimensions: %dpx x %dpx", obj->get_width(), obj->get_height()); \ + ESP_LOGCONFIG(TAG, "%s Rotations: %d °", prefix, obj->rotation_); \ + ESP_LOGCONFIG(TAG, "%s Dimensions: %dpx x %dpx", prefix, obj->get_width(), obj->get_height()); \ } class DisplayBuffer { diff --git a/esphome/components/esp32_ble_beacon/esp32_ble_beacon.cpp b/esphome/components/esp32_ble_beacon/esp32_ble_beacon.cpp index a61975d02f..b7810bd056 100644 --- a/esphome/components/esp32_ble_beacon/esp32_ble_beacon.cpp +++ b/esphome/components/esp32_ble_beacon/esp32_ble_beacon.cpp @@ -31,6 +31,11 @@ static esp_ble_adv_params_t ble_adv_params = { static esp_ble_ibeacon_head_t ibeacon_common_head = { .flags = {0x02, 0x01, 0x06}, .length = 0x1A, .type = 0xFF, .company_id = 0x004C, .beacon_type = 0x1502}; +void ESP32BLEBeacon::dump_config() { + ESP_LOGCONFIG(TAG, "ESP32 BLE Beacon:"); + ESP_LOGCONFIG(TAG, " Major: %u, Minor: %u", this->major_, this->minor_); +} + void ESP32BLEBeacon::setup() { ESP_LOGCONFIG(TAG, "Setting up ESP32 BLE beacon..."); global_esp32_ble_beacon = this; diff --git a/esphome/components/esp32_ble_beacon/esp32_ble_beacon.h b/esphome/components/esp32_ble_beacon/esp32_ble_beacon.h index 1c52b41d73..aba02830b3 100644 --- a/esphome/components/esp32_ble_beacon/esp32_ble_beacon.h +++ b/esphome/components/esp32_ble_beacon/esp32_ble_beacon.h @@ -34,6 +34,7 @@ class ESP32BLEBeacon : public Component { explicit ESP32BLEBeacon(const std::array &uuid) : uuid_(uuid) {} void setup() override; + void dump_config() override; float get_setup_priority() const override; void set_major(uint16_t major) { this->major_ = major; } diff --git a/esphome/components/ntc/ntc.cpp b/esphome/components/ntc/ntc.cpp index 1b5c5182c7..9446508b0b 100644 --- a/esphome/components/ntc/ntc.cpp +++ b/esphome/components/ntc/ntc.cpp @@ -19,9 +19,9 @@ void NTC::process_(float value) { return; } - float lr = logf(value); - float v = this->a_ + this->b_ * lr + this->c_ * lr * lr * lr; - float temp = 1 / v - 273.15f; + double lr = log(double(value)); + double v = this->a_ + this->b_ * lr + this->c_ * lr * lr * lr; + auto temp = float(1.0 / v - 273.15); ESP_LOGD(TAG, "'%s' - Temperature: %.1f°C", this->name_.c_str(), temp); this->publish_state(temp); diff --git a/esphome/components/ntc/ntc.h b/esphome/components/ntc/ntc.h index 9d6b37412d..c8592e0fe8 100644 --- a/esphome/components/ntc/ntc.h +++ b/esphome/components/ntc/ntc.h @@ -9,9 +9,9 @@ namespace ntc { class NTC : public Component, public sensor::Sensor { public: void set_sensor(Sensor *sensor) { sensor_ = sensor; } - void set_a(float a) { a_ = a; } - void set_b(float b) { b_ = b; } - void set_c(float c) { c_ = c; } + void set_a(double a) { a_ = a; } + void set_b(double b) { b_ = b; } + void set_c(double c) { c_ = c; } void setup() override; void dump_config() override; float get_setup_priority() const override; @@ -20,9 +20,9 @@ class NTC : public Component, public sensor::Sensor { void process_(float value); sensor::Sensor *sensor_; - float a_; - float b_; - float c_; + double a_; + double b_; + double c_; }; } // namespace ntc diff --git a/esphome/components/pzem004t/pzem004t.cpp b/esphome/components/pzem004t/pzem004t.cpp index 3f07e74f9b..cbdc14f0d0 100644 --- a/esphome/components/pzem004t/pzem004t.cpp +++ b/esphome/components/pzem004t/pzem004t.cpp @@ -98,6 +98,12 @@ void PZEM004T::write_state_(PZEM004T::PZEM004TReadState state) { this->write_array(data); this->read_state_ = state; } +void PZEM004T::dump_config() { + ESP_LOGCONFIG(TAG, "PZEM004T:"); + LOG_SENSOR("", "Voltage", this->voltage_sensor_); + LOG_SENSOR("", "Current", this->current_sensor_); + LOG_SENSOR("", "Power", this->power_sensor_); +} } // namespace pzem004t } // namespace esphome diff --git a/esphome/components/pzem004t/pzem004t.h b/esphome/components/pzem004t/pzem004t.h index 7969efd78c..f0208d415a 100644 --- a/esphome/components/pzem004t/pzem004t.h +++ b/esphome/components/pzem004t/pzem004t.h @@ -17,6 +17,8 @@ class PZEM004T : public PollingComponent, public uart::UARTDevice { void update() override; + void dump_config() override; + protected: sensor::Sensor *voltage_sensor_; sensor::Sensor *current_sensor_; diff --git a/esphome/components/pzemac/pzemac.cpp b/esphome/components/pzemac/pzemac.cpp index 1c3957dc09..f05ce15711 100644 --- a/esphome/components/pzemac/pzemac.cpp +++ b/esphome/components/pzemac/pzemac.cpp @@ -57,6 +57,15 @@ void PZEMAC::on_modbus_data(const std::vector &data) { } void PZEMAC::update() { this->send(PZEM_CMD_READ_IN_REGISTERS, 0, PZEM_REGISTER_COUNT); } +void PZEMAC::dump_config() { + ESP_LOGCONFIG(TAG, "PZEMAC:"); + ESP_LOGCONFIG(TAG, " Address: 0x%02X", this->address_); + LOG_SENSOR("", "Voltage", this->voltage_sensor_); + LOG_SENSOR("", "Current", this->current_sensor_); + LOG_SENSOR("", "Power", this->power_sensor_); + LOG_SENSOR("", "Frequency", this->frequency_sensor_); + LOG_SENSOR("", "Power Factor", this->power_factor_sensor_); +} } // namespace pzemac } // namespace esphome diff --git a/esphome/components/pzemac/pzemac.h b/esphome/components/pzemac/pzemac.h index 0ba742fafe..d396b7cddf 100644 --- a/esphome/components/pzemac/pzemac.h +++ b/esphome/components/pzemac/pzemac.h @@ -19,6 +19,8 @@ class PZEMAC : public PollingComponent, public modbus::ModbusDevice { void on_modbus_data(const std::vector &data) override; + void dump_config() override; + protected: sensor::Sensor *voltage_sensor_; sensor::Sensor *current_sensor_; diff --git a/esphome/components/pzemdc/pzemdc.cpp b/esphome/components/pzemdc/pzemdc.cpp index c85d35106d..9bd58410c0 100644 --- a/esphome/components/pzemdc/pzemdc.cpp +++ b/esphome/components/pzemdc/pzemdc.cpp @@ -47,6 +47,13 @@ void PZEMDC::on_modbus_data(const std::vector &data) { } void PZEMDC::update() { this->send(PZEM_CMD_READ_IN_REGISTERS, 0, 8); } +void PZEMDC::dump_config() { + ESP_LOGCONFIG(TAG, "PZEMDC:"); + ESP_LOGCONFIG(TAG, " Address: 0x%02X", this->address_); + LOG_SENSOR("", "Voltage", this->voltage_sensor_); + LOG_SENSOR("", "Current", this->current_sensor_); + LOG_SENSOR("", "Power", this->power_sensor_); +} } // namespace pzemdc } // namespace esphome diff --git a/esphome/components/pzemdc/pzemdc.h b/esphome/components/pzemdc/pzemdc.h index e19203dc21..d838eb4167 100644 --- a/esphome/components/pzemdc/pzemdc.h +++ b/esphome/components/pzemdc/pzemdc.h @@ -19,6 +19,8 @@ class PZEMDC : public PollingComponent, public modbus::ModbusDevice { void on_modbus_data(const std::vector &data) override; + void dump_config() override; + protected: sensor::Sensor *voltage_sensor_; sensor::Sensor *current_sensor_; diff --git a/esphome/components/sensor/sensor.h b/esphome/components/sensor/sensor.h index 14ace91b35..f23f022767 100644 --- a/esphome/components/sensor/sensor.h +++ b/esphome/components/sensor/sensor.h @@ -9,17 +9,17 @@ namespace sensor { #define LOG_SENSOR(prefix, type, obj) \ if (obj != nullptr) { \ - ESP_LOGCONFIG(TAG, prefix type " '%s'", obj->get_name().c_str()); \ - ESP_LOGCONFIG(TAG, prefix " Unit of Measurement: '%s'", obj->get_unit_of_measurement().c_str()); \ - ESP_LOGCONFIG(TAG, prefix " Accuracy Decimals: %d", obj->get_accuracy_decimals()); \ + ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, type, obj->get_name().c_str()); \ + ESP_LOGCONFIG(TAG, "%s Unit of Measurement: '%s'", prefix, obj->get_unit_of_measurement().c_str()); \ + ESP_LOGCONFIG(TAG, "%s Accuracy Decimals: %d", prefix, obj->get_accuracy_decimals()); \ if (!obj->get_icon().empty()) { \ - ESP_LOGCONFIG(TAG, prefix " Icon: '%s'", obj->get_icon().c_str()); \ + ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, obj->get_icon().c_str()); \ } \ if (!obj->unique_id().empty()) { \ - ESP_LOGV(TAG, prefix " Unique ID: '%s'", obj->unique_id().c_str()); \ + ESP_LOGV(TAG, "%s Unique ID: '%s'", prefix, obj->unique_id().c_str()); \ } \ if (obj->get_force_update()) { \ - ESP_LOGV(TAG, prefix " Force Update: YES"); \ + ESP_LOGV(TAG, "%s Force Update: YES", prefix); \ } \ } diff --git a/esphome/components/sim800l/sim800l.cpp b/esphome/components/sim800l/sim800l.cpp index b2d58c5043..1390ef8b49 100644 --- a/esphome/components/sim800l/sim800l.cpp +++ b/esphome/components/sim800l/sim800l.cpp @@ -255,6 +255,10 @@ void Sim800LComponent::send_sms(std::string recipient, std::string message) { this->send_pending_ = true; this->update(); } +void Sim800LComponent::dump_config() { + ESP_LOGCONFIG(TAG, "SIM800L:"); + ESP_LOGCONFIG(TAG, " RSSI: %d dB", this->rssi_); +} } // namespace sim800l } // namespace esphome diff --git a/esphome/components/sim800l/sim800l.h b/esphome/components/sim800l/sim800l.h index 0a3f4b463b..696eb8890f 100644 --- a/esphome/components/sim800l/sim800l.h +++ b/esphome/components/sim800l/sim800l.h @@ -37,6 +37,7 @@ class Sim800LComponent : public uart::UARTDevice, public PollingComponent { /// Retrieve the latest sensor values. This operation takes approximately 16ms. void update() override; void loop() override; + void dump_config() override; void add_on_sms_received_callback(std::function callback) { this->callback_.add(std::move(callback)); } diff --git a/esphome/components/switch/switch.h b/esphome/components/switch/switch.h index be4fc24c4a..cd6cec429f 100644 --- a/esphome/components/switch/switch.h +++ b/esphome/components/switch/switch.h @@ -9,15 +9,15 @@ namespace switch_ { #define LOG_SWITCH(prefix, type, obj) \ if (obj != nullptr) { \ - ESP_LOGCONFIG(TAG, prefix type " '%s'", obj->get_name().c_str()); \ + ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, type, obj->get_name().c_str()); \ if (!obj->get_icon().empty()) { \ - ESP_LOGCONFIG(TAG, prefix " Icon: '%s'", obj->get_icon().c_str()); \ + ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, obj->get_icon().c_str()); \ } \ if (obj->assumed_state()) { \ - ESP_LOGCONFIG(TAG, prefix " Assumed State: YES"); \ + ESP_LOGCONFIG(TAG, "%s Assumed State: YES", prefix); \ } \ if (obj->is_inverted()) { \ - ESP_LOGCONFIG(TAG, prefix " Inverted: YES"); \ + ESP_LOGCONFIG(TAG, "%s Inverted: YES", prefix); \ } \ } diff --git a/esphome/components/text_sensor/text_sensor.h b/esphome/components/text_sensor/text_sensor.h index 719f0b0d62..85c2b644a0 100644 --- a/esphome/components/text_sensor/text_sensor.h +++ b/esphome/components/text_sensor/text_sensor.h @@ -8,12 +8,12 @@ namespace text_sensor { #define LOG_TEXT_SENSOR(prefix, type, obj) \ if (obj != nullptr) { \ - ESP_LOGCONFIG(TAG, prefix type " '%s'", obj->get_name().c_str()); \ + ESP_LOGCONFIG(TAG, "%s%s '%s'", prefix, type, obj->get_name().c_str()); \ if (!obj->get_icon().empty()) { \ - ESP_LOGCONFIG(TAG, prefix " Icon: '%s'", obj->get_icon().c_str()); \ + ESP_LOGCONFIG(TAG, "%s Icon: '%s'", prefix, obj->get_icon().c_str()); \ } \ if (!obj->unique_id().empty()) { \ - ESP_LOGV(TAG, prefix " Unique ID: '%s'", obj->unique_id().c_str()); \ + ESP_LOGV(TAG, "%s Unique ID: '%s'", prefix, obj->unique_id().c_str()); \ } \ } diff --git a/esphome/components/uptime/uptime_sensor.cpp b/esphome/components/uptime/uptime_sensor.cpp index f047724768..5d117ab61d 100644 --- a/esphome/components/uptime/uptime_sensor.cpp +++ b/esphome/components/uptime/uptime_sensor.cpp @@ -27,6 +27,7 @@ void UptimeSensor::update() { } std::string UptimeSensor::unique_id() { return get_mac_address() + "-uptime"; } float UptimeSensor::get_setup_priority() const { return setup_priority::HARDWARE; } +void UptimeSensor::dump_config() { LOG_SENSOR("", "Uptime Sensor", this); } } // namespace uptime } // namespace esphome diff --git a/esphome/components/uptime/uptime_sensor.h b/esphome/components/uptime/uptime_sensor.h index 184022503d..dab380d2d9 100644 --- a/esphome/components/uptime/uptime_sensor.h +++ b/esphome/components/uptime/uptime_sensor.h @@ -9,6 +9,7 @@ namespace uptime { class UptimeSensor : public sensor::Sensor, public PollingComponent { public: void update() override; + void dump_config() override; float get_setup_priority() const override; diff --git a/script/ci-custom.py b/script/ci-custom.py index 3592faefab..b43b15bcdd 100755 --- a/script/ci-custom.py +++ b/script/ci-custom.py @@ -325,6 +325,7 @@ def lint_pragma_once(fname, content): 'esphome/components/stepper/stepper.h', 'esphome/components/switch/switch.h', 'esphome/components/text_sensor/text_sensor.h', + 'esphome/components/climate/climate.h', 'esphome/core/component.h', 'esphome/core/esphal.h', 'esphome/core/log.h',