Compare commits
47 Commits
bluetooth_
...
p4_remote_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
123d4c3e0d | ||
|
|
4f1953c581 | ||
|
|
a00fc75c77 | ||
|
|
80fd827f8b | ||
|
|
1dd3c6de90 | ||
|
|
c8c43f13fd | ||
|
|
518bce50a5 | ||
|
|
4f87bea788 | ||
|
|
8054c9b4f5 | ||
|
|
935e0a365f | ||
|
|
b39a9924d8 | ||
|
|
19ec922e28 | ||
|
|
a225d6881f | ||
|
|
6675e99862 | ||
|
|
8cbe2b41f6 | ||
|
|
6a225cb4c0 | ||
|
|
e62d8bfabe | ||
|
|
d4cea84b1b | ||
|
|
b63f90a6c0 | ||
|
|
4370b6695e | ||
|
|
589f13f0f7 | ||
|
|
367017b352 | ||
|
|
ec26d31499 | ||
|
|
1bbc6db1c3 | ||
|
|
162472bdc2 | ||
|
|
aecac15809 | ||
|
|
6554af21b9 | ||
|
|
8583466c6a | ||
|
|
6666604069 | ||
|
|
13e7aacc9d | ||
|
|
737d502614 | ||
|
|
67dd649d00 | ||
|
|
b2fc51367b | ||
|
|
5771bb4907 | ||
|
|
9ba9674437 | ||
|
|
acb1532e34 | ||
|
|
e2093c34da | ||
|
|
a2e4ad90ba | ||
|
|
32e69c67f2 | ||
|
|
df0b5a187e | ||
|
|
cee0e5379b | ||
|
|
daf2bd7e66 | ||
|
|
5bdf5c1bf3 | ||
|
|
fa27c0b8f1 | ||
|
|
69fec85cc1 | ||
|
|
aa26e2bffd | ||
|
|
af1a4d8a0a |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -296,7 +296,7 @@ jobs:
|
||||
name: Run script/clang-tidy for ZEPHYR
|
||||
options: --environment nrf52-tidy --grep USE_ZEPHYR
|
||||
pio_cache_key: tidy-zephyr
|
||||
ignore_errors: true
|
||||
ignore_errors: false
|
||||
|
||||
steps:
|
||||
- name: Check out code from GitHub
|
||||
|
||||
@@ -146,6 +146,7 @@ esphome/components/esp32_ble_client/* @jesserockz
|
||||
esphome/components/esp32_ble_server/* @Rapsssito @clydebarrow @jesserockz
|
||||
esphome/components/esp32_camera_web_server/* @ayufan
|
||||
esphome/components/esp32_can/* @Sympatron
|
||||
esphome/components/esp32_hosted/* @swoboda1337
|
||||
esphome/components/esp32_improv/* @jesserockz
|
||||
esphome/components/esp32_rmt/* @jesserockz
|
||||
esphome/components/esp32_rmt_led_strip/* @jesserockz
|
||||
@@ -235,6 +236,7 @@ esphome/components/kamstrup_kmp/* @cfeenstra1024
|
||||
esphome/components/key_collector/* @ssieb
|
||||
esphome/components/key_provider/* @ssieb
|
||||
esphome/components/kuntze/* @ssieb
|
||||
esphome/components/lc709203f/* @ilikecake
|
||||
esphome/components/lcd_menu/* @numo68
|
||||
esphome/components/ld2410/* @regevbr @sebcaps
|
||||
esphome/components/ld2420/* @descipher
|
||||
|
||||
@@ -22,7 +22,7 @@ static const int ADC_MAX = (1 << SOC_ADC_RTC_MAX_BITWIDTH) - 1;
|
||||
static const int ADC_HALF = (1 << SOC_ADC_RTC_MAX_BITWIDTH) >> 1;
|
||||
|
||||
void ADCSensor::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Running setup for '%s'...", this->get_name().c_str());
|
||||
ESP_LOGCONFIG(TAG, "Running setup for '%s'", this->get_name().c_str());
|
||||
|
||||
if (this->channel1_ != ADC1_CHANNEL_MAX) {
|
||||
adc1_config_width(ADC_WIDTH_MAX_SOC_BITS);
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace adc {
|
||||
static const char *const TAG = "adc.esp8266";
|
||||
|
||||
void ADCSensor::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Running setup for '%s'...", this->get_name().c_str());
|
||||
ESP_LOGCONFIG(TAG, "Running setup for '%s'", this->get_name().c_str());
|
||||
#ifndef USE_ADC_SENSOR_VCC
|
||||
this->pin_->setup();
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace adc {
|
||||
static const char *const TAG = "adc.libretiny";
|
||||
|
||||
void ADCSensor::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Running setup for '%s'...", this->get_name().c_str());
|
||||
ESP_LOGCONFIG(TAG, "Running setup for '%s'", this->get_name().c_str());
|
||||
#ifndef USE_ADC_SENSOR_VCC
|
||||
this->pin_->setup();
|
||||
#endif // !USE_ADC_SENSOR_VCC
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace adc {
|
||||
static const char *const TAG = "adc.rp2040";
|
||||
|
||||
void ADCSensor::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Running setup for '%s'...", this->get_name().c_str());
|
||||
ESP_LOGCONFIG(TAG, "Running setup for '%s'", this->get_name().c_str());
|
||||
static bool initialized = false;
|
||||
if (!initialized) {
|
||||
adc_init();
|
||||
|
||||
@@ -115,7 +115,7 @@ void AHT10Component::read_data_() {
|
||||
if (this->humidity_sensor_ == nullptr) {
|
||||
ESP_LOGV(TAG, "Invalid humidity (reading not required)");
|
||||
} else {
|
||||
ESP_LOGD(TAG, "Invalid humidity, retrying...");
|
||||
ESP_LOGD(TAG, "Invalid humidity, retrying");
|
||||
if (this->write(AHT10_MEASURE_CMD, sizeof(AHT10_MEASURE_CMD)) != i2c::ERROR_OK) {
|
||||
this->status_set_warning(ESP_LOG_MSG_COMM_FAIL);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ void APIConnection::loop() {
|
||||
// when network is disconnected force disconnect immediately
|
||||
// don't wait for timeout
|
||||
this->on_fatal_error();
|
||||
ESP_LOGW(TAG, "%s: Network unavailable, disconnecting", this->client_combined_info_.c_str());
|
||||
ESP_LOGW(TAG, "%s: Network unavailable; disconnecting", this->client_combined_info_.c_str());
|
||||
return;
|
||||
}
|
||||
if (this->next_close_) {
|
||||
@@ -182,24 +182,23 @@ void APIConnection::loop() {
|
||||
// Disconnect if not responded within 2.5*keepalive
|
||||
if (now - this->last_traffic_ > (KEEPALIVE_TIMEOUT_MS * 5) / 2) {
|
||||
on_fatal_error();
|
||||
ESP_LOGW(TAG, "%s didn't respond to ping request in time. Disconnecting...", this->client_combined_info_.c_str());
|
||||
ESP_LOGW(TAG, "%s is unresponsive; disconnecting", this->client_combined_info_.c_str());
|
||||
}
|
||||
} else if (now - this->last_traffic_ > KEEPALIVE_TIMEOUT_MS && now > this->next_ping_retry_) {
|
||||
ESP_LOGVV(TAG, "Sending keepalive PING...");
|
||||
ESP_LOGVV(TAG, "Sending keepalive PING");
|
||||
this->sent_ping_ = this->send_ping_request(PingRequest());
|
||||
if (!this->sent_ping_) {
|
||||
char warn_str[38];
|
||||
this->next_ping_retry_ = now + ping_retry_interval;
|
||||
this->ping_retries_++;
|
||||
sprintf(warn_str, "Sending keepalive failed %u time(s); ", this->ping_retries_);
|
||||
if (this->ping_retries_ >= max_ping_retries) {
|
||||
on_fatal_error();
|
||||
ESP_LOGE(TAG, "%s: Sending keepalive failed %d time(s). Disconnecting...", this->client_combined_info_.c_str(),
|
||||
this->ping_retries_);
|
||||
ESP_LOGE(TAG, "%s: %sdisconnecting", this->client_combined_info_.c_str(), warn_str);
|
||||
} else if (this->ping_retries_ >= 10) {
|
||||
ESP_LOGW(TAG, "%s: Sending keepalive failed %d time(s), will retry in %d ms",
|
||||
this->client_combined_info_.c_str(), this->ping_retries_, ping_retry_interval);
|
||||
ESP_LOGW(TAG, "%s: %sretrying in %u ms", this->client_combined_info_.c_str(), warn_str, ping_retry_interval);
|
||||
} else {
|
||||
ESP_LOGD(TAG, "%s: Sending keepalive failed %d time(s), will retry in %d ms",
|
||||
this->client_combined_info_.c_str(), this->ping_retries_, ping_retry_interval);
|
||||
ESP_LOGD(TAG, "%s: %sretrying in %u ms", this->client_combined_info_.c_str(), warn_str, ping_retry_interval);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,7 +269,7 @@ DisconnectResponse APIConnection::disconnect(const DisconnectRequest &msg) {
|
||||
// remote initiated disconnect_client
|
||||
// don't close yet, we still need to send the disconnect response
|
||||
// close will happen on next loop
|
||||
ESP_LOGD(TAG, "%s requested disconnected", this->client_combined_info_.c_str());
|
||||
ESP_LOGD(TAG, "%s disconnected", this->client_combined_info_.c_str());
|
||||
this->next_close_ = true;
|
||||
DisconnectResponse resp;
|
||||
return resp;
|
||||
@@ -1472,7 +1471,7 @@ void APIConnection::update_command(const UpdateCommandRequest &msg) {
|
||||
update->check();
|
||||
break;
|
||||
case enums::UPDATE_COMMAND_NONE:
|
||||
ESP_LOGE(TAG, "UPDATE_COMMAND_NONE not handled. Check client is sending the correct command");
|
||||
ESP_LOGE(TAG, "UPDATE_COMMAND_NONE not handled; confirm command is correct");
|
||||
break;
|
||||
default:
|
||||
ESP_LOGW(TAG, "Unknown update command: %" PRIu32, msg.command);
|
||||
@@ -1534,7 +1533,7 @@ ConnectResponse APIConnection::connect(const ConnectRequest &msg) {
|
||||
// bool invalid_password = 1;
|
||||
resp.invalid_password = !correct;
|
||||
if (correct) {
|
||||
ESP_LOGD(TAG, "%s: Connected successfully", this->client_combined_info_.c_str());
|
||||
ESP_LOGD(TAG, "%s connected", this->client_combined_info_.c_str());
|
||||
this->connection_state_ = ConnectionState::AUTHENTICATED;
|
||||
this->parent_->get_client_connected_trigger()->trigger(this->client_info_, this->client_peername_);
|
||||
#ifdef USE_HOMEASSISTANT_TIME
|
||||
@@ -1605,7 +1604,7 @@ void APIConnection::execute_service(const ExecuteServiceRequest &msg) {
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
ESP_LOGV(TAG, "Could not find matching service!");
|
||||
ESP_LOGV(TAG, "Could not find service");
|
||||
}
|
||||
}
|
||||
#ifdef USE_API_NOISE
|
||||
@@ -1674,11 +1673,11 @@ bool APIConnection::send_buffer(ProtoWriteBuffer buffer, uint32_t message_type)
|
||||
}
|
||||
void APIConnection::on_unauthenticated_access() {
|
||||
this->on_fatal_error();
|
||||
ESP_LOGD(TAG, "%s: tried to access without authentication.", this->client_combined_info_.c_str());
|
||||
ESP_LOGD(TAG, "%s requested access without authentication", this->client_combined_info_.c_str());
|
||||
}
|
||||
void APIConnection::on_no_setup_connection() {
|
||||
this->on_fatal_error();
|
||||
ESP_LOGD(TAG, "%s: tried to access without full connection.", this->client_combined_info_.c_str());
|
||||
ESP_LOGD(TAG, "%s requested access without full connection", this->client_combined_info_.c_str());
|
||||
}
|
||||
void APIConnection::on_fatal_error() {
|
||||
this->helper_->close();
|
||||
|
||||
@@ -780,7 +780,7 @@ extern "C" {
|
||||
// declare how noise generates random bytes (here with a good HWRNG based on the RF system)
|
||||
void noise_rand_bytes(void *output, size_t len) {
|
||||
if (!esphome::random_bytes(reinterpret_cast<uint8_t *>(output), len)) {
|
||||
ESP_LOGE(TAG, "Failed to acquire random bytes, rebooting!");
|
||||
ESP_LOGE(TAG, "Acquiring random bytes failed; rebooting");
|
||||
arch_restart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ void AS3935Component::display_oscillator(bool state, uint8_t osc) {
|
||||
// based on the resonance frequency of the antenna and so it should be trimmed
|
||||
// before the calibration is done.
|
||||
bool AS3935Component::calibrate_oscillator() {
|
||||
ESP_LOGI(TAG, "Starting oscillators calibration...");
|
||||
ESP_LOGI(TAG, "Starting oscillators calibration");
|
||||
this->write_register(CALIB_RCO, WIPE_ALL, DIRECT_COMMAND, 0); // Send command to calibrate the oscillators
|
||||
|
||||
this->display_oscillator(true, 2);
|
||||
@@ -307,7 +307,7 @@ bool AS3935Component::calibrate_oscillator() {
|
||||
}
|
||||
|
||||
void AS3935Component::tune_antenna() {
|
||||
ESP_LOGI(TAG, "Starting antenna tuning...");
|
||||
ESP_LOGI(TAG, "Starting antenna tuning");
|
||||
uint8_t div_ratio = this->read_div_ratio();
|
||||
uint8_t tune_val = this->read_capacitance();
|
||||
ESP_LOGI(TAG, "Division Ratio is set to: %d", div_ratio);
|
||||
|
||||
@@ -75,7 +75,7 @@ void AT581XComponent::setup() { ESP_LOGCONFIG(TAG, "Running setup"); }
|
||||
void AT581XComponent::dump_config() { LOG_I2C_DEVICE(this); }
|
||||
#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0]))
|
||||
bool AT581XComponent::i2c_write_config() {
|
||||
ESP_LOGCONFIG(TAG, "Writing new config for AT581X...");
|
||||
ESP_LOGCONFIG(TAG, "Writing new config for AT581X");
|
||||
ESP_LOGCONFIG(TAG, "Frequency: %dMHz", this->freq_);
|
||||
ESP_LOGCONFIG(TAG, "Sensing distance: %d", this->delta_);
|
||||
ESP_LOGCONFIG(TAG, "Power: %dµA", this->power_);
|
||||
|
||||
@@ -686,7 +686,7 @@ void ATM90E32Component::restore_power_offset_calibrations_() {
|
||||
}
|
||||
|
||||
void ATM90E32Component::clear_gain_calibrations() {
|
||||
ESP_LOGI(TAG, "[CALIBRATION] Clearing stored gain calibrations and restoring config-defined values...");
|
||||
ESP_LOGI(TAG, "[CALIBRATION] Clearing stored gain calibrations and restoring config-defined values");
|
||||
|
||||
for (int phase = 0; phase < 3; phase++) {
|
||||
gain_phase_[phase].voltage_gain = this->phase_[phase].voltage_gain_;
|
||||
|
||||
@@ -527,7 +527,7 @@ void BedJetHub::dispatch_status_() {
|
||||
}
|
||||
|
||||
if (this->timeout_ > 0 && diff > this->timeout_ && this->parent()->enabled) {
|
||||
ESP_LOGW(TAG, "[%s] Timed out after %" PRId32 " sec. Retrying...", this->get_name().c_str(), this->timeout_);
|
||||
ESP_LOGW(TAG, "[%s] Timed out after %" PRId32 " sec. Retrying", this->get_name().c_str(), this->timeout_);
|
||||
// set_enabled(false) will only close the connection if state != IDLE.
|
||||
this->parent()->set_state(espbt::ClientState::CONNECTING);
|
||||
this->parent()->set_enabled(false);
|
||||
|
||||
@@ -256,7 +256,7 @@ void BekenSPILEDStripLightOutput::write_state(light::LightState *state) {
|
||||
this->last_refresh_ = now;
|
||||
this->mark_shown_();
|
||||
|
||||
ESP_LOGVV(TAG, "Writing RGB values to bus...");
|
||||
ESP_LOGVV(TAG, "Writing RGB values to bus");
|
||||
|
||||
if (spi_data == nullptr) {
|
||||
ESP_LOGE(TAG, "SPI not initialized");
|
||||
|
||||
@@ -68,8 +68,7 @@ void binary_sensor::MultiClickTrigger::on_state_(bool state) {
|
||||
*this->at_index_ = *this->at_index_ + 1;
|
||||
}
|
||||
void binary_sensor::MultiClickTrigger::schedule_cooldown_() {
|
||||
ESP_LOGV(TAG, "Multi Click: Invalid length of press, starting cooldown of %" PRIu32 " ms...",
|
||||
this->invalid_cooldown_);
|
||||
ESP_LOGV(TAG, "Multi Click: Invalid length of press, starting cooldown of %" PRIu32 " ms", this->invalid_cooldown_);
|
||||
this->is_in_cooldown_ = true;
|
||||
this->set_timeout("cooldown", this->invalid_cooldown_, [this]() {
|
||||
ESP_LOGV(TAG, "Multi Click: Cooldown ended, matching is now enabled again.");
|
||||
|
||||
@@ -100,7 +100,7 @@ void BL0906::handle_actions_() {
|
||||
for (int i = 0; i < this->action_queue_.size(); i++) {
|
||||
ptr_func = this->action_queue_[i];
|
||||
if (ptr_func) {
|
||||
ESP_LOGI(TAG, "HandleActionCallback[%d]...", i);
|
||||
ESP_LOGI(TAG, "HandleActionCallback[%d]", i);
|
||||
(this->*ptr_func)();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ inline uint8_t oversampling_to_time(BME280Oversampling over_sampling) { return (
|
||||
|
||||
void BME280Component::update() {
|
||||
// Enable sensor
|
||||
ESP_LOGV(TAG, "Sending conversion request...");
|
||||
ESP_LOGV(TAG, "Sending conversion request");
|
||||
uint8_t meas_value = 0;
|
||||
meas_value |= (this->temperature_oversampling_ & 0b111) << 5;
|
||||
meas_value |= (this->pressure_oversampling_ & 0b111) << 2;
|
||||
|
||||
@@ -13,7 +13,7 @@ from esphome.const import (
|
||||
CONF_PRESSURE,
|
||||
CONF_TEMPERATURE,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_PRESSURE,
|
||||
DEVICE_CLASS_ATMOSPHERIC_PRESSURE,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
ICON_GAS_CYLINDER,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
@@ -71,7 +71,7 @@ CONFIG_SCHEMA = (
|
||||
cv.Optional(CONF_PRESSURE): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_HECTOPASCAL,
|
||||
accuracy_decimals=1,
|
||||
device_class=DEVICE_CLASS_PRESSURE,
|
||||
device_class=DEVICE_CLASS_ATMOSPHERIC_PRESSURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
).extend(
|
||||
{
|
||||
|
||||
@@ -15,6 +15,8 @@ from esphome.const import (
|
||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
||||
ICON_GAS_CYLINDER,
|
||||
ICON_GAUGE,
|
||||
ICON_THERMOMETER,
|
||||
ICON_WATER_PERCENT,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
UNIT_CELSIUS,
|
||||
UNIT_HECTOPASCAL,
|
||||
@@ -27,11 +29,11 @@ from . import CONF_BME680_BSEC_ID, SAMPLE_RATE_OPTIONS, BME680BSECComponent
|
||||
|
||||
DEPENDENCIES = ["bme680_bsec"]
|
||||
|
||||
CONF_IAQ = "iaq"
|
||||
CONF_CO2_EQUIVALENT = "co2_equivalent"
|
||||
CONF_BREATH_VOC_EQUIVALENT = "breath_voc_equivalent"
|
||||
UNIT_IAQ = "IAQ"
|
||||
CONF_CO2_EQUIVALENT = "co2_equivalent"
|
||||
CONF_IAQ = "iaq"
|
||||
ICON_ACCURACY = "mdi:checkbox-marked-circle-outline"
|
||||
UNIT_IAQ = "IAQ"
|
||||
|
||||
TYPES = [
|
||||
CONF_TEMPERATURE,
|
||||
@@ -49,6 +51,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
cv.GenerateID(CONF_BME680_BSEC_ID): cv.use_id(BME680BSECComponent),
|
||||
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
icon=ICON_THERMOMETER,
|
||||
accuracy_decimals=1,
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
@@ -65,6 +68,7 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
),
|
||||
cv.Optional(CONF_HUMIDITY): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_PERCENT,
|
||||
icon=ICON_WATER_PERCENT,
|
||||
accuracy_decimals=1,
|
||||
device_class=DEVICE_CLASS_HUMIDITY,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
|
||||
@@ -9,8 +9,10 @@ from esphome.const import (
|
||||
CONF_SAMPLE_RATE,
|
||||
CONF_TEMPERATURE,
|
||||
DEVICE_CLASS_ATMOSPHERIC_PRESSURE,
|
||||
DEVICE_CLASS_CARBON_DIOXIDE,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
||||
ICON_GAS_CYLINDER,
|
||||
ICON_GAUGE,
|
||||
ICON_THERMOMETER,
|
||||
@@ -32,7 +34,6 @@ CONF_CO2_EQUIVALENT = "co2_equivalent"
|
||||
CONF_IAQ = "iaq"
|
||||
CONF_IAQ_STATIC = "iaq_static"
|
||||
ICON_ACCURACY = "mdi:checkbox-marked-circle-outline"
|
||||
ICON_TEST_TUBE = "mdi:test-tube"
|
||||
UNIT_IAQ = "IAQ"
|
||||
|
||||
TYPES = [
|
||||
@@ -61,7 +62,6 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
),
|
||||
cv.Optional(CONF_PRESSURE): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_HECTOPASCAL,
|
||||
icon=ICON_GAUGE,
|
||||
accuracy_decimals=1,
|
||||
device_class=DEVICE_CLASS_ATMOSPHERIC_PRESSURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
@@ -102,14 +102,14 @@ CONFIG_SCHEMA = cv.Schema(
|
||||
),
|
||||
cv.Optional(CONF_CO2_EQUIVALENT): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_PARTS_PER_MILLION,
|
||||
icon=ICON_TEST_TUBE,
|
||||
accuracy_decimals=1,
|
||||
device_class=DEVICE_CLASS_CARBON_DIOXIDE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
cv.Optional(CONF_BREATH_VOC_EQUIVALENT): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_PARTS_PER_MILLION,
|
||||
icon=ICON_TEST_TUBE,
|
||||
accuracy_decimals=1,
|
||||
device_class=DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
}
|
||||
|
||||
@@ -126,37 +126,37 @@ void BMI160Component::internal_setup_(int stage) {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, " Bringing accelerometer out of sleep...");
|
||||
ESP_LOGV(TAG, " Bringing accelerometer out of sleep");
|
||||
if (!this->write_byte(BMI160_REGISTER_CMD, (uint8_t) Cmd::ACCL_SET_PMU_MODE | (uint8_t) AcclPmuMode::NORMAL)) {
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
ESP_LOGV(TAG, " Waiting for accelerometer to wake up...");
|
||||
ESP_LOGV(TAG, " Waiting for accelerometer to wake up");
|
||||
// need to wait (max delay in datasheet) because we can't send commands while another is in progress
|
||||
// min 5ms, 10ms
|
||||
this->set_timeout(10, [this]() { this->internal_setup_(1); });
|
||||
break;
|
||||
|
||||
case 1:
|
||||
ESP_LOGV(TAG, " Bringing gyroscope out of sleep...");
|
||||
ESP_LOGV(TAG, " Bringing gyroscope out of sleep");
|
||||
if (!this->write_byte(BMI160_REGISTER_CMD, (uint8_t) Cmd::GYRO_SET_PMU_MODE | (uint8_t) GyroPmuMode::NORMAL)) {
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
ESP_LOGV(TAG, " Waiting for gyroscope to wake up...");
|
||||
ESP_LOGV(TAG, " Waiting for gyroscope to wake up");
|
||||
// wait between 51 & 81ms, doing 100 to be safe
|
||||
this->set_timeout(10, [this]() { this->internal_setup_(2); });
|
||||
break;
|
||||
|
||||
case 2:
|
||||
ESP_LOGV(TAG, " Setting up Gyro Config...");
|
||||
ESP_LOGV(TAG, " Setting up Gyro Config");
|
||||
uint8_t gyro_config = (uint8_t) GyroBandwidth::OSR4 | (uint8_t) GyroOuputDataRate::HZ_25;
|
||||
ESP_LOGV(TAG, " Output gyro_config: 0b" BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(gyro_config));
|
||||
if (!this->write_byte(BMI160_REGISTER_GYRO_CONFIG, gyro_config)) {
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
ESP_LOGV(TAG, " Setting up Gyro Range...");
|
||||
ESP_LOGV(TAG, " Setting up Gyro Range");
|
||||
uint8_t gyro_range = (uint8_t) GyroRange::RANGE_2000_DPS;
|
||||
ESP_LOGV(TAG, " Output gyro_range: 0b" BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(gyro_range));
|
||||
if (!this->write_byte(BMI160_REGISTER_GYRO_RANGE, gyro_range)) {
|
||||
@@ -164,7 +164,7 @@ void BMI160Component::internal_setup_(int stage) {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, " Setting up Accel Config...");
|
||||
ESP_LOGV(TAG, " Setting up Accel Config");
|
||||
uint8_t accel_config =
|
||||
(uint8_t) AcclFilterMode::PERF | (uint8_t) AcclBandwidth::RES_AVG16 | (uint8_t) AccelOutputDataRate::HZ_25;
|
||||
ESP_LOGV(TAG, " Output accel_config: 0b" BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(accel_config));
|
||||
@@ -172,7 +172,7 @@ void BMI160Component::internal_setup_(int stage) {
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
ESP_LOGV(TAG, " Setting up Accel Range...");
|
||||
ESP_LOGV(TAG, " Setting up Accel Range");
|
||||
uint8_t accel_range = (uint8_t) AccelRange::RANGE_16G;
|
||||
ESP_LOGV(TAG, " Output accel_range: 0b" BYTE_TO_BINARY_PATTERN, BYTE_TO_BINARY(accel_range));
|
||||
if (!this->write_byte(BMI160_REGISTER_ACCEL_RANGE, accel_range)) {
|
||||
@@ -219,7 +219,7 @@ void BMI160Component::update() {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, " Updating BMI160...");
|
||||
ESP_LOGV(TAG, " Updating BMI160");
|
||||
int16_t data[6];
|
||||
if (this->read_le_int16_(BMI160_REGISTER_DATA_GYRO_X_LSB, data, 6) != i2c::ERROR_OK) {
|
||||
this->status_set_warning();
|
||||
|
||||
@@ -129,7 +129,7 @@ void BMP085Component::read_pressure_() {
|
||||
this->status_clear_warning();
|
||||
}
|
||||
bool BMP085Component::set_mode_(uint8_t mode) {
|
||||
ESP_LOGV(TAG, "Setting mode to 0x%02X...", mode);
|
||||
ESP_LOGV(TAG, "Setting mode to 0x%02X", mode);
|
||||
return this->write_byte(BMP085_REGISTER_CONTROL, mode);
|
||||
}
|
||||
float BMP085Component::get_setup_priority() const { return setup_priority::DATA; }
|
||||
|
||||
@@ -155,7 +155,7 @@ inline uint8_t oversampling_to_time(BMP280Oversampling over_sampling) { return (
|
||||
|
||||
void BMP280Component::update() {
|
||||
// Enable sensor
|
||||
ESP_LOGV(TAG, "Sending conversion request...");
|
||||
ESP_LOGV(TAG, "Sending conversion request");
|
||||
uint8_t meas_value = 0;
|
||||
meas_value |= (this->temperature_oversampling_ & 0b111) << 5;
|
||||
meas_value |= (this->pressure_oversampling_ & 0b111) << 2;
|
||||
|
||||
@@ -73,7 +73,7 @@ void BMP3XXComponent::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
// Call the Device base class "initialise" function
|
||||
if (!reset()) {
|
||||
ESP_LOGE(TAG, "Failed to reset BMP3XX...");
|
||||
ESP_LOGE(TAG, "Failed to reset");
|
||||
this->error_code_ = ERROR_SENSOR_RESET;
|
||||
this->mark_failed();
|
||||
}
|
||||
@@ -157,16 +157,14 @@ void BMP3XXComponent::dump_config() {
|
||||
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
|
||||
break;
|
||||
case ERROR_WRONG_CHIP_ID:
|
||||
ESP_LOGE(
|
||||
TAG,
|
||||
"BMP3XX has wrong chip ID (reported id: 0x%X) - please check if you are really using a BMP 388 or BMP 390",
|
||||
this->chip_id_.reg);
|
||||
ESP_LOGE(TAG, "Wrong chip ID (reported id: 0x%X) - please check if you are really using a BMP 388 or BMP 390",
|
||||
this->chip_id_.reg);
|
||||
break;
|
||||
case ERROR_SENSOR_RESET:
|
||||
ESP_LOGE(TAG, "BMP3XX failed to reset");
|
||||
ESP_LOGE(TAG, "Failed to reset");
|
||||
break;
|
||||
default:
|
||||
ESP_LOGE(TAG, "BMP3XX error code %d", (int) this->error_code_);
|
||||
ESP_LOGE(TAG, "Error code %d", (int) this->error_code_);
|
||||
break;
|
||||
}
|
||||
ESP_LOGCONFIG(TAG, " IIR Filter: %s", LOG_STR_ARG(iir_filter_to_str(this->iir_filter_)));
|
||||
@@ -186,7 +184,7 @@ inline uint8_t oversampling_to_time(Oversampling over_sampling) { return (1 << u
|
||||
|
||||
void BMP3XXComponent::update() {
|
||||
// Enable sensor
|
||||
ESP_LOGV(TAG, "Sending conversion request...");
|
||||
ESP_LOGV(TAG, "Sending conversion request");
|
||||
float meas_time = 1.0f;
|
||||
// Ref: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp390-ds002.pdf 3.9.2
|
||||
meas_time += 2.02f * oversampling_to_time(this->temperature_oversampling_) + 0.163f;
|
||||
@@ -296,7 +294,7 @@ bool BMP3XXComponent::get_pressure(float &pressure) {
|
||||
bool BMP3XXComponent::get_measurements(float &temperature, float &pressure) {
|
||||
// Check if a measurement is ready
|
||||
if (!data_ready()) {
|
||||
ESP_LOGD(TAG, "BMP3XX Get measurement - data not ready skipping update");
|
||||
ESP_LOGD(TAG, "Get measurement - data not ready skipping update");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -72,22 +72,22 @@ void BMP581Component::dump_config() {
|
||||
case NONE:
|
||||
break;
|
||||
case ERROR_COMMUNICATION_FAILED:
|
||||
ESP_LOGE(TAG, " Communication with BMP581 failed!");
|
||||
ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
|
||||
break;
|
||||
case ERROR_WRONG_CHIP_ID:
|
||||
ESP_LOGE(TAG, " BMP581 has wrong chip ID - please verify you are using a BMP 581");
|
||||
ESP_LOGE(TAG, "Unknown chip ID");
|
||||
break;
|
||||
case ERROR_SENSOR_RESET:
|
||||
ESP_LOGE(TAG, " BMP581 failed to reset");
|
||||
ESP_LOGE(TAG, "Reset failed");
|
||||
break;
|
||||
case ERROR_SENSOR_STATUS:
|
||||
ESP_LOGE(TAG, " BMP581 sensor status failed, there were NVM problems");
|
||||
ESP_LOGE(TAG, "Get status failed");
|
||||
break;
|
||||
case ERROR_PRIME_IIR_FAILED:
|
||||
ESP_LOGE(TAG, " BMP581's IIR Filter failed to prime with an initial measurement");
|
||||
ESP_LOGE(TAG, "IIR Filter failed to prime with initial measurement");
|
||||
break;
|
||||
default:
|
||||
ESP_LOGE(TAG, " BMP581 error code %d", (int) this->error_code_);
|
||||
ESP_LOGE(TAG, "Error %d", (int) this->error_code_);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ void BMP581Component::setup() {
|
||||
|
||||
// Power-On-Reboot bit is asserted if sensor successfully reset
|
||||
if (!this->reset_()) {
|
||||
ESP_LOGE(TAG, "BMP581 failed to reset");
|
||||
ESP_LOGE(TAG, "Reset failed");
|
||||
|
||||
this->error_code_ = ERROR_SENSOR_RESET;
|
||||
this->mark_failed();
|
||||
@@ -146,7 +146,7 @@ void BMP581Component::setup() {
|
||||
|
||||
// read chip id from sensor
|
||||
if (!this->read_byte(BMP581_CHIP_ID, &chip_id)) {
|
||||
ESP_LOGE(TAG, "Failed to read chip id");
|
||||
ESP_LOGE(TAG, "Read chip ID failed");
|
||||
|
||||
this->error_code_ = ERROR_COMMUNICATION_FAILED;
|
||||
this->mark_failed();
|
||||
@@ -156,7 +156,7 @@ void BMP581Component::setup() {
|
||||
|
||||
// verify id
|
||||
if (chip_id != BMP581_ASIC_ID) {
|
||||
ESP_LOGE(TAG, "Unknown chip ID, is this a BMP581?");
|
||||
ESP_LOGE(TAG, "Unknown chip ID");
|
||||
|
||||
this->error_code_ = ERROR_WRONG_CHIP_ID;
|
||||
this->mark_failed();
|
||||
@@ -179,7 +179,7 @@ void BMP581Component::setup() {
|
||||
|
||||
// verify status_nvm_rdy bit (it is asserted if boot was successful)
|
||||
if (!(this->status_.bit.status_nvm_rdy)) {
|
||||
ESP_LOGE(TAG, "NVM not ready after boot");
|
||||
ESP_LOGE(TAG, "NVM not ready");
|
||||
|
||||
this->error_code_ = ERROR_SENSOR_STATUS;
|
||||
this->mark_failed();
|
||||
@@ -189,7 +189,7 @@ void BMP581Component::setup() {
|
||||
|
||||
// verify status_nvm_err bit (it is asserted if an error is detected)
|
||||
if (this->status_.bit.status_nvm_err) {
|
||||
ESP_LOGE(TAG, "NVM error detected on boot");
|
||||
ESP_LOGE(TAG, "NVM error detected");
|
||||
|
||||
this->error_code_ = ERROR_SENSOR_STATUS;
|
||||
this->mark_failed();
|
||||
@@ -254,7 +254,7 @@ void BMP581Component::setup() {
|
||||
}
|
||||
|
||||
if (!this->prime_iir_filter_()) {
|
||||
ESP_LOGE(TAG, "Failed to prime the IIR filter with an intiial measurement");
|
||||
ESP_LOGE(TAG, "Failed to prime the IIR filter with an initial measurement");
|
||||
|
||||
this->error_code_ = ERROR_PRIME_IIR_FAILED;
|
||||
this->mark_failed();
|
||||
@@ -286,10 +286,10 @@ void BMP581Component::update() {
|
||||
// 1) Request a measurement //
|
||||
//////////////////////////////
|
||||
|
||||
ESP_LOGVV(TAG, "Requesting a measurement from sensor");
|
||||
ESP_LOGVV(TAG, "Requesting measurement");
|
||||
|
||||
if (!this->start_measurement_()) {
|
||||
ESP_LOGW(TAG, "Failed to request forced measurement of sensor");
|
||||
ESP_LOGW(TAG, "Requesting forced measurement failed");
|
||||
this->status_set_warning();
|
||||
|
||||
return;
|
||||
@@ -299,7 +299,7 @@ void BMP581Component::update() {
|
||||
// 2) Wait for measurement to finish (based on oversampling rates) //
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
ESP_LOGVV(TAG, "Measurement is expected to take %d ms to complete", this->conversion_time_);
|
||||
ESP_LOGVV(TAG, "Measurement should take %d ms", this->conversion_time_);
|
||||
|
||||
this->set_timeout("measurement", this->conversion_time_, [this]() {
|
||||
float temperature = 0.0;
|
||||
@@ -311,14 +311,14 @@ void BMP581Component::update() {
|
||||
|
||||
if (this->pressure_sensor_) {
|
||||
if (!this->read_temperature_and_pressure_(temperature, pressure)) {
|
||||
ESP_LOGW(TAG, "Failed to read temperature and pressure measurements, skipping update");
|
||||
ESP_LOGW(TAG, "Failed to read temperature and pressure; skipping update");
|
||||
this->status_set_warning();
|
||||
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!this->read_temperature_(temperature)) {
|
||||
ESP_LOGW(TAG, "Failed to read temperature measurement, skipping update");
|
||||
ESP_LOGW(TAG, "Failed to read temperature; skipping update");
|
||||
this->status_set_warning();
|
||||
|
||||
return;
|
||||
@@ -349,7 +349,7 @@ bool BMP581Component::check_data_readiness_() {
|
||||
// - returns data readiness state
|
||||
|
||||
if (this->odr_config_.bit.pwr_mode == STANDBY_MODE) {
|
||||
ESP_LOGD(TAG, "Data is not ready, sensor is in standby mode");
|
||||
ESP_LOGD(TAG, "Data not ready, sensor is in standby mode");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -443,7 +443,7 @@ bool BMP581Component::read_temperature_(float &temperature) {
|
||||
// - the measured temperature (in degrees Celsius)
|
||||
|
||||
if (!this->check_data_readiness_()) {
|
||||
ESP_LOGW(TAG, "Data from sensor isn't ready, skipping this update");
|
||||
ESP_LOGW(TAG, "Data not ready, skipping this update");
|
||||
this->status_set_warning();
|
||||
|
||||
return false;
|
||||
@@ -451,7 +451,7 @@ bool BMP581Component::read_temperature_(float &temperature) {
|
||||
|
||||
uint8_t data[3];
|
||||
if (!this->read_bytes(BMP581_MEASUREMENT_DATA, &data[0], 3)) {
|
||||
ESP_LOGW(TAG, "Failed to read sensor's measurement data");
|
||||
ESP_LOGW(TAG, "Failed to read measurement");
|
||||
this->status_set_warning();
|
||||
|
||||
return false;
|
||||
@@ -472,7 +472,7 @@ bool BMP581Component::read_temperature_and_pressure_(float &temperature, float &
|
||||
// - the measured pressure (in Pa)
|
||||
|
||||
if (!this->check_data_readiness_()) {
|
||||
ESP_LOGW(TAG, "Data from sensor isn't ready, skipping this update");
|
||||
ESP_LOGW(TAG, "Data not ready, skipping this update");
|
||||
this->status_set_warning();
|
||||
|
||||
return false;
|
||||
@@ -480,7 +480,7 @@ bool BMP581Component::read_temperature_and_pressure_(float &temperature, float &
|
||||
|
||||
uint8_t data[6];
|
||||
if (!this->read_bytes(BMP581_MEASUREMENT_DATA, &data[0], 6)) {
|
||||
ESP_LOGW(TAG, "Failed to read sensor's measurement data");
|
||||
ESP_LOGW(TAG, "Failed to read measurement");
|
||||
this->status_set_warning();
|
||||
|
||||
return false;
|
||||
|
||||
@@ -38,7 +38,7 @@ void CM1106Component::update() {
|
||||
}
|
||||
|
||||
if (response[0] != 0x16 || response[1] != 0x05 || response[2] != 0x01) {
|
||||
ESP_LOGW(TAG, "Got wrong UART response from CM1106: %02X %02X %02X %02X...", response[0], response[1], response[2],
|
||||
ESP_LOGW(TAG, "Got wrong UART response from CM1106: %02X %02X %02X %02X", response[0], response[1], response[2],
|
||||
response[3]);
|
||||
this->status_set_warning();
|
||||
return;
|
||||
|
||||
@@ -22,7 +22,7 @@ static const uint8_t DAC7678_REG_INTERNAL_REF_1 = 0x90;
|
||||
void DAC7678Output::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
ESP_LOGV(TAG, "Resetting device...");
|
||||
ESP_LOGV(TAG, "Resetting device");
|
||||
|
||||
// Reset device
|
||||
if (!this->write_byte_16(DAC7678_REG_SOFTWARE_RESET, 0x0000)) {
|
||||
|
||||
@@ -15,10 +15,6 @@ namespace debug {
|
||||
static const char *const TAG = "debug";
|
||||
|
||||
void DebugComponent::dump_config() {
|
||||
#ifndef ESPHOME_LOG_HAS_DEBUG
|
||||
return; // Can't log below if debug logging is disabled
|
||||
#endif
|
||||
|
||||
ESP_LOGCONFIG(TAG, "Debug component:");
|
||||
#ifdef USE_TEXT_SENSOR
|
||||
LOG_TEXT_SENSOR(" ", "Device info", this->device_info_);
|
||||
|
||||
@@ -21,7 +21,7 @@ uint8_t Command::execute(DfrobotSen0395Component *parent) {
|
||||
if (this->retries_left_ > 0) {
|
||||
this->retries_left_ -= 1;
|
||||
this->cmd_sent_ = false;
|
||||
ESP_LOGD(TAG, "Retrying...");
|
||||
ESP_LOGD(TAG, "Retrying");
|
||||
return 0;
|
||||
} else {
|
||||
this->parent_->find_prompt_();
|
||||
@@ -33,7 +33,7 @@ uint8_t Command::execute(DfrobotSen0395Component *parent) {
|
||||
if (this->retries_left_ > 0) {
|
||||
this->retries_left_ -= 1;
|
||||
this->cmd_sent_ = false;
|
||||
ESP_LOGD(TAG, "Retrying...");
|
||||
ESP_LOGD(TAG, "Retrying");
|
||||
return 0;
|
||||
} else {
|
||||
this->parent_->find_prompt_();
|
||||
@@ -51,7 +51,7 @@ uint8_t Command::execute(DfrobotSen0395Component *parent) {
|
||||
if (this->retries_left_ > 0) {
|
||||
this->retries_left_ -= 1;
|
||||
this->cmd_sent_ = false;
|
||||
ESP_LOGD(TAG, "Retrying...");
|
||||
ESP_LOGD(TAG, "Retrying");
|
||||
} else {
|
||||
return 1; // Command done
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class ESP32Preferences : public ESPPreferences {
|
||||
if (err == 0)
|
||||
return;
|
||||
|
||||
ESP_LOGW(TAG, "nvs_open failed: %s - erasing NVS...", esp_err_to_name(err));
|
||||
ESP_LOGW(TAG, "nvs_open failed: %s - erasing NVS", esp_err_to_name(err));
|
||||
nvs_flash_deinit();
|
||||
nvs_flash_erase();
|
||||
nvs_flash_init();
|
||||
@@ -111,7 +111,7 @@ class ESP32Preferences : public ESPPreferences {
|
||||
if (s_pending_save.empty())
|
||||
return true;
|
||||
|
||||
ESP_LOGD(TAG, "Saving %d preferences to flash...", s_pending_save.size());
|
||||
ESP_LOGV(TAG, "Saving %d items...", s_pending_save.size());
|
||||
// goal try write all pending saves even if one fails
|
||||
int cached = 0, written = 0, failed = 0;
|
||||
esp_err_t last_err = ESP_OK;
|
||||
@@ -139,10 +139,10 @@ class ESP32Preferences : public ESPPreferences {
|
||||
}
|
||||
s_pending_save.erase(s_pending_save.begin() + i);
|
||||
}
|
||||
ESP_LOGD(TAG, "Saving %d preferences to flash: %d cached, %d written, %d failed", cached + written + failed, cached,
|
||||
written, failed);
|
||||
ESP_LOGD(TAG, "Writing %d items: %d cached, %d written, %d failed", cached + written + failed, cached, written,
|
||||
failed);
|
||||
if (failed > 0) {
|
||||
ESP_LOGE(TAG, "Error saving %d preferences to flash. Last error=%s for key=%s", failed, esp_err_to_name(last_err),
|
||||
ESP_LOGE(TAG, "Writing %d items failed. Last error=%s for key=%s", failed, esp_err_to_name(last_err),
|
||||
last_key.c_str());
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ class ESP32Preferences : public ESPPreferences {
|
||||
}
|
||||
|
||||
bool reset() override {
|
||||
ESP_LOGD(TAG, "Cleaning up preferences in flash...");
|
||||
ESP_LOGD(TAG, "Erasing storage");
|
||||
s_pending_save.clear();
|
||||
|
||||
nvs_flash_deinit();
|
||||
|
||||
@@ -270,14 +270,14 @@ void ESP32BLE::loop() {
|
||||
case BLE_COMPONENT_STATE_DISABLED:
|
||||
return;
|
||||
case BLE_COMPONENT_STATE_DISABLE: {
|
||||
ESP_LOGD(TAG, "Disabling BLE...");
|
||||
ESP_LOGD(TAG, "Disabling");
|
||||
|
||||
for (auto *ble_event_handler : this->ble_status_event_handlers_) {
|
||||
ble_event_handler->ble_before_disabled_event_handler();
|
||||
}
|
||||
|
||||
if (!ble_dismantle_()) {
|
||||
ESP_LOGE(TAG, "BLE could not be dismantled");
|
||||
ESP_LOGE(TAG, "Could not be dismantled");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
@@ -285,11 +285,11 @@ void ESP32BLE::loop() {
|
||||
return;
|
||||
}
|
||||
case BLE_COMPONENT_STATE_ENABLE: {
|
||||
ESP_LOGD(TAG, "Enabling BLE...");
|
||||
ESP_LOGD(TAG, "Enabling");
|
||||
this->state_ = BLE_COMPONENT_STATE_OFF;
|
||||
|
||||
if (!ble_setup_()) {
|
||||
ESP_LOGE(TAG, "BLE could not be set up");
|
||||
ESP_LOGE(TAG, "Could not be set up");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ void ESP32BLETracker::loop() {
|
||||
(this->scan_set_param_failed_ && this->scanner_state_ == ScannerState::RUNNING)) {
|
||||
this->stop_scan_();
|
||||
if (this->scan_start_fail_count_ == std::numeric_limits<uint8_t>::max()) {
|
||||
ESP_LOGE(TAG, "ESP-IDF BLE scan could not restart after %d attempts, rebooting to restore BLE stack...",
|
||||
ESP_LOGE(TAG, "Scan could not restart after %d attempts, rebooting to restore stack (IDF)",
|
||||
std::numeric_limits<uint8_t>::max());
|
||||
App.reboot();
|
||||
}
|
||||
@@ -219,10 +219,10 @@ void ESP32BLETracker::loop() {
|
||||
for (auto *client : this->clients_) {
|
||||
if (client->state() == ClientState::DISCOVERED) {
|
||||
if (this->scanner_state_ == ScannerState::RUNNING) {
|
||||
ESP_LOGD(TAG, "Stopping scan to make connection...");
|
||||
ESP_LOGD(TAG, "Stopping scan to make connection");
|
||||
this->stop_scan_();
|
||||
} else if (this->scanner_state_ == ScannerState::IDLE) {
|
||||
ESP_LOGD(TAG, "Promoting client to connect...");
|
||||
ESP_LOGD(TAG, "Promoting client to connect");
|
||||
// We only want to promote one client at a time.
|
||||
// once the scanner is fully stopped.
|
||||
#ifdef USE_ESP32_BLE_SOFTWARE_COEXISTENCE
|
||||
@@ -306,7 +306,7 @@ void ESP32BLETracker::start_scan_(bool first) {
|
||||
|
||||
// Start timeout before scan is started. Otherwise scan never starts if any error.
|
||||
this->set_timeout("scan", this->scan_duration_ * 2000, []() {
|
||||
ESP_LOGE(TAG, "ESP-IDF BLE scan never terminated, rebooting to restore BLE stack...");
|
||||
ESP_LOGE(TAG, "Scan never terminated, rebooting to restore stack (IDF)");
|
||||
App.reboot();
|
||||
});
|
||||
|
||||
|
||||
125
esphome/components/esp32_hosted/__init__.py
Normal file
125
esphome/components/esp32_hosted/__init__.py
Normal file
@@ -0,0 +1,125 @@
|
||||
import os
|
||||
|
||||
from esphome import pins
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import esp32
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_CLK_PIN,
|
||||
CONF_ID,
|
||||
CONF_RESET_PIN,
|
||||
CONF_VARIANT,
|
||||
KEY_CORE,
|
||||
KEY_FRAMEWORK_VERSION,
|
||||
)
|
||||
from esphome.core import CORE
|
||||
|
||||
CODEOWNERS = ["@swoboda1337"]
|
||||
AUTO_LOAD = ["esp32"]
|
||||
|
||||
esp32_hosted_ns = cg.esphome_ns.namespace("esp32_hosted")
|
||||
ESP32Hosted = esp32_hosted_ns.class_("ESP32Hosted", cg.Component)
|
||||
|
||||
CONF_ACTIVE_HIGH = "active_high"
|
||||
CONF_CMD_PIN = "cmd_pin"
|
||||
CONF_D0_PIN = "d0_pin"
|
||||
CONF_D1_PIN = "d1_pin"
|
||||
CONF_D2_PIN = "d2_pin"
|
||||
CONF_D3_PIN = "d3_pin"
|
||||
CONF_SLOT = "slot"
|
||||
|
||||
VARIANTS_WITHOUT_WIFI = {
|
||||
esp32.VARIANT_ESP32H2,
|
||||
esp32.VARIANT_ESP32P4,
|
||||
}
|
||||
|
||||
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(ESP32Hosted),
|
||||
cv.Required(CONF_VARIANT): cv.one_of(*esp32.VARIANTS, upper=True),
|
||||
cv.Optional(CONF_ACTIVE_HIGH, default=True): cv.boolean,
|
||||
cv.Required(CONF_CLK_PIN): pins.internal_gpio_output_pin_number,
|
||||
cv.Required(CONF_CMD_PIN): pins.internal_gpio_output_pin_number,
|
||||
cv.Required(CONF_D0_PIN): pins.internal_gpio_output_pin_number,
|
||||
cv.Required(CONF_D1_PIN): pins.internal_gpio_output_pin_number,
|
||||
cv.Required(CONF_D2_PIN): pins.internal_gpio_output_pin_number,
|
||||
cv.Required(CONF_D3_PIN): pins.internal_gpio_output_pin_number,
|
||||
cv.Required(CONF_RESET_PIN): pins.internal_gpio_output_pin_number,
|
||||
cv.Optional(CONF_SLOT, default=1): cv.int_range(min=0, max=1),
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
|
||||
framework_ver: cv.Version = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
|
||||
|
||||
if config[CONF_ACTIVE_HIGH]:
|
||||
esp32.add_idf_sdkconfig_option("CONFIG_ESP_HOSTED_SDIO_RESET_ACTIVE_HIGH", True)
|
||||
else:
|
||||
esp32.add_idf_sdkconfig_option("CONFIG_ESP_HOSTED_SDIO_RESET_ACTIVE_LOW", True)
|
||||
|
||||
esp32.add_idf_sdkconfig_option(
|
||||
f"CONFIG_SLAVE_IDF_TARGET_{config[CONF_VARIANT]}", # NOLINT
|
||||
True,
|
||||
)
|
||||
|
||||
esp32.add_idf_sdkconfig_option(
|
||||
f"CONFIG_ESP_HOSTED_SDIO_SLOT_{config[CONF_SLOT]}", True
|
||||
)
|
||||
|
||||
esp32.add_idf_sdkconfig_option(
|
||||
f"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_CLK_SLOT_{config[CONF_SLOT]}",
|
||||
config[CONF_CLK_PIN],
|
||||
)
|
||||
|
||||
esp32.add_idf_sdkconfig_option(
|
||||
f"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_CMD_SLOT_{config[CONF_SLOT]}",
|
||||
config[CONF_CMD_PIN],
|
||||
)
|
||||
|
||||
esp32.add_idf_sdkconfig_option(
|
||||
f"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_D0_SLOT_{config[CONF_SLOT]}",
|
||||
config[CONF_D0_PIN],
|
||||
)
|
||||
|
||||
esp32.add_idf_sdkconfig_option(
|
||||
f"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_D1_4BIT_BUS_SLOT_{config[CONF_SLOT]}",
|
||||
config[CONF_D1_PIN],
|
||||
)
|
||||
|
||||
esp32.add_idf_sdkconfig_option(
|
||||
f"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_D2_4BIT_BUS_SLOT_{config[CONF_SLOT]}",
|
||||
config[CONF_D2_PIN],
|
||||
)
|
||||
|
||||
esp32.add_idf_sdkconfig_option(
|
||||
f"CONFIG_ESP_HOSTED_PRIV_SDIO_PIN_D3_4BIT_BUS_SLOT_{config[CONF_SLOT]}",
|
||||
config[CONF_D3_PIN],
|
||||
)
|
||||
|
||||
esp32.add_idf_sdkconfig_option(
|
||||
"CONFIG_ESP_HOSTED_SDIO_GPIO_RESET_SLAVE", # NOLINT
|
||||
config[CONF_RESET_PIN],
|
||||
)
|
||||
|
||||
os.environ["ESP_IDF_VERSION"] = f"{framework_ver.major}.{framework_ver.minor}"
|
||||
|
||||
if config[CONF_VARIANT] not in VARIANTS_WITHOUT_WIFI:
|
||||
esp32.add_idf_component(
|
||||
name="esp_wifi_remote",
|
||||
repo="https://github.com/espressif/esp-wifi-remote.git",
|
||||
path="components/esp_wifi_remote",
|
||||
ref="wifi_remote-v0.10.2",
|
||||
)
|
||||
|
||||
esp32.add_extra_script(
|
||||
"post",
|
||||
"esp32_hosted.py",
|
||||
os.path.join(os.path.dirname(__file__), "esp32_hosted.py.script"),
|
||||
)
|
||||
53
esphome/components/esp32_hosted/esp32_hosted.cpp
Normal file
53
esphome/components/esp32_hosted/esp32_hosted.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "esp32_hosted.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#ifdef USE_ESP32
|
||||
|
||||
#ifdef USE_ESP32_BLE
|
||||
#include <esp_bluedroid_hci.h>
|
||||
#include <hosted_hci_bluedroid.h>
|
||||
#endif
|
||||
|
||||
namespace esphome {
|
||||
namespace esp32_hosted {
|
||||
|
||||
static const char *const TAG = "esp32_hosted";
|
||||
|
||||
void ESP32Hosted::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Setting up ESP32 Hosted...");
|
||||
|
||||
#ifdef USE_ESP32_BLE
|
||||
// Initialize Bluetooth if esp32_ble component is enabled
|
||||
this->init_bluetooth_();
|
||||
#else
|
||||
ESP_LOGD(TAG, "Bluetooth support disabled (esp32_ble not included)");
|
||||
#endif
|
||||
}
|
||||
|
||||
void ESP32Hosted::dump_config() { ESP_LOGCONFIG(TAG, "ESP32 Hosted:"); }
|
||||
|
||||
#ifdef USE_ESP32_BLE
|
||||
void ESP32Hosted::init_bluetooth_() {
|
||||
ESP_LOGD(TAG, "Initializing Bluetooth...");
|
||||
|
||||
// Initialize TRANSPORT first
|
||||
hosted_hci_bluedroid_open();
|
||||
|
||||
// Get HCI driver operations
|
||||
esp_bluedroid_hci_driver_operations_t operations = {
|
||||
.send = hosted_hci_bluedroid_send,
|
||||
.check_send_available = hosted_hci_bluedroid_check_send_available,
|
||||
.register_host_callback = hosted_hci_bluedroid_register_host_callback,
|
||||
};
|
||||
|
||||
// Attach HCI driver
|
||||
esp_bluedroid_attach_hci_driver(&operations);
|
||||
|
||||
ESP_LOGD(TAG, "Bluetooth initialized successfully");
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace esp32_hosted
|
||||
} // namespace esphome
|
||||
|
||||
#endif // USE_ESP32
|
||||
26
esphome/components/esp32_hosted/esp32_hosted.h
Normal file
26
esphome/components/esp32_hosted/esp32_hosted.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
#ifdef USE_ESP32
|
||||
|
||||
namespace esphome {
|
||||
namespace esp32_hosted {
|
||||
|
||||
class ESP32Hosted : public Component {
|
||||
public:
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
||||
|
||||
protected:
|
||||
#ifdef USE_ESP32_BLE
|
||||
void init_bluetooth_();
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace esp32_hosted
|
||||
} // namespace esphome
|
||||
|
||||
#endif // USE_ESP32
|
||||
12
esphome/components/esp32_hosted/esp32_hosted.py.script
Normal file
12
esphome/components/esp32_hosted/esp32_hosted.py.script
Normal file
@@ -0,0 +1,12 @@
|
||||
# pylint: disable=E0602
|
||||
Import("env") # noqa
|
||||
|
||||
# Workaround whole archive issue
|
||||
if "__LIB_DEPS" in env and "libespressif__esp_hosted.a" in env["__LIB_DEPS"]:
|
||||
env.Append(
|
||||
LINKFLAGS=[
|
||||
"-Wl,--whole-archive",
|
||||
env["BUILD_DIR"] + "/esp-idf/espressif__esp_hosted/libespressif__esp_hosted.a",
|
||||
"-Wl,--no-whole-archive",
|
||||
]
|
||||
)
|
||||
@@ -324,10 +324,10 @@ void ESP32ImprovComponent::process_incoming_data_() {
|
||||
this->incoming_data_.clear();
|
||||
}
|
||||
} else if (this->incoming_data_.size() - 2 > length) {
|
||||
ESP_LOGV(TAG, "Too much data received or data malformed; resetting buffer...");
|
||||
ESP_LOGV(TAG, "Too much data received or data malformed; resetting buffer");
|
||||
this->incoming_data_.clear();
|
||||
} else {
|
||||
ESP_LOGV(TAG, "Waiting for split data packets...");
|
||||
ESP_LOGV(TAG, "Waiting for split data packets");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ void ESP32RMTLEDStripLightOutput::write_state(light::LightState *state) {
|
||||
this->last_refresh_ = now;
|
||||
this->mark_shown_();
|
||||
|
||||
ESP_LOGVV(TAG, "Writing RGB values to bus...");
|
||||
ESP_LOGVV(TAG, "Writing RGB values to bus");
|
||||
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
esp_err_t error = rmt_tx_wait_all_done(this->channel_, 1000);
|
||||
|
||||
@@ -40,6 +40,7 @@ struct ISRPinArg {
|
||||
volatile uint32_t *mode_set_reg;
|
||||
volatile uint32_t *mode_clr_reg;
|
||||
volatile uint32_t *func_reg;
|
||||
volatile uint32_t *control_reg;
|
||||
uint32_t mask;
|
||||
};
|
||||
|
||||
@@ -54,6 +55,7 @@ ISRInternalGPIOPin ESP8266GPIOPin::to_isr() const {
|
||||
arg->mode_set_reg = &GPES;
|
||||
arg->mode_clr_reg = &GPEC;
|
||||
arg->func_reg = &GPF(this->pin_);
|
||||
arg->control_reg = &GPC(this->pin_);
|
||||
arg->mask = 1 << this->pin_;
|
||||
} else {
|
||||
arg->in_reg = &GP16I;
|
||||
@@ -62,6 +64,7 @@ ISRInternalGPIOPin ESP8266GPIOPin::to_isr() const {
|
||||
arg->mode_set_reg = &GP16E;
|
||||
arg->mode_clr_reg = nullptr;
|
||||
arg->func_reg = &GPF16;
|
||||
arg->control_reg = nullptr;
|
||||
arg->mask = 1;
|
||||
}
|
||||
return ISRInternalGPIOPin((void *) arg);
|
||||
@@ -143,11 +146,17 @@ void IRAM_ATTR ISRInternalGPIOPin::pin_mode(gpio::Flags flags) {
|
||||
if (arg->pin < 16) {
|
||||
if (flags & gpio::FLAG_OUTPUT) {
|
||||
*arg->mode_set_reg = arg->mask;
|
||||
} else {
|
||||
if (flags & gpio::FLAG_OPEN_DRAIN) {
|
||||
*arg->control_reg |= 1 << GPCD;
|
||||
} else {
|
||||
*arg->control_reg &= ~(1 << GPCD);
|
||||
}
|
||||
} else if (flags & gpio::FLAG_INPUT) {
|
||||
*arg->mode_clr_reg = arg->mask;
|
||||
}
|
||||
if (flags & gpio::FLAG_PULLUP) {
|
||||
*arg->func_reg |= 1 << GPFPU;
|
||||
*arg->control_reg |= 1 << GPCD;
|
||||
} else {
|
||||
*arg->func_reg &= ~(1 << GPFPU);
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ class ESP8266Preferences : public ESPPreferences {
|
||||
|
||||
void setup() {
|
||||
s_flash_storage = new uint32_t[ESP8266_FLASH_STORAGE_SIZE]; // NOLINT
|
||||
ESP_LOGVV(TAG, "Loading preferences from flash...");
|
||||
ESP_LOGVV(TAG, "Loading preferences from flash");
|
||||
|
||||
{
|
||||
InterruptLock lock;
|
||||
@@ -235,7 +235,7 @@ class ESP8266Preferences : public ESPPreferences {
|
||||
if (s_prevent_write)
|
||||
return false;
|
||||
|
||||
ESP_LOGD(TAG, "Saving preferences to flash...");
|
||||
ESP_LOGD(TAG, "Saving");
|
||||
SpiFlashOpResult erase_res, write_res = SPI_FLASH_RESULT_OK;
|
||||
{
|
||||
InterruptLock lock;
|
||||
@@ -245,11 +245,11 @@ class ESP8266Preferences : public ESPPreferences {
|
||||
}
|
||||
}
|
||||
if (erase_res != SPI_FLASH_RESULT_OK) {
|
||||
ESP_LOGE(TAG, "Erase ESP8266 flash failed!");
|
||||
ESP_LOGE(TAG, "Erasing failed");
|
||||
return false;
|
||||
}
|
||||
if (write_res != SPI_FLASH_RESULT_OK) {
|
||||
ESP_LOGE(TAG, "Write ESP8266 flash failed!");
|
||||
ESP_LOGE(TAG, "Writing failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -258,14 +258,14 @@ class ESP8266Preferences : public ESPPreferences {
|
||||
}
|
||||
|
||||
bool reset() override {
|
||||
ESP_LOGD(TAG, "Cleaning up preferences in flash...");
|
||||
ESP_LOGD(TAG, "Erasing storage");
|
||||
SpiFlashOpResult erase_res;
|
||||
{
|
||||
InterruptLock lock;
|
||||
erase_res = spi_flash_erase_sector(get_esp8266_flash_sector());
|
||||
}
|
||||
if (erase_res != SPI_FLASH_RESULT_OK) {
|
||||
ESP_LOGE(TAG, "Erase ESP8266 flash failed!");
|
||||
ESP_LOGE(TAG, "Erasing failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ void ESPHomeOTAComponent::handle_() {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "Starting update from %s...", this->client_->getpeername().c_str());
|
||||
ESP_LOGD(TAG, "Starting update from %s", this->client_->getpeername().c_str());
|
||||
this->status_set_warning();
|
||||
#ifdef USE_OTA_STATE_CALLBACK
|
||||
this->state_callback_.call(ota::OTA_STARTED, 0.0f, 0);
|
||||
|
||||
@@ -245,33 +245,33 @@ void EthernetComponent::loop() {
|
||||
switch (this->state_) {
|
||||
case EthernetComponentState::STOPPED:
|
||||
if (this->started_) {
|
||||
ESP_LOGI(TAG, "Starting ethernet connection");
|
||||
ESP_LOGI(TAG, "Starting connection");
|
||||
this->state_ = EthernetComponentState::CONNECTING;
|
||||
this->start_connect_();
|
||||
}
|
||||
break;
|
||||
case EthernetComponentState::CONNECTING:
|
||||
if (!this->started_) {
|
||||
ESP_LOGI(TAG, "Stopped ethernet connection");
|
||||
ESP_LOGI(TAG, "Stopped connection");
|
||||
this->state_ = EthernetComponentState::STOPPED;
|
||||
} else if (this->connected_) {
|
||||
// connection established
|
||||
ESP_LOGI(TAG, "Connected via Ethernet!");
|
||||
ESP_LOGI(TAG, "Connected");
|
||||
this->state_ = EthernetComponentState::CONNECTED;
|
||||
|
||||
this->dump_connect_params_();
|
||||
this->status_clear_warning();
|
||||
} else if (now - this->connect_begin_ > 15000) {
|
||||
ESP_LOGW(TAG, "Connecting via ethernet failed! Re-connecting...");
|
||||
ESP_LOGW(TAG, "Connecting failed; reconnecting");
|
||||
this->start_connect_();
|
||||
}
|
||||
break;
|
||||
case EthernetComponentState::CONNECTED:
|
||||
if (!this->started_) {
|
||||
ESP_LOGI(TAG, "Stopped ethernet connection");
|
||||
ESP_LOGI(TAG, "Stopped connection");
|
||||
this->state_ = EthernetComponentState::STOPPED;
|
||||
} else if (!this->connected_) {
|
||||
ESP_LOGW(TAG, "Connection via Ethernet lost! Re-connecting...");
|
||||
ESP_LOGW(TAG, "Connection lost; reconnecting");
|
||||
this->state_ = EthernetComponentState::CONNECTING;
|
||||
this->start_connect_();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ static const char *const TAG = "factory_reset.button";
|
||||
|
||||
void FactoryResetButton::dump_config() { LOG_BUTTON("", "Factory Reset Button", this); }
|
||||
void FactoryResetButton::press_action() {
|
||||
ESP_LOGI(TAG, "Resetting...");
|
||||
ESP_LOGI(TAG, "Resetting");
|
||||
// Let MQTT settle a bit
|
||||
delay(100); // NOLINT
|
||||
global_preferences->reset();
|
||||
|
||||
@@ -14,7 +14,7 @@ void FactoryResetSwitch::write_state(bool state) {
|
||||
this->publish_state(false);
|
||||
|
||||
if (state) {
|
||||
ESP_LOGI(TAG, "Resetting...");
|
||||
ESP_LOGI(TAG, "Resetting");
|
||||
// Let MQTT settle a bit
|
||||
delay(100); // NOLINT
|
||||
global_preferences->reset();
|
||||
|
||||
@@ -33,7 +33,7 @@ void FastLEDLightOutput::write_state(light::LightState *state) {
|
||||
this->last_refresh_ = now;
|
||||
this->mark_shown_();
|
||||
|
||||
ESP_LOGVV(TAG, "Writing RGB values to bus...");
|
||||
ESP_LOGVV(TAG, "Writing RGB values to bus");
|
||||
this->controller_->showLeds(this->state_parent_->current_values.get_brightness() * 255);
|
||||
}
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ haier_protocol::HandlerError HaierClimateBase::timeout_default_handler_(haier_pr
|
||||
}
|
||||
|
||||
void HaierClimateBase::setup() {
|
||||
ESP_LOGI(TAG, "Haier initialization...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
// Set timestamp here to give AC time to boot
|
||||
this->last_request_timestamp_ = std::chrono::steady_clock::now();
|
||||
this->set_phase(ProtocolPhases::SENDING_INIT_1);
|
||||
@@ -286,7 +286,7 @@ void HaierClimateBase::loop() {
|
||||
if (this->action_request_.has_value() && this->prepare_pending_action()) {
|
||||
this->set_phase(ProtocolPhases::SENDING_ACTION_COMMAND);
|
||||
} else if (this->next_hvac_settings_.valid || this->force_send_control_) {
|
||||
ESP_LOGV(TAG, "Control packet is pending...");
|
||||
ESP_LOGV(TAG, "Control packet is pending");
|
||||
this->set_phase(ProtocolPhases::SENDING_CONTROL);
|
||||
if (this->next_hvac_settings_.valid) {
|
||||
this->current_hvac_settings_ = this->next_hvac_settings_;
|
||||
|
||||
@@ -48,7 +48,7 @@ void OtaHttpRequestComponent::flash() {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Starting update...");
|
||||
ESP_LOGI(TAG, "Starting update");
|
||||
#ifdef USE_OTA_STATE_CALLBACK
|
||||
this->state_callback_.call(ota::OTA_STARTED, 0.0f, 0);
|
||||
#endif
|
||||
|
||||
@@ -40,7 +40,7 @@ void ArduinoI2CBus::setup() {
|
||||
|
||||
this->initialized_ = true;
|
||||
if (this->scan_) {
|
||||
ESP_LOGV(TAG, "Scanning i2c bus for active devices...");
|
||||
ESP_LOGV(TAG, "Scanning bus for active devices");
|
||||
this->i2c_scan_();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ void IDFI2CBus::setup() {
|
||||
}
|
||||
initialized_ = true;
|
||||
if (this->scan_) {
|
||||
ESP_LOGV(TAG, "Scanning i2c bus for active devices...");
|
||||
ESP_LOGV(TAG, "Scanning bus for active devices");
|
||||
this->i2c_scan_();
|
||||
}
|
||||
}
|
||||
|
||||
1
esphome/components/lc709203f/__init__.py
Normal file
1
esphome/components/lc709203f/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
CODEOWNERS = ["@ilikecake"]
|
||||
297
esphome/components/lc709203f/lc709203f.cpp
Normal file
297
esphome/components/lc709203f/lc709203f.cpp
Normal file
@@ -0,0 +1,297 @@
|
||||
#include "esphome/core/log.h"
|
||||
#include "lc709203f.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace lc709203f {
|
||||
|
||||
static const char *const TAG = "lc709203f.sensor";
|
||||
|
||||
// Device I2C address. This address is fixed.
|
||||
static const uint8_t LC709203F_I2C_ADDR_DEFAULT = 0x0B;
|
||||
|
||||
// Device registers
|
||||
static const uint8_t LC709203F_BEFORE_RSOC = 0x04;
|
||||
static const uint8_t LC709203F_THERMISTOR_B = 0x06;
|
||||
static const uint8_t LC709203F_INITIAL_RSOC = 0x07;
|
||||
static const uint8_t LC709203F_CELL_TEMPERATURE = 0x08;
|
||||
static const uint8_t LC709203F_CELL_VOLTAGE = 0x09;
|
||||
static const uint8_t LC709203F_CURRENT_DIRECTION = 0x0A;
|
||||
static const uint8_t LC709203F_APA = 0x0B;
|
||||
static const uint8_t LC709203F_APT = 0x0C;
|
||||
static const uint8_t LC709203F_RSOC = 0x0D;
|
||||
static const uint8_t LC709203F_ITE = 0x0F;
|
||||
static const uint8_t LC709203F_IC_VERSION = 0x11;
|
||||
static const uint8_t LC709203F_CHANGE_OF_THE_PARAMETER = 0x12;
|
||||
static const uint8_t LC709203F_ALARM_LOW_RSOC = 0x13;
|
||||
static const uint8_t LC709203F_ALARM_LOW_CELL_VOLTAGE = 0x14;
|
||||
static const uint8_t LC709203F_IC_POWER_MODE = 0x15;
|
||||
static const uint8_t LC709203F_STATUS_BIT = 0x16;
|
||||
static const uint8_t LC709203F_NUMBER_OF_THE_PARAMETER = 0x1A;
|
||||
|
||||
static const uint8_t LC709203F_POWER_MODE_ON = 0x0001;
|
||||
static const uint8_t LC709203F_POWER_MODE_SLEEP = 0x0002;
|
||||
|
||||
// The number of times to retry an I2C transaction before giving up. In my experience,
|
||||
// 10 is a good number here that will take care of most bus issues that require retry.
|
||||
static const uint8_t LC709203F_I2C_RETRY_COUNT = 10;
|
||||
|
||||
void Lc709203f::setup() {
|
||||
// Note: The setup implements a small state machine. This is because we want to have
|
||||
// delays before and after sending the RSOC command. The full init process should be:
|
||||
// INIT->RSOC->TEMP_SETUP->NORMAL
|
||||
// The setup() function will only perform the first part of the initialization process.
|
||||
// Assuming no errors, the whole process should occur during the setup() function and
|
||||
// the first two calls to update(). After that, the part should remain in normal mode
|
||||
// until a device reset.
|
||||
//
|
||||
// This device can be picky about I2C communication and can error out occasionally. The
|
||||
// get/set register functions impelment retry logic to retry the I2C transactions. The
|
||||
// initialization code checks the return code from those functions. If they don't return
|
||||
// NO_ERROR (0x00), that part of the initialization aborts and will be retried on the next
|
||||
// call to update().
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
// Set power mode to on. Note that, unlike some other similar devices, in sleep mode the IC
|
||||
// does not record power usage. If there is significant power consumption during sleep mode,
|
||||
// the pack RSOC will likely no longer be correct. Because of that, I do not implement
|
||||
// sleep mode on this device.
|
||||
|
||||
// Initialize device registers. If any of these fail, retry during the update() function.
|
||||
if (this->set_register_(LC709203F_IC_POWER_MODE, LC709203F_POWER_MODE_ON) != i2c::NO_ERROR) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->set_register_(LC709203F_APA, this->apa_) != i2c::NO_ERROR) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->set_register_(LC709203F_CHANGE_OF_THE_PARAMETER, this->pack_voltage_) != i2c::NO_ERROR) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->state_ = STATE_RSOC;
|
||||
// Note: Initialization continues in the update() function.
|
||||
}
|
||||
|
||||
void Lc709203f::update() {
|
||||
uint16_t buffer;
|
||||
|
||||
if (this->state_ == STATE_NORMAL) {
|
||||
// Note: If we fail to read from the data registers, we do not report any sensor reading.
|
||||
if (this->voltage_sensor_ != nullptr) {
|
||||
if (this->get_register_(LC709203F_CELL_VOLTAGE, &buffer) == i2c::NO_ERROR) {
|
||||
// Raw units are mV
|
||||
this->voltage_sensor_->publish_state(static_cast<float>(buffer) / 1000.0f);
|
||||
this->status_clear_warning();
|
||||
}
|
||||
}
|
||||
if (this->battery_remaining_sensor_ != nullptr) {
|
||||
if (this->get_register_(LC709203F_ITE, &buffer) == i2c::NO_ERROR) {
|
||||
// Raw units are .1%
|
||||
this->battery_remaining_sensor_->publish_state(static_cast<float>(buffer) / 10.0f);
|
||||
this->status_clear_warning();
|
||||
}
|
||||
}
|
||||
if (this->temperature_sensor_ != nullptr) {
|
||||
// I can't test this with a real thermistor because I don't have a device with
|
||||
// an attached thermistor. I have turned on the sensor and made sure that it
|
||||
// sets up the registers properly.
|
||||
if (this->get_register_(LC709203F_CELL_TEMPERATURE, &buffer) == i2c::NO_ERROR) {
|
||||
// Raw units are .1 K
|
||||
this->temperature_sensor_->publish_state((static_cast<float>(buffer) / 10.0f) - 273.15f);
|
||||
this->status_clear_warning();
|
||||
}
|
||||
}
|
||||
} else if (this->state_ == STATE_INIT) {
|
||||
// Retry initializing the device registers. We should only get here if the init sequence
|
||||
// failed during the setup() function. This would likely occur because of a repeated failures
|
||||
// on the I2C bus. If any of these fail, retry the next time the update() function is called.
|
||||
if (this->set_register_(LC709203F_IC_POWER_MODE, LC709203F_POWER_MODE_ON) != i2c::NO_ERROR) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->set_register_(LC709203F_APA, this->apa_) != i2c::NO_ERROR) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->set_register_(LC709203F_CHANGE_OF_THE_PARAMETER, this->pack_voltage_) != i2c::NO_ERROR) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->state_ = STATE_RSOC;
|
||||
|
||||
} else if (this->state_ == STATE_RSOC) {
|
||||
// We implement a delay here to send the initial RSOC command.
|
||||
// This should run once on the first update() after initialization.
|
||||
if (this->set_register_(LC709203F_INITIAL_RSOC, 0xAA55) == i2c::NO_ERROR) {
|
||||
this->state_ = STATE_TEMP_SETUP;
|
||||
}
|
||||
} else if (this->state_ == STATE_TEMP_SETUP) {
|
||||
// This should run once on the second update() after initialization.
|
||||
if (this->temperature_sensor_ != nullptr) {
|
||||
// This assumes that a thermistor is attached to the device as shown in the datahseet.
|
||||
if (this->set_register_(LC709203F_STATUS_BIT, 0x0001) == i2c::NO_ERROR) {
|
||||
if (this->set_register_(LC709203F_THERMISTOR_B, this->b_constant_) == i2c::NO_ERROR) {
|
||||
this->state_ = STATE_NORMAL;
|
||||
}
|
||||
}
|
||||
} else if (this->set_register_(LC709203F_STATUS_BIT, 0x0000) == i2c::NO_ERROR) {
|
||||
// The device expects to get updates to the temperature in this mode.
|
||||
// I am not doing that now. The temperature register defaults to 25C.
|
||||
// In theory, we could have another temperature sensor and have ESPHome
|
||||
// send updated temperature to the device occasionally, but I have no idea
|
||||
// how to make that happen.
|
||||
this->state_ = STATE_NORMAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Lc709203f::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "LC709203F:");
|
||||
LOG_I2C_DEVICE(this);
|
||||
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
ESP_LOGCONFIG(TAG, " Pack Size: %d mAH", this->pack_size_);
|
||||
ESP_LOGCONFIG(TAG, " Pack APA: 0x%02X", this->apa_);
|
||||
|
||||
// This is only true if the pack_voltage_ is either 0x0000 or 0x0001. The config validator
|
||||
// should have already verified this.
|
||||
ESP_LOGCONFIG(TAG, " Pack Rated Voltage: 3.%sV", this->pack_voltage_ == 0x0000 ? "8" : "7");
|
||||
|
||||
LOG_SENSOR(" ", "Voltage", this->voltage_sensor_);
|
||||
LOG_SENSOR(" ", "Battery Remaining", this->battery_remaining_sensor_);
|
||||
|
||||
if (this->temperature_sensor_ != nullptr) {
|
||||
LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
|
||||
ESP_LOGCONFIG(TAG, " B_Constant: %d", this->b_constant_);
|
||||
} else {
|
||||
ESP_LOGCONFIG(TAG, " No Temperature Sensor");
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t Lc709203f::get_register_(uint8_t register_to_read, uint16_t *register_value) {
|
||||
i2c::ErrorCode return_code;
|
||||
uint8_t read_buffer[6];
|
||||
|
||||
read_buffer[0] = (this->address_) << 1;
|
||||
read_buffer[1] = register_to_read;
|
||||
read_buffer[2] = ((this->address_) << 1) | 0x01;
|
||||
|
||||
for (uint8_t i = 0; i <= LC709203F_I2C_RETRY_COUNT; i++) {
|
||||
// Note: the read_register() function does not send a stop between the write and
|
||||
// the read portions of the I2C transation when you set the last variable to 'false'
|
||||
// as we do below. Some of the other I2C read functions such as the generic read()
|
||||
// function will send a stop between the read and the write portion of the I2C
|
||||
// transaction. This is bad in this case and will result in reading nothing but 0xFFFF
|
||||
// from the registers.
|
||||
return_code = this->read_register(register_to_read, &read_buffer[3], 3, false);
|
||||
if (return_code != i2c::NO_ERROR) {
|
||||
// Error on the i2c bus
|
||||
this->status_set_warning(
|
||||
str_sprintf("Error code %d when reading from register 0x%02X", return_code, register_to_read).c_str());
|
||||
} else if (this->crc8_(read_buffer, 5) != read_buffer[5]) {
|
||||
// I2C indicated OK, but the CRC of the data does not matcth.
|
||||
this->status_set_warning(str_sprintf("CRC error reading from register 0x%02X", register_to_read).c_str());
|
||||
} else {
|
||||
*register_value = ((uint16_t) read_buffer[4] << 8) | (uint16_t) read_buffer[3];
|
||||
return i2c::NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, we tried LC709203F_I2C_RETRY_COUNT times to read the register and
|
||||
// failed each time. Set the register value to 0 and return the I2C error code or 0xFF
|
||||
// to indicate a CRC failure. It will be up to the higher level code what to do when
|
||||
// this happens.
|
||||
*register_value = 0x0000;
|
||||
if (return_code != i2c::NO_ERROR) {
|
||||
return return_code;
|
||||
} else {
|
||||
return 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t Lc709203f::set_register_(uint8_t register_to_set, uint16_t value_to_set) {
|
||||
i2c::ErrorCode return_code;
|
||||
uint8_t write_buffer[5];
|
||||
|
||||
// Note: We don't actually send byte[0] of the buffer. We include it because it is
|
||||
// part of the CRC calculation.
|
||||
write_buffer[0] = (this->address_) << 1;
|
||||
write_buffer[1] = register_to_set;
|
||||
write_buffer[2] = value_to_set & 0xFF; // Low byte
|
||||
write_buffer[3] = (value_to_set >> 8) & 0xFF; // High byte
|
||||
write_buffer[4] = this->crc8_(write_buffer, 4);
|
||||
|
||||
for (uint8_t i = 0; i <= LC709203F_I2C_RETRY_COUNT; i++) {
|
||||
// Note: we don't write the first byte of the write buffer to the device.
|
||||
// This is done automatically by the write() function.
|
||||
return_code = this->write(&write_buffer[1], 4, true);
|
||||
if (return_code == i2c::NO_ERROR) {
|
||||
return return_code;
|
||||
} else {
|
||||
this->status_set_warning(
|
||||
str_sprintf("Error code %d when writing to register 0x%02X", return_code, register_to_set).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, we tried to send the data LC709203F_I2C_RETRY_COUNT times and failed.
|
||||
// We return the I2C error code, it is up to the higher level code what to do about it.
|
||||
return return_code;
|
||||
}
|
||||
|
||||
uint8_t Lc709203f::crc8_(uint8_t *byte_buffer, uint8_t length_of_crc) {
|
||||
uint8_t crc = 0x00;
|
||||
const uint8_t polynomial(0x07);
|
||||
|
||||
for (uint8_t j = length_of_crc; j; --j) {
|
||||
crc ^= *byte_buffer++;
|
||||
|
||||
for (uint8_t i = 8; i; --i) {
|
||||
crc = (crc & 0x80) ? (crc << 1) ^ polynomial : (crc << 1);
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
|
||||
void Lc709203f::set_pack_size(uint16_t pack_size) {
|
||||
static const uint16_t PACK_SIZE_ARRAY[6] = {100, 200, 500, 1000, 2000, 3000};
|
||||
static const uint16_t APA_ARRAY[6] = {0x08, 0x0B, 0x10, 0x19, 0x2D, 0x36};
|
||||
float slope;
|
||||
float intercept;
|
||||
|
||||
this->pack_size_ = pack_size; // Pack size in mAH
|
||||
|
||||
// The size is used to calculate the 'Adjustment Pack Application' number.
|
||||
// Here we assume a type 01 or type 03 battery and do a linear curve fit to find the APA.
|
||||
for (uint8_t i = 0; i < 6; i++) {
|
||||
if (PACK_SIZE_ARRAY[i] == pack_size) {
|
||||
// If the pack size is exactly one of the values in the array.
|
||||
this->apa_ = APA_ARRAY[i];
|
||||
return;
|
||||
} else if ((i > 0) && (PACK_SIZE_ARRAY[i] > pack_size) && (PACK_SIZE_ARRAY[i - 1] < pack_size)) {
|
||||
// If the pack size is between the current array element and the previous. Do a linear
|
||||
// Curve fit to determine the APA value.
|
||||
|
||||
// Type casting is required here to avoid interger division
|
||||
slope = static_cast<float>(APA_ARRAY[i] - APA_ARRAY[i - 1]) /
|
||||
static_cast<float>(PACK_SIZE_ARRAY[i] - PACK_SIZE_ARRAY[i - 1]);
|
||||
|
||||
// Type casting might not be needed here.
|
||||
intercept = static_cast<float>(APA_ARRAY[i]) - slope * static_cast<float>(PACK_SIZE_ARRAY[i]);
|
||||
|
||||
this->apa_ = static_cast<uint8_t>(slope * pack_size + intercept);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// We should never get here. If we do, it means we never set the pack APA. This should
|
||||
// not be possible because of the config validation. However, if it does happen, the
|
||||
// consequence is that the RSOC values will likley not be as accurate. However, it should
|
||||
// not cause an error or crash, so I am not doing any additional checking here.
|
||||
}
|
||||
|
||||
void Lc709203f::set_thermistor_b_constant(uint16_t b_constant) { this->b_constant_ = b_constant; }
|
||||
|
||||
void Lc709203f::set_pack_voltage(LC709203FBatteryVoltage pack_voltage) { this->pack_voltage_ = pack_voltage; }
|
||||
|
||||
} // namespace lc709203f
|
||||
} // namespace esphome
|
||||
55
esphome/components/lc709203f/lc709203f.h
Normal file
55
esphome/components/lc709203f/lc709203f.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/components/sensor/sensor.h"
|
||||
#include "esphome/components/i2c/i2c.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace lc709203f {
|
||||
|
||||
enum LC709203FState {
|
||||
STATE_INIT,
|
||||
STATE_RSOC,
|
||||
STATE_TEMP_SETUP,
|
||||
STATE_NORMAL,
|
||||
};
|
||||
|
||||
/// Enum listing allowable voltage settings for the LC709203F.
|
||||
enum LC709203FBatteryVoltage {
|
||||
LC709203F_BATTERY_VOLTAGE_3_8 = 0x0000,
|
||||
LC709203F_BATTERY_VOLTAGE_3_7 = 0x0001,
|
||||
};
|
||||
|
||||
class Lc709203f : public sensor::Sensor, public PollingComponent, public i2c::I2CDevice {
|
||||
public:
|
||||
void setup() override;
|
||||
void update() override;
|
||||
void dump_config() override;
|
||||
|
||||
void set_pack_size(uint16_t pack_size);
|
||||
void set_thermistor_b_constant(uint16_t b_constant);
|
||||
void set_pack_voltage(LC709203FBatteryVoltage pack_voltage);
|
||||
void set_voltage_sensor(sensor::Sensor *voltage_sensor) { voltage_sensor_ = voltage_sensor; }
|
||||
void set_battery_remaining_sensor(sensor::Sensor *battery_remaining_sensor) {
|
||||
battery_remaining_sensor_ = battery_remaining_sensor;
|
||||
}
|
||||
void set_temperature_sensor(sensor::Sensor *temperature_sensor) { temperature_sensor_ = temperature_sensor; }
|
||||
|
||||
private:
|
||||
uint8_t get_register_(uint8_t register_to_read, uint16_t *register_value);
|
||||
uint8_t set_register_(uint8_t register_to_set, uint16_t value_to_set);
|
||||
uint8_t crc8_(uint8_t *byte_buffer, uint8_t length_of_crc);
|
||||
|
||||
protected:
|
||||
sensor::Sensor *voltage_sensor_{nullptr};
|
||||
sensor::Sensor *battery_remaining_sensor_{nullptr};
|
||||
sensor::Sensor *temperature_sensor_{nullptr};
|
||||
uint16_t pack_size_;
|
||||
uint16_t apa_;
|
||||
uint16_t b_constant_;
|
||||
LC709203FState state_ = STATE_INIT;
|
||||
uint16_t pack_voltage_;
|
||||
};
|
||||
|
||||
} // namespace lc709203f
|
||||
} // namespace esphome
|
||||
93
esphome/components/lc709203f/sensor.py
Normal file
93
esphome/components/lc709203f/sensor.py
Normal file
@@ -0,0 +1,93 @@
|
||||
import esphome.codegen as cg
|
||||
from esphome.components import i2c, sensor
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_BATTERY_LEVEL,
|
||||
CONF_BATTERY_VOLTAGE,
|
||||
CONF_ID,
|
||||
CONF_SIZE,
|
||||
CONF_TEMPERATURE,
|
||||
CONF_VOLTAGE,
|
||||
DEVICE_CLASS_BATTERY,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
DEVICE_CLASS_VOLTAGE,
|
||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
UNIT_CELSIUS,
|
||||
UNIT_PERCENT,
|
||||
UNIT_VOLT,
|
||||
)
|
||||
|
||||
DEPENDENCIES = ["i2c"]
|
||||
|
||||
lc709203f_ns = cg.esphome_ns.namespace("lc709203f")
|
||||
|
||||
CONF_B_CONSTANT = "b_constant"
|
||||
|
||||
LC709203FBatteryVoltage = lc709203f_ns.enum("LC709203FBatteryVoltage")
|
||||
BATTERY_VOLTAGE_OPTIONS = {
|
||||
"3.7": LC709203FBatteryVoltage.LC709203F_BATTERY_VOLTAGE_3_7,
|
||||
"3.8": LC709203FBatteryVoltage.LC709203F_BATTERY_VOLTAGE_3_8,
|
||||
}
|
||||
|
||||
lc709203f = lc709203f_ns.class_("Lc709203f", cg.PollingComponent, i2c.I2CDevice)
|
||||
|
||||
CONFIG_SCHEMA = (
|
||||
cv.Schema(
|
||||
{
|
||||
cv.GenerateID(): cv.declare_id(lc709203f),
|
||||
cv.Optional(CONF_SIZE, default="500"): cv.int_range(100, 3000),
|
||||
cv.Optional(CONF_VOLTAGE, default="3.7"): cv.enum(
|
||||
BATTERY_VOLTAGE_OPTIONS, upper=True
|
||||
),
|
||||
cv.Optional(CONF_BATTERY_VOLTAGE): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_VOLT,
|
||||
accuracy_decimals=3,
|
||||
device_class=DEVICE_CLASS_VOLTAGE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
),
|
||||
cv.Optional(CONF_BATTERY_LEVEL): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_PERCENT,
|
||||
accuracy_decimals=3,
|
||||
device_class=DEVICE_CLASS_BATTERY,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
),
|
||||
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_CELSIUS,
|
||||
accuracy_decimals=2,
|
||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
).extend(
|
||||
{
|
||||
cv.Required(CONF_B_CONSTANT): cv.int_range(0, 0xFFFF),
|
||||
}
|
||||
),
|
||||
}
|
||||
)
|
||||
.extend(cv.polling_component_schema("60s"))
|
||||
.extend(i2c.i2c_device_schema(0x0B))
|
||||
)
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await cg.register_component(var, config)
|
||||
await i2c.register_i2c_device(var, config)
|
||||
cg.add(var.set_pack_size(config.get(CONF_SIZE)))
|
||||
cg.add(var.set_pack_voltage(BATTERY_VOLTAGE_OPTIONS[config[CONF_VOLTAGE]]))
|
||||
|
||||
if voltage_config := config.get(CONF_BATTERY_VOLTAGE):
|
||||
sens = await sensor.new_sensor(voltage_config)
|
||||
cg.add(var.set_voltage_sensor(sens))
|
||||
|
||||
if level_config := config.get(CONF_BATTERY_LEVEL):
|
||||
sens = await sensor.new_sensor(level_config)
|
||||
cg.add(var.set_battery_remaining_sensor(sens))
|
||||
|
||||
if temp_config := config.get(CONF_TEMPERATURE):
|
||||
sens = await sensor.new_sensor(temp_config)
|
||||
cg.add(var.set_temperature_sensor(sens))
|
||||
cg.add(var.set_thermistor_b_constant(temp_config[CONF_B_CONSTANT]))
|
||||
@@ -158,7 +158,7 @@ void LD2420Component::apply_config_action() {
|
||||
ESP_LOGCONFIG(TAG, "No configuration change detected");
|
||||
return;
|
||||
}
|
||||
ESP_LOGCONFIG(TAG, "Reconfiguring LD2420...");
|
||||
ESP_LOGCONFIG(TAG, "Reconfiguring LD2420");
|
||||
if (this->set_config_mode(true) == LD2420_ERROR_TIMEOUT) {
|
||||
ESP_LOGE(TAG, "LD2420 module has failed to respond, check baud rate and serial connections.");
|
||||
this->mark_failed();
|
||||
@@ -180,7 +180,7 @@ void LD2420Component::apply_config_action() {
|
||||
}
|
||||
|
||||
void LD2420Component::factory_reset_action() {
|
||||
ESP_LOGCONFIG(TAG, "Setting factory defaults...");
|
||||
ESP_LOGCONFIG(TAG, "Setting factory defaults");
|
||||
if (this->set_config_mode(true) == LD2420_ERROR_TIMEOUT) {
|
||||
ESP_LOGE(TAG, "LD2420 module has failed to respond, check baud rate and serial connections.");
|
||||
this->mark_failed();
|
||||
@@ -209,7 +209,7 @@ void LD2420Component::factory_reset_action() {
|
||||
}
|
||||
|
||||
void LD2420Component::restart_module_action() {
|
||||
ESP_LOGCONFIG(TAG, "Restarting LD2420 module...");
|
||||
ESP_LOGCONFIG(TAG, "Restarting LD2420 module");
|
||||
this->send_module_restart();
|
||||
this->set_timeout(250, [this]() {
|
||||
this->set_config_mode(true);
|
||||
|
||||
@@ -6,6 +6,8 @@ from esphome.const import (
|
||||
CONF_DISTANCE,
|
||||
CONF_RESOLUTION,
|
||||
CONF_SPEED,
|
||||
CONF_X,
|
||||
CONF_Y,
|
||||
DEVICE_CLASS_DISTANCE,
|
||||
DEVICE_CLASS_SPEED,
|
||||
UNIT_DEGREES,
|
||||
@@ -19,8 +21,6 @@ DEPENDENCIES = ["ld2450"]
|
||||
CONF_MOVING_TARGET_COUNT = "moving_target_count"
|
||||
CONF_STILL_TARGET_COUNT = "still_target_count"
|
||||
CONF_TARGET_COUNT = "target_count"
|
||||
CONF_X = "x"
|
||||
CONF_Y = "y"
|
||||
|
||||
ICON_ACCOUNT_GROUP = "mdi:account-group"
|
||||
ICON_ACCOUNT_SWITCH = "mdi:account-switch"
|
||||
|
||||
@@ -139,7 +139,7 @@ void LEDCOutput::write_state(float state) {
|
||||
}
|
||||
|
||||
void LEDCOutput::setup() {
|
||||
ESP_LOGV(TAG, "Entering setup...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
#ifdef USE_ARDUINO
|
||||
this->update_frequency(this->frequency_);
|
||||
this->turn_off();
|
||||
@@ -207,14 +207,14 @@ void LEDCOutput::update_frequency(float frequency) {
|
||||
this->bit_depth_ = bit_depth_opt.value_or(8);
|
||||
this->frequency_ = frequency;
|
||||
#ifdef USE_ARDUINO
|
||||
ESP_LOGV(TAG, "Using Arduino API - Trying to define channel, frequency and bit depth...");
|
||||
ESP_LOGV(TAG, "Using Arduino API - Trying to define channel, frequency and bit depth");
|
||||
u_int32_t configured_frequency = 0;
|
||||
|
||||
// Configure LEDC channel, frequency and bit depth with fallback
|
||||
int attempt_count_max = SETUP_ATTEMPT_COUNT_MAX;
|
||||
while (attempt_count_max > 0 && configured_frequency == 0) {
|
||||
ESP_LOGV(TAG, "Initializing channel %u with frequency %.1f and bit depth of %u...", this->channel_,
|
||||
this->frequency_, this->bit_depth_);
|
||||
ESP_LOGV(TAG, "Initializing channel %u with frequency %.1f and bit depth of %u", this->channel_, this->frequency_,
|
||||
this->bit_depth_);
|
||||
configured_frequency = ledcSetup(this->channel_, frequency, this->bit_depth_);
|
||||
if (configured_frequency != 0) {
|
||||
this->initialized_ = true;
|
||||
|
||||
@@ -101,7 +101,7 @@ class LibreTinyPreferences : public ESPPreferences {
|
||||
if (s_pending_save.empty())
|
||||
return true;
|
||||
|
||||
ESP_LOGD(TAG, "Saving %d preferences to flash...", s_pending_save.size());
|
||||
ESP_LOGV(TAG, "Saving %d items...", s_pending_save.size());
|
||||
// goal try write all pending saves even if one fails
|
||||
int cached = 0, written = 0, failed = 0;
|
||||
fdb_err_t last_err = FDB_NO_ERR;
|
||||
@@ -129,11 +129,10 @@ class LibreTinyPreferences : public ESPPreferences {
|
||||
}
|
||||
s_pending_save.erase(s_pending_save.begin() + i);
|
||||
}
|
||||
ESP_LOGD(TAG, "Saving %d preferences to flash: %d cached, %d written, %d failed", cached + written + failed, cached,
|
||||
written, failed);
|
||||
ESP_LOGD(TAG, "Writing %d items: %d cached, %d written, %d failed", cached + written + failed, cached, written,
|
||||
failed);
|
||||
if (failed > 0) {
|
||||
ESP_LOGE(TAG, "Error saving %d preferences to flash. Last error=%d for key=%s", failed, last_err,
|
||||
last_key.c_str());
|
||||
ESP_LOGE(TAG, "Writing %d items failed. Last error=%d for key=%s", failed, last_err, last_key.c_str());
|
||||
}
|
||||
|
||||
return failed == 0;
|
||||
@@ -158,7 +157,7 @@ class LibreTinyPreferences : public ESPPreferences {
|
||||
}
|
||||
|
||||
bool reset() override {
|
||||
ESP_LOGD(TAG, "Cleaning up preferences in flash...");
|
||||
ESP_LOGD(TAG, "Erasing storage");
|
||||
s_pending_save.clear();
|
||||
|
||||
fdb_kv_set_default(&db);
|
||||
|
||||
@@ -212,9 +212,9 @@ class Logger : public Component {
|
||||
}
|
||||
|
||||
// Format string to explicit buffer with varargs
|
||||
inline void printf_to_buffer_(const char *format, char *buffer, int *buffer_at, int buffer_size, ...) {
|
||||
inline void printf_to_buffer_(char *buffer, int *buffer_at, int buffer_size, const char *format, ...) {
|
||||
va_list arg;
|
||||
va_start(arg, buffer_size);
|
||||
va_start(arg, format);
|
||||
this->format_body_to_buffer_(buffer, buffer_at, buffer_size, format, arg);
|
||||
va_end(arg);
|
||||
}
|
||||
@@ -312,13 +312,13 @@ class Logger : public Component {
|
||||
#if defined(USE_ESP32) || defined(USE_LIBRETINY)
|
||||
if (thread_name != nullptr) {
|
||||
// Non-main task with thread name
|
||||
this->printf_to_buffer_("%s[%s][%s:%03u]%s[%s]%s: ", buffer, buffer_at, buffer_size, color, letter, tag, line,
|
||||
this->printf_to_buffer_(buffer, buffer_at, buffer_size, "%s[%s][%s:%03u]%s[%s]%s: ", color, letter, tag, line,
|
||||
ESPHOME_LOG_BOLD(ESPHOME_LOG_COLOR_RED), thread_name, color);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
// Main task or non ESP32/LibreTiny platform
|
||||
this->printf_to_buffer_("%s[%s][%s:%03u]: ", buffer, buffer_at, buffer_size, color, letter, tag, line);
|
||||
this->printf_to_buffer_(buffer, buffer_at, buffer_size, "%s[%s][%s:%03u]: ", color, letter, tag, line);
|
||||
}
|
||||
|
||||
inline void HOT format_body_to_buffer_(char *buffer, int *buffer_at, int buffer_size, const char *format,
|
||||
|
||||
@@ -306,7 +306,7 @@ void LTRAlsPs501Component::configure_als_() {
|
||||
|
||||
uint8_t tries = MAX_TRIES;
|
||||
do {
|
||||
ESP_LOGV(TAG, "Waiting for ALS device to become active...");
|
||||
ESP_LOGV(TAG, "Waiting for ALS device to become active");
|
||||
delay(2);
|
||||
als_ctrl.raw = this->reg((uint8_t) CommandRegisters::ALS_CONTR).get();
|
||||
} while (!als_ctrl.als_mode_active && tries--); // while active mode is not set - keep waiting
|
||||
|
||||
@@ -298,7 +298,7 @@ void LTRAlsPsComponent::configure_als_() {
|
||||
|
||||
uint8_t tries = MAX_TRIES;
|
||||
do {
|
||||
ESP_LOGV(TAG, "Waiting for device to become active...");
|
||||
ESP_LOGV(TAG, "Waiting for device to become active");
|
||||
delay(2);
|
||||
als_ctrl.raw = this->reg((uint8_t) CommandRegisters::ALS_CONTR).get();
|
||||
} while (!als_ctrl.active_mode && tries--); // while active mode is not set - keep waiting
|
||||
|
||||
@@ -519,8 +519,6 @@ CONF_UPDATE_ON_RELEASE = "update_on_release"
|
||||
CONF_VISIBLE_ROW_COUNT = "visible_row_count"
|
||||
CONF_WIDGET = "widget"
|
||||
CONF_WIDGETS = "widgets"
|
||||
CONF_X = "x"
|
||||
CONF_Y = "y"
|
||||
CONF_ZOOM = "zoom"
|
||||
|
||||
# Keypad keys
|
||||
|
||||
@@ -13,13 +13,15 @@ from esphome.const import (
|
||||
CONF_TIME,
|
||||
CONF_TRIGGER_ID,
|
||||
CONF_TYPE,
|
||||
CONF_X,
|
||||
CONF_Y,
|
||||
)
|
||||
from esphome.core import TimePeriod
|
||||
from esphome.core.config import StartupTrigger
|
||||
from esphome.schema_extractors import SCHEMA_EXTRACT
|
||||
|
||||
from . import defines as df, lv_validation as lvalid
|
||||
from .defines import CONF_TIME_FORMAT, CONF_X, CONF_Y, LV_GRAD_DIR
|
||||
from .defines import CONF_TIME_FORMAT, LV_GRAD_DIR
|
||||
from .helpers import add_lv_use, requires_component, validate_printf
|
||||
from .lv_validation import lv_color, lv_font, lv_gradient, lv_image, opacity
|
||||
from .lvcode import LvglComponent, lv_event_t_ptr
|
||||
@@ -354,8 +356,8 @@ ALIGN_TO_SCHEMA = {
|
||||
{
|
||||
cv.Required(CONF_ID): cv.use_id(lv_obj_t),
|
||||
cv.Required(df.CONF_ALIGN): df.ALIGN_ALIGNMENTS.one_of,
|
||||
cv.Optional(df.CONF_X, default=0): lvalid.pixels_or_percent,
|
||||
cv.Optional(df.CONF_Y, default=0): lvalid.pixels_or_percent,
|
||||
cv.Optional(CONF_X, default=0): lvalid.pixels_or_percent,
|
||||
cv.Optional(CONF_Y, default=0): lvalid.pixels_or_percent,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
from esphome import automation
|
||||
import esphome.codegen as cg
|
||||
from esphome.const import CONF_ID, CONF_ON_BOOT, CONF_ON_VALUE, CONF_TRIGGER_ID
|
||||
from esphome.const import (
|
||||
CONF_ID,
|
||||
CONF_ON_BOOT,
|
||||
CONF_ON_VALUE,
|
||||
CONF_TRIGGER_ID,
|
||||
CONF_X,
|
||||
CONF_Y,
|
||||
)
|
||||
|
||||
from .defines import (
|
||||
CONF_ALIGN,
|
||||
CONF_ALIGN_TO,
|
||||
CONF_X,
|
||||
CONF_Y,
|
||||
DIRECTIONS,
|
||||
LV_EVENT_MAP,
|
||||
LV_EVENT_TRIGGERS,
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
from esphome import automation, codegen as cg, config_validation as cv
|
||||
from esphome.components.display_menu_base import CONF_LABEL
|
||||
from esphome.const import CONF_COLOR, CONF_HEIGHT, CONF_ID, CONF_TEXT, CONF_WIDTH
|
||||
from esphome.const import (
|
||||
CONF_COLOR,
|
||||
CONF_HEIGHT,
|
||||
CONF_ID,
|
||||
CONF_TEXT,
|
||||
CONF_WIDTH,
|
||||
CONF_X,
|
||||
CONF_Y,
|
||||
)
|
||||
from esphome.cpp_generator import Literal, MockObj
|
||||
|
||||
from ..automation import action_to_code
|
||||
@@ -13,8 +21,6 @@ from ..defines import (
|
||||
CONF_POINTS,
|
||||
CONF_SRC,
|
||||
CONF_START_ANGLE,
|
||||
CONF_X,
|
||||
CONF_Y,
|
||||
literal,
|
||||
)
|
||||
from ..lv_validation import (
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import CONF_X, CONF_Y
|
||||
from esphome.core import Lambda
|
||||
|
||||
from ..defines import CONF_MAIN, CONF_X, CONF_Y, call_lambda
|
||||
from ..defines import CONF_MAIN, call_lambda
|
||||
from ..lvcode import lv_add
|
||||
from ..schemas import point_schema
|
||||
from ..types import LvCompound, LvType
|
||||
|
||||
@@ -13,14 +13,14 @@ void M5Stack8AngleComponent::setup() {
|
||||
|
||||
err = this->read(nullptr, 0);
|
||||
if (err != i2c::NO_ERROR) {
|
||||
ESP_LOGE(TAG, "I2C error %02X...", err);
|
||||
ESP_LOGE(TAG, "I2C error %02X", err);
|
||||
this->mark_failed();
|
||||
return;
|
||||
};
|
||||
|
||||
err = this->read_register(M5STACK_8ANGLE_REGISTER_FW_VERSION, &this->fw_version_, 1);
|
||||
if (err != i2c::NO_ERROR) {
|
||||
ESP_LOGE(TAG, "I2C error %02X...", err);
|
||||
ESP_LOGE(TAG, "I2C error %02X", err);
|
||||
this->mark_failed();
|
||||
return;
|
||||
};
|
||||
|
||||
@@ -95,28 +95,28 @@ bool MAX31856Sensor::has_fault_() {
|
||||
this->status_set_warning();
|
||||
|
||||
if ((faults & MAX31856_FAULT_CJRANGE) == MAX31856_FAULT_CJRANGE) {
|
||||
ESP_LOGW(TAG, "Cold Junction Out-of-Range: '%s'...", this->name_.c_str());
|
||||
ESP_LOGW(TAG, "Cold Junction Out-of-Range: '%s'", this->name_.c_str());
|
||||
}
|
||||
if ((faults & MAX31856_FAULT_TCRANGE) == MAX31856_FAULT_TCRANGE) {
|
||||
ESP_LOGW(TAG, "Thermocouple Out-of-Range: '%s'...", this->name_.c_str());
|
||||
ESP_LOGW(TAG, "Thermocouple Out-of-Range: '%s'", this->name_.c_str());
|
||||
}
|
||||
if ((faults & MAX31856_FAULT_CJHIGH) == MAX31856_FAULT_CJHIGH) {
|
||||
ESP_LOGW(TAG, "Cold-Junction High Fault: '%s'...", this->name_.c_str());
|
||||
ESP_LOGW(TAG, "Cold-Junction High Fault: '%s'", this->name_.c_str());
|
||||
}
|
||||
if ((faults & MAX31856_FAULT_CJLOW) == MAX31856_FAULT_CJLOW) {
|
||||
ESP_LOGW(TAG, "Cold-Junction Low Fault: '%s'...", this->name_.c_str());
|
||||
ESP_LOGW(TAG, "Cold-Junction Low Fault: '%s'", this->name_.c_str());
|
||||
}
|
||||
if ((faults & MAX31856_FAULT_TCHIGH) == MAX31856_FAULT_TCHIGH) {
|
||||
ESP_LOGW(TAG, "Thermocouple Temperature High Fault: '%s'...", this->name_.c_str());
|
||||
ESP_LOGW(TAG, "Thermocouple Temperature High Fault: '%s'", this->name_.c_str());
|
||||
}
|
||||
if ((faults & MAX31856_FAULT_TCLOW) == MAX31856_FAULT_TCLOW) {
|
||||
ESP_LOGW(TAG, "Thermocouple Temperature Low Fault: '%s'...", this->name_.c_str());
|
||||
ESP_LOGW(TAG, "Thermocouple Temperature Low Fault: '%s'", this->name_.c_str());
|
||||
}
|
||||
if ((faults & MAX31856_FAULT_OVUV) == MAX31856_FAULT_OVUV) {
|
||||
ESP_LOGW(TAG, "Overvoltage or Undervoltage Input Fault: '%s'...", this->name_.c_str());
|
||||
ESP_LOGW(TAG, "Overvoltage or Undervoltage Input Fault: '%s'", this->name_.c_str());
|
||||
}
|
||||
if ((faults & MAX31856_FAULT_OPEN) == MAX31856_FAULT_OPEN) {
|
||||
ESP_LOGW(TAG, "Thermocouple Open-Circuit Fault (possibly not connected): '%s'...", this->name_.c_str());
|
||||
ESP_LOGW(TAG, "Thermocouple Open-Circuit Fault (possibly not connected): '%s'", this->name_.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -42,17 +42,17 @@ void MAX9611Component::setup() {
|
||||
const uint8_t fast_mode_dat[] = {CONTROL_REGISTER_1_ADRR, MAX9611Multiplexer::MAX9611_MULTIPLEXER_FAST_MODE};
|
||||
|
||||
if (this->write(reinterpret_cast<const uint8_t *>(&setup_dat), sizeof(setup_dat)) != ErrorCode::ERROR_OK) {
|
||||
ESP_LOGE(TAG, "Failed to setup Max9611 during GAIN SET");
|
||||
ESP_LOGE(TAG, "GAIN SET failed");
|
||||
return;
|
||||
}
|
||||
delay(SETUP_DELAY);
|
||||
if (this->write(reinterpret_cast<const uint8_t *>(&fast_mode_dat), sizeof(fast_mode_dat)) != ErrorCode::ERROR_OK) {
|
||||
ESP_LOGE(TAG, "Failed to setup Max9611 during FAST MODE SET");
|
||||
ESP_LOGE(TAG, "FAST MODE SET failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
void MAX9611Component::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Dump Config max9611...");
|
||||
ESP_LOGCONFIG(TAG, "MAX9611:");
|
||||
ESP_LOGCONFIG(TAG, " CSA Gain Register: %x", gain_);
|
||||
LOG_I2C_DEVICE(this);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ void MAX9611Component::update() {
|
||||
// Just read the entire register map in a bulk read, faster than individually querying register.
|
||||
const ErrorCode read_result = this->read(register_map_, sizeof(register_map_));
|
||||
if (write_result != ErrorCode::ERROR_OK || read_result != ErrorCode::ERROR_OK) {
|
||||
ESP_LOGW(TAG, "MAX9611 Update FAILED!");
|
||||
ESP_LOGW(TAG, "Update failed");
|
||||
return;
|
||||
}
|
||||
uint16_t csa_register = ((register_map_[CSA_DATA_BYTE_MSB_ADRR] << 8) | (register_map_[CSA_DATA_BYTE_LSB_ADRR])) >> 4;
|
||||
|
||||
@@ -33,7 +33,7 @@ class MDNSComponent : public Component {
|
||||
#if (defined(USE_ESP8266) || defined(USE_RP2040)) && defined(USE_ARDUINO)
|
||||
void loop() override;
|
||||
#endif
|
||||
float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
|
||||
float get_setup_priority() const override { return setup_priority::AFTER_CONNECTION; }
|
||||
|
||||
void add_extra_service(MDNSService service) { services_extra_.push_back(std::move(service)); }
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ void MICS4514Component::setup() {
|
||||
uint8_t power_mode;
|
||||
this->read_register(POWER_MODE_REGISTER, &power_mode, 1);
|
||||
if (power_mode == 0x00) {
|
||||
ESP_LOGCONFIG(TAG, "Waking up MICS 4514, sensors will have data after 3 minutes...");
|
||||
ESP_LOGCONFIG(TAG, "Waking up MICS 4514, sensors will have data after 3 minutes");
|
||||
power_mode = 0x01;
|
||||
this->write_register(POWER_MODE_REGISTER, &power_mode, 1);
|
||||
delay(100); // NOLINT
|
||||
|
||||
@@ -29,7 +29,7 @@ void MPU6050Component::setup() {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, " Setting up Power Management...");
|
||||
ESP_LOGV(TAG, " Setting up Power Management");
|
||||
// Setup power management
|
||||
uint8_t power_management;
|
||||
if (!this->read_byte(MPU6050_REGISTER_POWER_MANAGEMENT_1, &power_management)) {
|
||||
@@ -50,7 +50,7 @@ void MPU6050Component::setup() {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, " Setting up Gyro Config...");
|
||||
ESP_LOGV(TAG, " Setting up Gyro Config");
|
||||
// Set scale - 2000DPS
|
||||
uint8_t gyro_config;
|
||||
if (!this->read_byte(MPU6050_REGISTER_GYRO_CONFIG, &gyro_config)) {
|
||||
@@ -66,7 +66,7 @@ void MPU6050Component::setup() {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, " Setting up Accel Config...");
|
||||
ESP_LOGV(TAG, " Setting up Accel Config");
|
||||
// Set range - 2G
|
||||
uint8_t accel_config;
|
||||
if (!this->read_byte(MPU6050_REGISTER_ACCEL_CONFIG, &accel_config)) {
|
||||
@@ -99,7 +99,7 @@ void MPU6050Component::dump_config() {
|
||||
}
|
||||
|
||||
void MPU6050Component::update() {
|
||||
ESP_LOGV(TAG, " Updating MPU6050...");
|
||||
ESP_LOGV(TAG, "Updating");
|
||||
uint16_t raw_data[7];
|
||||
if (!this->read_bytes_16(MPU6050_REGISTER_ACCEL_XOUT_H, raw_data, 7)) {
|
||||
this->status_set_warning();
|
||||
|
||||
@@ -33,7 +33,7 @@ void MPU6886Component::setup() {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, " Setting up Power Management...");
|
||||
ESP_LOGV(TAG, " Setting up Power Management");
|
||||
// Setup power management
|
||||
uint8_t power_management;
|
||||
if (!this->read_byte(MPU6886_REGISTER_POWER_MANAGEMENT_1, &power_management)) {
|
||||
@@ -54,7 +54,7 @@ void MPU6886Component::setup() {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, " Setting up Gyroscope Config...");
|
||||
ESP_LOGV(TAG, " Setting up Gyroscope Config");
|
||||
// Set scale - 2000DPS
|
||||
uint8_t gyro_config;
|
||||
if (!this->read_byte(MPU6886_REGISTER_GYRO_CONFIG, &gyro_config)) {
|
||||
@@ -70,7 +70,7 @@ void MPU6886Component::setup() {
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, " Setting up Accelerometer Config...");
|
||||
ESP_LOGV(TAG, " Setting up Accelerometer Config");
|
||||
// Set range - 2G
|
||||
uint8_t accel_config;
|
||||
if (!this->read_byte(MPU6886_REGISTER_ACCEL_CONFIG, &accel_config)) {
|
||||
@@ -104,7 +104,7 @@ void MPU6886Component::dump_config() {
|
||||
}
|
||||
|
||||
void MPU6886Component::update() {
|
||||
ESP_LOGV(TAG, " Updating MPU6886...");
|
||||
ESP_LOGV(TAG, " Updating");
|
||||
uint16_t raw_data[7];
|
||||
if (!this->read_bytes_16(MPU6886_REGISTER_ACCEL_XOUT_H, raw_data, 7)) {
|
||||
this->status_set_warning();
|
||||
|
||||
@@ -201,13 +201,13 @@ void MQTTClientComponent::start_dnslookup_() {
|
||||
}
|
||||
case ERR_INPROGRESS: {
|
||||
// wait for callback
|
||||
ESP_LOGD(TAG, "Resolving MQTT broker IP address...");
|
||||
ESP_LOGD(TAG, "Resolving broker IP address");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
case ERR_ARG: {
|
||||
// error
|
||||
ESP_LOGW(TAG, "Error resolving MQTT broker IP address: %d", err);
|
||||
ESP_LOGW(TAG, "Error resolving broker IP address: %d", err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -221,7 +221,7 @@ void MQTTClientComponent::check_dnslookup_() {
|
||||
}
|
||||
|
||||
if (this->dns_resolve_error_) {
|
||||
ESP_LOGW(TAG, "Couldn't resolve IP address for '%s'!", this->credentials_.address.c_str());
|
||||
ESP_LOGW(TAG, "Couldn't resolve IP address for '%s'", this->credentials_.address.c_str());
|
||||
this->state_ = MQTT_CLIENT_DISCONNECTED;
|
||||
return;
|
||||
}
|
||||
@@ -251,7 +251,7 @@ void MQTTClientComponent::start_connect_() {
|
||||
if (!network::is_connected())
|
||||
return;
|
||||
|
||||
ESP_LOGI(TAG, "Connecting to MQTT...");
|
||||
ESP_LOGI(TAG, "Connecting");
|
||||
// Force disconnect first
|
||||
this->mqtt_backend_.disconnect();
|
||||
|
||||
@@ -292,7 +292,7 @@ void MQTTClientComponent::check_connected() {
|
||||
this->state_ = MQTT_CLIENT_CONNECTED;
|
||||
this->sent_birth_message_ = false;
|
||||
this->status_clear_warning();
|
||||
ESP_LOGI(TAG, "MQTT Connected!");
|
||||
ESP_LOGI(TAG, "Connected");
|
||||
// MQTT Client needs some time to be fully set up.
|
||||
delay(100); // NOLINT
|
||||
|
||||
@@ -341,7 +341,7 @@ void MQTTClientComponent::loop() {
|
||||
if (!network::is_connected()) {
|
||||
reason_s = LOG_STR("WiFi disconnected");
|
||||
}
|
||||
ESP_LOGW(TAG, "MQTT Disconnected: %s.", LOG_STR_ARG(reason_s));
|
||||
ESP_LOGW(TAG, "Disconnected: %s", LOG_STR_ARG(reason_s));
|
||||
this->disconnect_reason_.reset();
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ void MQTTClientComponent::loop() {
|
||||
case MQTT_CLIENT_CONNECTED:
|
||||
if (!this->mqtt_backend_.connected()) {
|
||||
this->state_ = MQTT_CLIENT_DISCONNECTED;
|
||||
ESP_LOGW(TAG, "Lost MQTT Client connection!");
|
||||
ESP_LOGW(TAG, "Lost client connection");
|
||||
this->start_dnslookup_();
|
||||
} else {
|
||||
if (!this->birth_message_.topic.empty() && !this->sent_birth_message_) {
|
||||
@@ -378,7 +378,7 @@ void MQTTClientComponent::loop() {
|
||||
}
|
||||
|
||||
if (millis() - this->last_connected_ > this->reboot_timeout_ && this->reboot_timeout_ != 0) {
|
||||
ESP_LOGE(TAG, "Can't connect to MQTT... Restarting...");
|
||||
ESP_LOGE(TAG, "Can't connect; restarting");
|
||||
App.reboot();
|
||||
}
|
||||
}
|
||||
@@ -396,7 +396,7 @@ bool MQTTClientComponent::subscribe_(const char *topic, uint8_t qos) {
|
||||
ESP_LOGV(TAG, "subscribe(topic='%s')", topic);
|
||||
} else {
|
||||
delay(5);
|
||||
ESP_LOGV(TAG, "Subscribe failed for topic='%s'. Will retry later.", topic);
|
||||
ESP_LOGV(TAG, "Subscribe failed for topic='%s'. Will retry", topic);
|
||||
this->status_momentary_warning("subscribe", 1000);
|
||||
}
|
||||
return ret != 0;
|
||||
@@ -499,7 +499,7 @@ bool MQTTClientComponent::publish(const MQTTMessage &message) {
|
||||
ESP_LOGV(TAG, "Publish(topic='%s' payload='%s' retain=%d qos=%d)", message.topic.c_str(), message.payload.c_str(),
|
||||
message.retain, message.qos);
|
||||
} else {
|
||||
ESP_LOGV(TAG, "Publish failed for topic='%s' (len=%u). will retry later..", message.topic.c_str(),
|
||||
ESP_LOGV(TAG, "Publish failed for topic='%s' (len=%u). Will retry", message.topic.c_str(),
|
||||
message.payload.length());
|
||||
this->status_momentary_warning("publish", 1000);
|
||||
}
|
||||
@@ -515,7 +515,7 @@ bool MQTTClientComponent::publish_json(const std::string &topic, const json::jso
|
||||
void MQTTClientComponent::enable() {
|
||||
if (this->state_ != MQTT_CLIENT_DISABLED)
|
||||
return;
|
||||
ESP_LOGD(TAG, "Enabling MQTT...");
|
||||
ESP_LOGD(TAG, "Enabling");
|
||||
this->state_ = MQTT_CLIENT_DISCONNECTED;
|
||||
this->last_connected_ = millis();
|
||||
this->start_dnslookup_();
|
||||
@@ -524,7 +524,7 @@ void MQTTClientComponent::enable() {
|
||||
void MQTTClientComponent::disable() {
|
||||
if (this->state_ == MQTT_CLIENT_DISABLED)
|
||||
return;
|
||||
ESP_LOGD(TAG, "Disabling MQTT...");
|
||||
ESP_LOGD(TAG, "Disabling");
|
||||
this->state_ = MQTT_CLIENT_DISABLED;
|
||||
this->on_shutdown();
|
||||
}
|
||||
|
||||
@@ -64,11 +64,11 @@ bool MQTTComponent::send_discovery_() {
|
||||
const MQTTDiscoveryInfo &discovery_info = global_mqtt_client->get_discovery_info();
|
||||
|
||||
if (discovery_info.clean) {
|
||||
ESP_LOGV(TAG, "'%s': Cleaning discovery...", this->friendly_name().c_str());
|
||||
ESP_LOGV(TAG, "'%s': Cleaning discovery", this->friendly_name().c_str());
|
||||
return global_mqtt_client->publish(this->get_discovery_topic_(discovery_info), "", 0, this->qos_, true);
|
||||
}
|
||||
|
||||
ESP_LOGV(TAG, "'%s': Sending discovery...", this->friendly_name().c_str());
|
||||
ESP_LOGV(TAG, "'%s': Sending discovery", this->friendly_name().c_str());
|
||||
|
||||
return global_mqtt_client->publish_json(
|
||||
this->get_discovery_topic_(discovery_info),
|
||||
|
||||
@@ -248,10 +248,10 @@ void MSA3xxComponent::loop() {
|
||||
}
|
||||
|
||||
void MSA3xxComponent::update() {
|
||||
ESP_LOGV(TAG, "Updating MSA3xx...");
|
||||
ESP_LOGV(TAG, "Updating");
|
||||
|
||||
if (!this->is_ready()) {
|
||||
ESP_LOGV(TAG, "Component MSA3xx not ready for update");
|
||||
ESP_LOGV(TAG, "Not ready for update");
|
||||
return;
|
||||
}
|
||||
ESP_LOGV(TAG, "Acceleration: {x = %+1.3f m/s², y = %+1.3f m/s², z = %+1.3f m/s²}; ", this->data_.x, this->data_.y,
|
||||
|
||||
@@ -14,6 +14,7 @@ CONF_COMPONENT_NAME = "component_name"
|
||||
CONF_EXIT_REPARSE_ON_START = "exit_reparse_on_start"
|
||||
CONF_FONT_ID = "font_id"
|
||||
CONF_FOREGROUND_PRESSED_COLOR = "foreground_pressed_color"
|
||||
CONF_MAX_QUEUE_SIZE = "max_queue_size"
|
||||
CONF_ON_BUFFER_OVERFLOW = "on_buffer_overflow"
|
||||
CONF_ON_PAGE = "on_page"
|
||||
CONF_ON_SETUP = "on_setup"
|
||||
|
||||
@@ -16,6 +16,7 @@ from .base_component import (
|
||||
CONF_AUTO_WAKE_ON_TOUCH,
|
||||
CONF_COMMAND_SPACING,
|
||||
CONF_EXIT_REPARSE_ON_START,
|
||||
CONF_MAX_QUEUE_SIZE,
|
||||
CONF_ON_BUFFER_OVERFLOW,
|
||||
CONF_ON_SETUP,
|
||||
CONF_ON_SLEEP,
|
||||
@@ -93,6 +94,7 @@ CONFIG_SCHEMA = (
|
||||
cv.positive_time_period_milliseconds,
|
||||
cv.Range(max=TimePeriod(milliseconds=255)),
|
||||
),
|
||||
cv.Optional(CONF_MAX_QUEUE_SIZE): cv.positive_int,
|
||||
}
|
||||
)
|
||||
.extend(cv.polling_component_schema("5s"))
|
||||
@@ -125,6 +127,10 @@ async def to_code(config):
|
||||
var = cg.new_Pvariable(config[CONF_ID])
|
||||
await uart.register_uart_device(var, config)
|
||||
|
||||
if max_queue_size := config.get(CONF_MAX_QUEUE_SIZE):
|
||||
cg.add_define("USE_NEXTION_MAX_QUEUE_SIZE")
|
||||
cg.add(var.set_max_queue_size(max_queue_size))
|
||||
|
||||
if command_spacing := config.get(CONF_COMMAND_SPACING):
|
||||
cg.add_define("USE_NEXTION_COMMAND_SPACING")
|
||||
cg.add(var.set_command_spacing(command_spacing.total_milliseconds))
|
||||
|
||||
@@ -173,6 +173,10 @@ void Nextion::dump_config() {
|
||||
#ifdef USE_NEXTION_COMMAND_SPACING
|
||||
ESP_LOGCONFIG(TAG, " Command spacing: %" PRIu8 "ms", this->command_pacer_.get_spacing());
|
||||
#endif // USE_NEXTION_COMMAND_SPACING
|
||||
|
||||
#ifdef USE_NEXTION_MAX_QUEUE_SIZE
|
||||
ESP_LOGCONFIG(TAG, " Max queue size: %zu", this->max_queue_size_);
|
||||
#endif
|
||||
}
|
||||
|
||||
float Nextion::get_setup_priority() const { return setup_priority::DATA; }
|
||||
@@ -998,13 +1002,31 @@ uint16_t Nextion::recv_ret_string_(std::string &response, uint32_t timeout, bool
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* @brief Add a command to the Nextion queue that expects no response.
|
||||
*
|
||||
* @param variable_name Name for the queue
|
||||
* This is typically used for write-only operations such as variable assignments or component updates
|
||||
* where no return value or acknowledgment is expected from the display.
|
||||
*
|
||||
* If the `max_queue_size` limit is configured and reached, the command will be skipped.
|
||||
*
|
||||
* @param variable_name Name of the variable or component associated with the command.
|
||||
*/
|
||||
void Nextion::add_no_result_to_queue_(const std::string &variable_name) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion::NextionQueue *nextion_queue = new nextion::NextionQueue;
|
||||
#ifdef USE_NEXTION_MAX_QUEUE_SIZE
|
||||
if (this->max_queue_size_ > 0 && this->nextion_queue_.size() >= this->max_queue_size_) {
|
||||
ESP_LOGW(TAG, "Nextion queue full (%zu entries), dropping NORESULT command: %s", this->nextion_queue_.size(),
|
||||
variable_name.c_str());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
ExternalRAMAllocator<nextion::NextionQueue> allocator(ExternalRAMAllocator<nextion::NextionQueue>::ALLOW_FAILURE);
|
||||
nextion::NextionQueue *nextion_queue = allocator.allocate(1);
|
||||
if (nextion_queue == nullptr) {
|
||||
ESP_LOGW(TAG, "Failed to allocate NextionQueue");
|
||||
return;
|
||||
}
|
||||
new (nextion_queue) nextion::NextionQueue();
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion_queue->component = new nextion::NextionComponentBase;
|
||||
@@ -1133,12 +1155,34 @@ void Nextion::add_no_result_to_queue_with_set_internal_(const std::string &varia
|
||||
state_value.c_str());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Queue a GET command for a component that expects a response from the Nextion display.
|
||||
*
|
||||
* This method is used for querying values such as sensor states, text content, or switch status.
|
||||
* The component will be added to the Nextion queue only if the display is already set up,
|
||||
* the queue has not reached the configured maximum size (if set), and the command is sent successfully.
|
||||
*
|
||||
* @param component Pointer to the Nextion component that will handle the response.
|
||||
*/
|
||||
void Nextion::add_to_get_queue(NextionComponentBase *component) {
|
||||
if ((!this->is_setup() && !this->ignore_is_setup_))
|
||||
return;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion::NextionQueue *nextion_queue = new nextion::NextionQueue;
|
||||
#ifdef USE_NEXTION_MAX_QUEUE_SIZE
|
||||
if (this->max_queue_size_ > 0 && this->nextion_queue_.size() >= this->max_queue_size_) {
|
||||
ESP_LOGW(TAG, "Nextion queue full (%zu entries), dropping GET for \"%s\"", this->nextion_queue_.size(),
|
||||
component->get_variable_name().c_str());
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
ExternalRAMAllocator<nextion::NextionQueue> allocator(ExternalRAMAllocator<nextion::NextionQueue>::ALLOW_FAILURE);
|
||||
nextion::NextionQueue *nextion_queue = allocator.allocate(1);
|
||||
if (nextion_queue == nullptr) {
|
||||
ESP_LOGW(TAG, "Failed to allocate NextionQueue");
|
||||
return;
|
||||
}
|
||||
new (nextion_queue) nextion::NextionQueue();
|
||||
|
||||
nextion_queue->component = component;
|
||||
nextion_queue->queue_time = millis();
|
||||
@@ -1165,8 +1209,13 @@ void Nextion::add_addt_command_to_queue(NextionComponentBase *component) {
|
||||
if ((!this->is_setup() && !this->ignore_is_setup_) || this->is_sleeping())
|
||||
return;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-owning-memory)
|
||||
nextion::NextionQueue *nextion_queue = new nextion::NextionQueue;
|
||||
ExternalRAMAllocator<nextion::NextionQueue> allocator(ExternalRAMAllocator<nextion::NextionQueue>::ALLOW_FAILURE);
|
||||
nextion::NextionQueue *nextion_queue = allocator.allocate(1);
|
||||
if (nextion_queue == nullptr) {
|
||||
ESP_LOGW(TAG, "Failed to allocate NextionQueue");
|
||||
return;
|
||||
}
|
||||
new (nextion_queue) nextion::NextionQueue();
|
||||
|
||||
nextion_queue->component = component;
|
||||
nextion_queue->queue_time = millis();
|
||||
|
||||
@@ -75,6 +75,20 @@ class NextionCommandPacer {
|
||||
|
||||
class Nextion : public NextionBase, public PollingComponent, public uart::UARTDevice {
|
||||
public:
|
||||
#ifdef USE_NEXTION_MAX_QUEUE_SIZE
|
||||
/**
|
||||
* @brief Set the maximum allowed queue size
|
||||
* @param size Max number of entries allowed in nextion_queue_
|
||||
*/
|
||||
inline void set_max_queue_size(size_t size) { this->max_queue_size_ = size; }
|
||||
|
||||
/**
|
||||
* @brief Get the maximum allowed queue size
|
||||
* @return Current limit (0 = unlimited)
|
||||
*/
|
||||
inline size_t get_max_queue_size() const { return this->max_queue_size_; }
|
||||
#endif // USE_NEXTION_MAX_QUEUE_SIZE
|
||||
|
||||
#ifdef USE_NEXTION_COMMAND_SPACING
|
||||
/**
|
||||
* @brief Set the command spacing for the display
|
||||
@@ -1273,6 +1287,9 @@ class Nextion : public NextionBase, public PollingComponent, public uart::UARTDe
|
||||
bool is_connected() { return this->is_connected_; }
|
||||
|
||||
protected:
|
||||
#ifdef USE_NEXTION_MAX_QUEUE_SIZE
|
||||
size_t max_queue_size_{0};
|
||||
#endif // USE_NEXTION_MAX_QUEUE_SIZE
|
||||
#ifdef USE_NEXTION_COMMAND_SPACING
|
||||
NextionCommandPacer command_pacer_{0};
|
||||
#endif // USE_NEXTION_COMMAND_SPACING
|
||||
|
||||
@@ -249,7 +249,7 @@ bool Nextion::upload_tft(uint32_t baud_rate, bool exit_reparse) {
|
||||
ESP_LOGV(TAG, "Connection closed");
|
||||
return this->upload_end_(false);
|
||||
} else {
|
||||
ESP_LOGV(TAG, "File size check passed. Proceeding...");
|
||||
ESP_LOGV(TAG, "File size check passed. Proceeding");
|
||||
}
|
||||
this->content_length_ = this->tft_size_;
|
||||
|
||||
|
||||
@@ -241,7 +241,7 @@ bool Nextion::upload_tft(uint32_t baud_rate, bool exit_reparse) {
|
||||
ESP_LOGV(TAG, "Connection closed");
|
||||
return this->upload_end_(false);
|
||||
} else {
|
||||
ESP_LOGV(TAG, "File size check passed. Proceeding...");
|
||||
ESP_LOGV(TAG, "File size check passed. Proceeding");
|
||||
}
|
||||
this->content_length_ = this->tft_size_;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ void OnlineImage::draw(int x, int y, display::Display *display, Color color_on,
|
||||
|
||||
void OnlineImage::release() {
|
||||
if (this->buffer_) {
|
||||
ESP_LOGV(TAG, "Deallocating old buffer...");
|
||||
ESP_LOGV(TAG, "Deallocating old buffer");
|
||||
this->allocator_.deallocate(this->buffer_, this->get_buffer_size_());
|
||||
this->data_start_ = nullptr;
|
||||
this->buffer_ = nullptr;
|
||||
|
||||
@@ -28,7 +28,7 @@ static const uint8_t PCA9685_MODE1_SLEEP = 0b00010000;
|
||||
void PCA9685Output::setup() {
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
ESP_LOGV(TAG, " Resetting devices...");
|
||||
ESP_LOGV(TAG, " Resetting devices");
|
||||
if (!this->write_bytes(PCA9685_REGISTER_SOFTWARE_RESET, nullptr, 0)) {
|
||||
this->mark_failed();
|
||||
return;
|
||||
|
||||
@@ -19,7 +19,7 @@ void PN532::setup() {
|
||||
|
||||
// Get version data
|
||||
if (!this->write_command_({PN532_COMMAND_VERSION_DATA})) {
|
||||
ESP_LOGW(TAG, "Error sending version command, trying again...");
|
||||
ESP_LOGW(TAG, "Error sending version command, trying again");
|
||||
if (!this->write_command_({PN532_COMMAND_VERSION_DATA})) {
|
||||
ESP_LOGE(TAG, "Error sending version command");
|
||||
this->mark_failed();
|
||||
@@ -208,21 +208,21 @@ void PN532::loop() {
|
||||
}
|
||||
}
|
||||
} else if (next_task_ == CLEAN) {
|
||||
ESP_LOGD(TAG, " Tag cleaning...");
|
||||
ESP_LOGD(TAG, " Tag cleaning");
|
||||
if (!this->clean_tag_(nfcid)) {
|
||||
ESP_LOGE(TAG, " Tag was not fully cleaned successfully");
|
||||
}
|
||||
ESP_LOGD(TAG, " Tag cleaned!");
|
||||
} else if (next_task_ == FORMAT) {
|
||||
ESP_LOGD(TAG, " Tag formatting...");
|
||||
ESP_LOGD(TAG, " Tag formatting");
|
||||
if (!this->format_tag_(nfcid)) {
|
||||
ESP_LOGE(TAG, "Error formatting tag as NDEF");
|
||||
}
|
||||
ESP_LOGD(TAG, " Tag formatted!");
|
||||
} else if (next_task_ == WRITE) {
|
||||
if (this->next_task_message_to_write_ != nullptr) {
|
||||
ESP_LOGD(TAG, " Tag writing...");
|
||||
ESP_LOGD(TAG, " Tag formatting...");
|
||||
ESP_LOGD(TAG, " Tag writing");
|
||||
ESP_LOGD(TAG, " Tag formatting");
|
||||
if (!this->format_tag_(nfcid)) {
|
||||
ESP_LOGE(TAG, " Tag could not be formatted for writing");
|
||||
} else {
|
||||
@@ -281,7 +281,7 @@ bool PN532::write_command_(const std::vector<uint8_t> &data) {
|
||||
}
|
||||
|
||||
bool PN532::read_ack_() {
|
||||
ESP_LOGV(TAG, "Reading ACK...");
|
||||
ESP_LOGV(TAG, "Reading ACK");
|
||||
|
||||
std::vector<uint8_t> data;
|
||||
if (!this->read_data(data, 6)) {
|
||||
|
||||
@@ -51,7 +51,7 @@ bool PN532Spi::read_data(std::vector<uint8_t> &data, uint8_t len) {
|
||||
delay(2);
|
||||
this->write_byte(0x03);
|
||||
|
||||
ESP_LOGV(TAG, "Reading data...");
|
||||
ESP_LOGV(TAG, "Reading data");
|
||||
|
||||
data.resize(len);
|
||||
this->read_array(data.data(), len);
|
||||
|
||||
@@ -830,7 +830,7 @@ void PN7150::process_rf_intf_activated_oid_(nfc::NciMessage &rx) { // an endpoi
|
||||
|
||||
switch (this->next_task_) {
|
||||
case EP_CLEAN:
|
||||
ESP_LOGD(TAG, " Tag cleaning...");
|
||||
ESP_LOGD(TAG, " Tag cleaning");
|
||||
if (this->clean_endpoint_(working_endpoint.tag->get_uid()) != nfc::STATUS_OK) {
|
||||
ESP_LOGE(TAG, " Tag cleaning incomplete");
|
||||
}
|
||||
@@ -838,7 +838,7 @@ void PN7150::process_rf_intf_activated_oid_(nfc::NciMessage &rx) { // an endpoi
|
||||
break;
|
||||
|
||||
case EP_FORMAT:
|
||||
ESP_LOGD(TAG, " Tag formatting...");
|
||||
ESP_LOGD(TAG, " Tag formatting");
|
||||
if (this->format_endpoint_(working_endpoint.tag->get_uid()) != nfc::STATUS_OK) {
|
||||
ESP_LOGE(TAG, "Error formatting tag as NDEF");
|
||||
}
|
||||
@@ -847,8 +847,8 @@ void PN7150::process_rf_intf_activated_oid_(nfc::NciMessage &rx) { // an endpoi
|
||||
|
||||
case EP_WRITE:
|
||||
if (this->next_task_message_to_write_ != nullptr) {
|
||||
ESP_LOGD(TAG, " Tag writing...");
|
||||
ESP_LOGD(TAG, " Tag formatting...");
|
||||
ESP_LOGD(TAG, " Tag writing");
|
||||
ESP_LOGD(TAG, " Tag formatting");
|
||||
if (this->format_endpoint_(working_endpoint.tag->get_uid()) != nfc::STATUS_OK) {
|
||||
ESP_LOGE(TAG, " Tag could not be formatted for writing");
|
||||
} else {
|
||||
|
||||
@@ -854,7 +854,7 @@ void PN7160::process_rf_intf_activated_oid_(nfc::NciMessage &rx) { // an endpoi
|
||||
|
||||
switch (this->next_task_) {
|
||||
case EP_CLEAN:
|
||||
ESP_LOGD(TAG, " Tag cleaning...");
|
||||
ESP_LOGD(TAG, " Tag cleaning");
|
||||
if (this->clean_endpoint_(working_endpoint.tag->get_uid()) != nfc::STATUS_OK) {
|
||||
ESP_LOGE(TAG, " Tag cleaning incomplete");
|
||||
}
|
||||
@@ -862,7 +862,7 @@ void PN7160::process_rf_intf_activated_oid_(nfc::NciMessage &rx) { // an endpoi
|
||||
break;
|
||||
|
||||
case EP_FORMAT:
|
||||
ESP_LOGD(TAG, " Tag formatting...");
|
||||
ESP_LOGD(TAG, " Tag formatting");
|
||||
if (this->format_endpoint_(working_endpoint.tag->get_uid()) != nfc::STATUS_OK) {
|
||||
ESP_LOGE(TAG, "Error formatting tag as NDEF");
|
||||
}
|
||||
@@ -871,8 +871,8 @@ void PN7160::process_rf_intf_activated_oid_(nfc::NciMessage &rx) { // an endpoi
|
||||
|
||||
case EP_WRITE:
|
||||
if (this->next_task_message_to_write_ != nullptr) {
|
||||
ESP_LOGD(TAG, " Tag writing...");
|
||||
ESP_LOGD(TAG, " Tag formatting...");
|
||||
ESP_LOGD(TAG, " Tag writing");
|
||||
ESP_LOGD(TAG, " Tag formatting");
|
||||
if (this->format_endpoint_(working_endpoint.tag->get_uid()) != nfc::STATUS_OK) {
|
||||
ESP_LOGE(TAG, " Tag could not be formatted for writing");
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,7 @@ void QrCode::set_ecc(qrcodegen_Ecc ecc) {
|
||||
}
|
||||
|
||||
void QrCode::generate_qr_code() {
|
||||
ESP_LOGV(TAG, "Generating QR code...");
|
||||
ESP_LOGV(TAG, "Generating QR code");
|
||||
uint8_t tempbuffer[qrcodegen_BUFFER_LEN_MAX];
|
||||
|
||||
if (!qrcodegen_encodeText(this->value_.c_str(), tempbuffer, this->qr_, this->ecc_, qrcodegen_VERSION_MIN,
|
||||
|
||||
@@ -46,7 +46,7 @@ void RC522::setup() {
|
||||
reset_pin_->pin_mode(gpio::FLAG_INPUT);
|
||||
|
||||
if (!reset_pin_->digital_read()) { // The MFRC522 chip is in power down mode.
|
||||
ESP_LOGV(TAG, "Power down mode detected. Hard resetting...");
|
||||
ESP_LOGV(TAG, "Power down mode detected. Hard resetting");
|
||||
reset_pin_->pin_mode(gpio::FLAG_OUTPUT); // Now set the resetPowerDownPin as digital output.
|
||||
reset_pin_->digital_write(false); // Make sure we have a clean LOW state.
|
||||
delayMicroseconds(2); // 8.8.1 Reset timing requirements says about 100ns. Let us be generous: 2μsl
|
||||
@@ -101,7 +101,7 @@ void RC522::dump_config() {
|
||||
case NONE:
|
||||
break;
|
||||
case RESET_FAILED:
|
||||
ESP_LOGE(TAG, "Reset command failed!");
|
||||
ESP_LOGE(TAG, "Reset command failed");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ void RC522::pcd_reset_() {
|
||||
return;
|
||||
|
||||
if (reset_count_ == RESET_COUNT) {
|
||||
ESP_LOGI(TAG, "Soft reset...");
|
||||
ESP_LOGI(TAG, "Soft reset");
|
||||
// Issue the SoftReset command.
|
||||
pcd_write_register(COMMAND_REG, PCD_SOFT_RESET);
|
||||
}
|
||||
@@ -300,14 +300,14 @@ void RC522::pcd_reset_() {
|
||||
// Expect the PowerDown bit in CommandReg to be cleared (max 3x50ms)
|
||||
if ((pcd_read_register(COMMAND_REG) & (1 << 4)) == 0) {
|
||||
reset_count_ = 0;
|
||||
ESP_LOGI(TAG, "Device online.");
|
||||
ESP_LOGI(TAG, "Device online");
|
||||
// Wait for initialize
|
||||
reset_timeout_ = millis();
|
||||
return;
|
||||
}
|
||||
|
||||
if (--reset_count_ == 0) {
|
||||
ESP_LOGE(TAG, "Unable to reset RC522.");
|
||||
ESP_LOGE(TAG, "Unable to reset");
|
||||
this->error_code_ = RESET_FAILED;
|
||||
mark_failed();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ void RemoteTransmitterComponent::setup() {
|
||||
}
|
||||
|
||||
void RemoteTransmitterComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Remote Transmitter...");
|
||||
ESP_LOGCONFIG(TAG, "Remote Transmitter:");
|
||||
ESP_LOGCONFIG(TAG, " Carrier Duty: %u%%", this->carrier_duty_percent_);
|
||||
LOG_PIN(" Pin: ", this->pin_);
|
||||
}
|
||||
@@ -72,7 +72,7 @@ void RemoteTransmitterComponent::space_(uint32_t usec) {
|
||||
}
|
||||
|
||||
void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t send_wait) {
|
||||
ESP_LOGD(TAG, "Sending remote code...");
|
||||
ESP_LOGD(TAG, "Sending remote code");
|
||||
uint32_t on_time, off_time;
|
||||
this->calculate_on_off_time_(this->temp_.get_carrier_frequency(), &on_time, &off_time);
|
||||
this->target_time_ = 0;
|
||||
|
||||
@@ -15,7 +15,7 @@ void RemoteTransmitterComponent::setup() {
|
||||
}
|
||||
|
||||
void RemoteTransmitterComponent::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Remote Transmitter...");
|
||||
ESP_LOGCONFIG(TAG, "Remote Transmitter:");
|
||||
ESP_LOGCONFIG(TAG, " Carrier Duty: %u%%", this->carrier_duty_percent_);
|
||||
LOG_PIN(" Pin: ", this->pin_);
|
||||
}
|
||||
@@ -74,7 +74,7 @@ void RemoteTransmitterComponent::space_(uint32_t usec) {
|
||||
}
|
||||
|
||||
void RemoteTransmitterComponent::send_internal(uint32_t send_times, uint32_t send_wait) {
|
||||
ESP_LOGD(TAG, "Sending remote code...");
|
||||
ESP_LOGD(TAG, "Sending remote code");
|
||||
uint32_t on_time, off_time;
|
||||
this->calculate_on_off_time_(this->temp_.get_carrier_frequency(), &on_time, &off_time);
|
||||
this->target_time_ = 0;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace restart {
|
||||
static const char *const TAG = "restart.button";
|
||||
|
||||
void RestartButton::press_action() {
|
||||
ESP_LOGI(TAG, "Restarting device...");
|
||||
ESP_LOGI(TAG, "Restarting device");
|
||||
// Let MQTT settle a bit
|
||||
delay(100); // NOLINT
|
||||
App.safe_reboot();
|
||||
|
||||
@@ -13,7 +13,7 @@ void RestartSwitch::write_state(bool state) {
|
||||
this->publish_state(false);
|
||||
|
||||
if (state) {
|
||||
ESP_LOGI(TAG, "Restarting device...");
|
||||
ESP_LOGI(TAG, "Restarting device");
|
||||
// Let MQTT settle a bit
|
||||
delay(100); // NOLINT
|
||||
App.safe_reboot();
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace rp2040 {
|
||||
|
||||
static const char *const TAG = "rp2040";
|
||||
|
||||
static int IRAM_ATTR flags_to_mode(gpio::Flags flags, uint8_t pin) {
|
||||
static int flags_to_mode(gpio::Flags flags, uint8_t pin) {
|
||||
if (flags == gpio::FLAG_INPUT) { // NOLINT(bugprone-branch-clone)
|
||||
return INPUT;
|
||||
} else if (flags == gpio::FLAG_OUTPUT) {
|
||||
@@ -25,14 +25,16 @@ static int IRAM_ATTR flags_to_mode(gpio::Flags flags, uint8_t pin) {
|
||||
}
|
||||
|
||||
struct ISRPinArg {
|
||||
uint32_t mask;
|
||||
uint8_t pin;
|
||||
bool inverted;
|
||||
};
|
||||
|
||||
ISRInternalGPIOPin RP2040GPIOPin::to_isr() const {
|
||||
auto *arg = new ISRPinArg{}; // NOLINT(cppcoreguidelines-owning-memory)
|
||||
arg->pin = pin_;
|
||||
arg->inverted = inverted_;
|
||||
arg->pin = this->pin_;
|
||||
arg->inverted = this->inverted_;
|
||||
arg->mask = 1 << this->pin_;
|
||||
return ISRInternalGPIOPin((void *) arg);
|
||||
}
|
||||
|
||||
@@ -81,21 +83,36 @@ void RP2040GPIOPin::detach_interrupt() const { detachInterrupt(pin_); }
|
||||
using namespace rp2040;
|
||||
|
||||
bool IRAM_ATTR ISRInternalGPIOPin::digital_read() {
|
||||
auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
|
||||
return bool(digitalRead(arg->pin)) != arg->inverted; // NOLINT
|
||||
auto *arg = reinterpret_cast<ISRPinArg *>(this->arg_);
|
||||
return bool(sio_hw->gpio_in & arg->mask) != arg->inverted;
|
||||
}
|
||||
|
||||
void IRAM_ATTR ISRInternalGPIOPin::digital_write(bool value) {
|
||||
auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
|
||||
digitalWrite(arg->pin, value != arg->inverted ? 1 : 0); // NOLINT
|
||||
auto *arg = reinterpret_cast<ISRPinArg *>(this->arg_);
|
||||
if (value != arg->inverted) {
|
||||
sio_hw->gpio_set = arg->mask;
|
||||
} else {
|
||||
sio_hw->gpio_clr = arg->mask;
|
||||
}
|
||||
}
|
||||
|
||||
void IRAM_ATTR ISRInternalGPIOPin::clear_interrupt() {
|
||||
// TODO: implement
|
||||
// auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
|
||||
// GPIO_REG_WRITE(GPIO_STATUS_W1TC_ADDRESS, 1UL << arg->pin);
|
||||
}
|
||||
|
||||
void IRAM_ATTR ISRInternalGPIOPin::pin_mode(gpio::Flags flags) {
|
||||
auto *arg = reinterpret_cast<ISRPinArg *>(arg_);
|
||||
pinMode(arg->pin, flags_to_mode(flags, arg->pin)); // NOLINT
|
||||
auto *arg = reinterpret_cast<ISRPinArg *>(this->arg_);
|
||||
if (flags & gpio::FLAG_OUTPUT) {
|
||||
sio_hw->gpio_oe_set = arg->mask;
|
||||
} else if (flags & gpio::FLAG_INPUT) {
|
||||
sio_hw->gpio_oe_clr = arg->mask;
|
||||
hw_write_masked(&padsbank0_hw->io[arg->pin],
|
||||
(bool_to_bit(flags & gpio::FLAG_PULLUP) << PADS_BANK0_GPIO0_PUE_LSB) |
|
||||
(bool_to_bit(flags & gpio::FLAG_PULLDOWN) << PADS_BANK0_GPIO0_PDE_LSB),
|
||||
PADS_BANK0_GPIO0_PUE_BITS | PADS_BANK0_GPIO0_PDE_BITS);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace esphome
|
||||
|
||||
@@ -87,7 +87,7 @@ class RP2040Preferences : public ESPPreferences {
|
||||
RP2040Preferences() : eeprom_sector_(&_EEPROM_start) {}
|
||||
void setup() {
|
||||
s_flash_storage = new uint8_t[RP2040_FLASH_STORAGE_SIZE]; // NOLINT
|
||||
ESP_LOGVV(TAG, "Loading preferences from flash...");
|
||||
ESP_LOGVV(TAG, "Loading preferences from flash");
|
||||
memcpy(s_flash_storage, this->eeprom_sector_, RP2040_FLASH_STORAGE_SIZE);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ class RP2040Preferences : public ESPPreferences {
|
||||
if (s_prevent_write)
|
||||
return false;
|
||||
|
||||
ESP_LOGD(TAG, "Saving preferences to flash...");
|
||||
ESP_LOGD(TAG, "Saving");
|
||||
|
||||
{
|
||||
InterruptLock lock;
|
||||
@@ -129,7 +129,7 @@ class RP2040Preferences : public ESPPreferences {
|
||||
}
|
||||
|
||||
bool reset() override {
|
||||
ESP_LOGD(TAG, "Cleaning up preferences in flash...");
|
||||
ESP_LOGD(TAG, "Erasing storage");
|
||||
{
|
||||
InterruptLock lock;
|
||||
::rp2040.idleOtherCore();
|
||||
|
||||
@@ -138,7 +138,7 @@ void RP2040PIOLEDStripLightOutput::setup() {
|
||||
}
|
||||
|
||||
void RP2040PIOLEDStripLightOutput::write_state(light::LightState *state) {
|
||||
ESP_LOGVV(TAG, "Writing state...");
|
||||
ESP_LOGVV(TAG, "Writing state");
|
||||
|
||||
if (this->is_failed()) {
|
||||
ESP_LOGW(TAG, "Light is in failed state, not writing state.");
|
||||
|
||||
@@ -8,16 +8,28 @@ from esphome.const import (
|
||||
CONF_HEIGHT,
|
||||
CONF_ID,
|
||||
CONF_LAMBDA,
|
||||
CONF_POSITION,
|
||||
CONF_WIDTH,
|
||||
CONF_X,
|
||||
CONF_Y,
|
||||
PLATFORM_HOST,
|
||||
)
|
||||
|
||||
sdl_ns = cg.esphome_ns.namespace("sdl")
|
||||
Sdl = sdl_ns.class_("Sdl", display.Display, cg.Component)
|
||||
sdl_window_flags = cg.global_ns.enum("SDL_WindowFlags")
|
||||
|
||||
|
||||
CONF_SDL_OPTIONS = "sdl_options"
|
||||
CONF_SDL_ID = "sdl_id"
|
||||
CONF_WINDOW_OPTIONS = "window_options"
|
||||
WINDOW_OPTIONS = (
|
||||
"borderless",
|
||||
"always_on_top",
|
||||
"fullscreen",
|
||||
"skip_taskbar",
|
||||
"resizable",
|
||||
)
|
||||
|
||||
|
||||
def get_sdl_options(value):
|
||||
@@ -29,6 +41,10 @@ def get_sdl_options(value):
|
||||
raise cv.Invalid("Unable to run sdl2-config - have you installed sdl2?") from e
|
||||
|
||||
|
||||
def get_window_options():
|
||||
return {cv.Optional(option, default=False): cv.boolean for option in WINDOW_OPTIONS}
|
||||
|
||||
|
||||
CONFIG_SCHEMA = cv.All(
|
||||
display.FULL_DISPLAY_SCHEMA.extend(
|
||||
cv.Schema(
|
||||
@@ -44,6 +60,17 @@ CONFIG_SCHEMA = cv.All(
|
||||
}
|
||||
),
|
||||
),
|
||||
cv.Optional(CONF_WINDOW_OPTIONS): cv.Schema(
|
||||
{
|
||||
cv.Optional(CONF_POSITION): cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_X): cv.int_,
|
||||
cv.Required(CONF_Y): cv.int_,
|
||||
}
|
||||
),
|
||||
**get_window_options(),
|
||||
}
|
||||
),
|
||||
}
|
||||
)
|
||||
),
|
||||
@@ -65,6 +92,19 @@ async def to_code(config):
|
||||
(width, height) = dimensions
|
||||
cg.add(var.set_dimensions(width, height))
|
||||
|
||||
if window_options := config.get(CONF_WINDOW_OPTIONS):
|
||||
create_flags = 0
|
||||
for option in WINDOW_OPTIONS:
|
||||
value = window_options.get(option, False)
|
||||
if value:
|
||||
create_flags = create_flags | getattr(
|
||||
sdl_window_flags, "SDL_WINDOW_" + option.upper()
|
||||
)
|
||||
cg.add(var.set_window_options(create_flags))
|
||||
|
||||
if position := window_options.get(CONF_POSITION):
|
||||
cg.add(var.set_position(position[CONF_X], position[CONF_Y]))
|
||||
|
||||
if lamb := config.get(CONF_LAMBDA):
|
||||
lambda_ = await cg.process_lambda(
|
||||
lamb, [(display.DisplayRef, "it")], return_type=cg.void
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace sdl {
|
||||
void Sdl::setup() {
|
||||
ESP_LOGD(TAG, "Starting setup");
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
this->window_ = SDL_CreateWindow(App.get_name().c_str(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
|
||||
this->width_, this->height_, SDL_WINDOW_RESIZABLE);
|
||||
this->window_ = SDL_CreateWindow(App.get_name().c_str(), this->pos_x_, this->pos_y_, this->width_, this->height_,
|
||||
this->window_options_);
|
||||
this->renderer_ = SDL_CreateRenderer(this->window_, -1, SDL_RENDERER_SOFTWARE);
|
||||
SDL_RenderSetLogicalSize(this->renderer_, this->width_, this->height_);
|
||||
this->texture_ =
|
||||
|
||||
@@ -28,6 +28,11 @@ class Sdl : public display::Display {
|
||||
this->width_ = width;
|
||||
this->height_ = height;
|
||||
}
|
||||
void set_window_options(uint32_t window_options) { this->window_options_ = window_options; }
|
||||
void set_position(uint16_t pos_x, uint16_t pos_y) {
|
||||
this->pos_x_ = pos_x;
|
||||
this->pos_y_ = pos_y;
|
||||
}
|
||||
int get_width() override { return this->width_; }
|
||||
int get_height() override { return this->height_; }
|
||||
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
||||
@@ -49,6 +54,9 @@ class Sdl : public display::Display {
|
||||
void redraw_(SDL_Rect &rect);
|
||||
int width_{};
|
||||
int height_{};
|
||||
uint32_t window_options_{0};
|
||||
int pos_x_{SDL_WINDOWPOS_UNDEFINED};
|
||||
int pos_y_{SDL_WINDOWPOS_UNDEFINED};
|
||||
SDL_Renderer *renderer_{};
|
||||
SDL_Window *window_{};
|
||||
SDL_Texture *texture_{};
|
||||
|
||||
@@ -17,31 +17,31 @@ static const uint16_t SDP3X_STOP_MEAS = 0x3FF9;
|
||||
void SDP3XComponent::update() { this->read_pressure_(); }
|
||||
|
||||
void SDP3XComponent::setup() {
|
||||
ESP_LOGD(TAG, "Setting up SDP3X...");
|
||||
ESP_LOGCONFIG(TAG, "Running setup");
|
||||
|
||||
if (!this->write_command(SDP3X_STOP_MEAS)) {
|
||||
ESP_LOGW(TAG, "Stop SDP3X failed!"); // This sometimes fails for no good reason
|
||||
ESP_LOGW(TAG, "Stop failed"); // This sometimes fails for no good reason
|
||||
}
|
||||
|
||||
if (!this->write_command(SDP3X_SOFT_RESET)) {
|
||||
ESP_LOGW(TAG, "Soft Reset SDP3X failed!"); // This sometimes fails for no good reason
|
||||
ESP_LOGW(TAG, "Soft Reset failed"); // This sometimes fails for no good reason
|
||||
}
|
||||
|
||||
this->set_timeout(20, [this] {
|
||||
if (!this->write_command(SDP3X_READ_ID1)) {
|
||||
ESP_LOGE(TAG, "Read ID1 SDP3X failed!");
|
||||
ESP_LOGE(TAG, "Read ID1 failed");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
if (!this->write_command(SDP3X_READ_ID2)) {
|
||||
ESP_LOGE(TAG, "Read ID2 SDP3X failed!");
|
||||
ESP_LOGE(TAG, "Read ID2 failed");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t data[6];
|
||||
if (!this->read_data(data, 6)) {
|
||||
ESP_LOGE(TAG, "Read ID SDP3X failed!");
|
||||
ESP_LOGE(TAG, "Read ID failed");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
@@ -79,18 +79,18 @@ void SDP3XComponent::setup() {
|
||||
}
|
||||
|
||||
if (!this->write_command(measurement_mode_ == DP_AVG ? SDP3X_START_DP_AVG : SDP3X_START_MASS_FLOW_AVG)) {
|
||||
ESP_LOGE(TAG, "Start Measurements SDP3X failed!");
|
||||
ESP_LOGE(TAG, "Start Measurements failed");
|
||||
this->mark_failed();
|
||||
return;
|
||||
}
|
||||
ESP_LOGCONFIG(TAG, "SDP3X started!");
|
||||
ESP_LOGCONFIG(TAG, "started");
|
||||
});
|
||||
}
|
||||
void SDP3XComponent::dump_config() {
|
||||
LOG_SENSOR(" ", "SDP3X", this);
|
||||
LOG_I2C_DEVICE(this);
|
||||
if (this->is_failed()) {
|
||||
ESP_LOGE(TAG, " Connection with SDP3X failed!");
|
||||
ESP_LOGE(TAG, " Connection with failed");
|
||||
}
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ void SDP3XComponent::dump_config() {
|
||||
void SDP3XComponent::read_pressure_() {
|
||||
uint16_t data[3];
|
||||
if (!this->read_data(data, 3)) {
|
||||
ESP_LOGW(TAG, "Couldn't read SDP3X data!");
|
||||
ESP_LOGW(TAG, "Couldn't read data");
|
||||
this->status_set_warning();
|
||||
return;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user