mirror of
https://github.com/esphome/esphome.git
synced 2024-12-23 14:04:53 +01:00
Implement more dump_configs (#791)
This commit is contained in:
parent
6f63a62a8d
commit
6cd76f00ac
32 changed files with 110 additions and 29 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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()); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<void()> callback) {
|
||||
this->on_finished_playback_callback_.add(std::move(callback));
|
||||
|
|
|
@ -84,8 +84,8 @@ using display_writer_t = std::function<void(DisplayBuffer &)>;
|
|||
#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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -34,6 +34,7 @@ class ESP32BLEBeacon : public Component {
|
|||
explicit ESP32BLEBeacon(const std::array<uint8_t, 16> &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; }
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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_;
|
||||
|
|
|
@ -57,6 +57,15 @@ void PZEMAC::on_modbus_data(const std::vector<uint8_t> &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
|
||||
|
|
|
@ -19,6 +19,8 @@ class PZEMAC : public PollingComponent, public modbus::ModbusDevice {
|
|||
|
||||
void on_modbus_data(const std::vector<uint8_t> &data) override;
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
sensor::Sensor *voltage_sensor_;
|
||||
sensor::Sensor *current_sensor_;
|
||||
|
|
|
@ -47,6 +47,13 @@ void PZEMDC::on_modbus_data(const std::vector<uint8_t> &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
|
||||
|
|
|
@ -19,6 +19,8 @@ class PZEMDC : public PollingComponent, public modbus::ModbusDevice {
|
|||
|
||||
void on_modbus_data(const std::vector<uint8_t> &data) override;
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
protected:
|
||||
sensor::Sensor *voltage_sensor_;
|
||||
sensor::Sensor *current_sensor_;
|
||||
|
|
|
@ -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); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<void(std::string, std::string)> callback) {
|
||||
this->callback_.add(std::move(callback));
|
||||
}
|
||||
|
|
|
@ -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); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
|
|
@ -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()); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue