[core] Use status_momentary_warning/error without a name in components (#20363)

This commit is contained in:
J. Nick Koston
2026-10-09 22:27:19 -04:00
committed by GitHub
parent f7b9646705
commit dc553aae55
21 changed files with 60 additions and 60 deletions
+12 -12
View File
@@ -148,7 +148,7 @@ void CS5460AComponent::schedule_next_check_() {
*/
if (time_left > -15000) {
time_left = 1000;
this->status_momentary_warning("warning", 1000);
this->status_momentary_warning(1000);
} else {
ESP_LOGCONFIG(TAG, "Device officially stuck, resetting");
this->cancel_timeout(STATUS_CHECK_TIMEOUT_ID);
@@ -179,67 +179,67 @@ bool CS5460AComponent::check_status_() {
if (status & (1 << 2)) {
clear |= 1 << 2;
ESP_LOGE(TAG, "Low supply detected");
this->status_momentary_warning("warning", 500);
this->status_momentary_warning(500);
}
if (status & (1 << 3)) {
clear |= 1 << 3;
ESP_LOGE(TAG, "Modulator oscillation on current channel");
this->status_momentary_warning("warning", 500);
this->status_momentary_warning(500);
}
if (status & (1 << 4)) {
clear |= 1 << 4;
ESP_LOGE(TAG, "Modulator oscillation on voltage channel");
this->status_momentary_warning("warning", 500);
this->status_momentary_warning(500);
}
if (status & (1 << 5)) {
clear |= 1 << 5;
ESP_LOGE(TAG, "Watch-dog timeout");
this->status_momentary_warning("warning", 500);
this->status_momentary_warning(500);
}
if (status & (1 << 11)) {
clear |= 1 << 11;
ESP_LOGE(TAG, "EOUT Energy Accumulation Register out of range");
this->status_momentary_warning("warning", 500);
this->status_momentary_warning(500);
}
if (status & (1 << 12)) {
clear |= 1 << 12;
ESP_LOGE(TAG, "Energy out of range");
this->status_momentary_warning("warning", 500);
this->status_momentary_warning(500);
}
if (status & (1 << 13)) {
clear |= 1 << 13;
ESP_LOGE(TAG, "RMS voltage out of range");
this->status_momentary_warning("warning", 500);
this->status_momentary_warning(500);
}
if (status & (1 << 14)) {
clear |= 1 << 14;
ESP_LOGE(TAG, "RMS current out of range");
this->status_momentary_warning("warning", 500);
this->status_momentary_warning(500);
}
if (status & (1 << 15)) {
clear |= 1 << 15;
ESP_LOGE(TAG, "Power calculation out of range");
this->status_momentary_warning("warning", 500);
this->status_momentary_warning(500);
}
if (status & (1 << 16)) {
clear |= 1 << 16;
ESP_LOGE(TAG, "Voltage out of range");
this->status_momentary_warning("warning", 500);
this->status_momentary_warning(500);
}
if (status & (1 << 17)) {
clear |= 1 << 17;
ESP_LOGE(TAG, "Current out of range");
this->status_momentary_warning("warning", 500);
this->status_momentary_warning(500);
}
if (status & (1 << 19)) {
+1 -1
View File
@@ -58,7 +58,7 @@ void DebugComponent::loop() {
if (new_free_heap < this->free_heap_ / 2) {
this->free_heap_ = new_free_heap;
ESP_LOGD(TAG, "Free Heap Size: %" PRIu32 " bytes", this->free_heap_);
this->status_momentary_warning("heap", 1000);
this->status_momentary_warning(1000);
}
#ifdef USE_SENSOR
@@ -33,7 +33,7 @@ class DemoAlarmControlPanel final : public AlarmControlPanel, public Component {
case ACP_STATE_ARMED_AWAY:
if (this->get_requires_code_to_arm()) {
if (!code.has_value() || *code != "1234") {
this->status_momentary_error("invalid_code", 5000);
this->status_momentary_error(5000);
return;
}
}
@@ -42,7 +42,7 @@ class DemoAlarmControlPanel final : public AlarmControlPanel, public Component {
case ACP_STATE_DISARMED:
if (this->get_requires_code()) {
if (!code.has_value() || *code != "1234") {
this->status_momentary_error("invalid_code", 5000);
this->status_momentary_error(5000);
return;
}
}
+2 -2
View File
@@ -231,7 +231,7 @@ bool ES8388::set_dac_output(DacOutputLine line) {
optional<DacOutputLine> ES8388::get_dac_power() {
uint8_t dac_power;
if (!this->read_byte(ES8388_DACPOWER, &dac_power)) {
this->status_momentary_warning("dacpower_read");
this->status_momentary_warning();
return {};
}
switch (dac_power) {
@@ -274,7 +274,7 @@ bool ES8388::set_adc_input_mic(AdcInputMicLine line) {
optional<AdcInputMicLine> ES8388::get_mic_input() {
uint8_t mic_input;
if (!this->read_byte(ES8388_ADCCONTROL2, &mic_input)) {
this->status_momentary_warning("adccontrol2_read");
this->status_momentary_warning();
return {};
}
switch (mic_input) {
@@ -635,7 +635,7 @@ error:
this->cleanup_connection_();
this->status_momentary_error("err", 5000);
this->status_momentary_error(5000);
#ifdef USE_OTA_STATE_LISTENER
this->notify_state_(ota::OTA_ERROR, 0.0f, static_cast<uint8_t>(error_code));
#endif
@@ -406,7 +406,7 @@ esp_err_t ESPNowComponent::send(const uint8_t *peer_address, const uint8_t *payl
if (packet == nullptr) {
this->send_packet_queue_.increment_dropped_count();
ESP_LOGE(TAG, "Failed to allocate send packet from pool");
this->status_momentary_warning("send-packet-pool-full");
this->status_momentary_warning();
return ESP_ERR_ESPNOW_NO_MEM;
}
// Load the packet data
@@ -434,7 +434,7 @@ void ESPNowComponent::send_() {
if (packet->callback_ != nullptr) {
packet->callback_(err);
}
this->status_momentary_warning("send-failed");
this->status_momentary_warning();
this->send_packet_pool_.release(packet);
this->current_send_packet_ = nullptr; // Reset current packet
return;
@@ -447,7 +447,7 @@ esp_err_t ESPNowComponent::add_peer(const uint8_t *peer) {
}
if (memcmp(peer, this->own_address_, ESP_NOW_ETH_ALEN) == 0) {
this->status_momentary_warning("peer-add-failed");
this->status_momentary_warning();
return ESP_ERR_INVALID_MAC;
}
@@ -462,7 +462,7 @@ esp_err_t ESPNowComponent::add_peer(const uint8_t *peer) {
char peer_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
format_mac_addr_upper(peer, peer_buf);
ESP_LOGE(TAG, "Failed to add peer %s - %s", peer_buf, LOG_STR_ARG(espnow_error_to_str(err)));
this->status_momentary_warning("peer-add-failed");
this->status_momentary_warning();
return err;
}
}
@@ -492,7 +492,7 @@ esp_err_t ESPNowComponent::del_peer(const uint8_t *peer) {
char peer_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE];
format_mac_addr_upper(peer, peer_buf);
ESP_LOGE(TAG, "Failed to delete peer %s - %s", peer_buf, LOG_STR_ARG(espnow_error_to_str(err)));
this->status_momentary_warning("peer-del-failed");
this->status_momentary_warning();
return err;
}
}
@@ -28,7 +28,7 @@ std::shared_ptr<HttpContainer> HttpRequestArduino::perform(const char *url, cons
const std::vector<Header> &request_headers,
const std::vector<std::string> &lower_case_collect_headers) {
if (!network::is_connected()) {
this->status_momentary_error("failed", 1000);
this->status_momentary_error(1000);
ESP_LOGW(TAG, "HTTP Request failed; Not connected to network");
return nullptr;
}
@@ -85,7 +85,7 @@ std::shared_ptr<HttpContainer> HttpRequestArduino::perform(const char *url, cons
if (!status) {
ESP_LOGW(TAG, "HTTP Request failed; URL: %s", url);
container->end();
this->status_momentary_error("failed", 1000);
this->status_momentary_error(1000);
return nullptr;
}
@@ -143,13 +143,13 @@ std::shared_ptr<HttpContainer> HttpRequestArduino::perform(const char *url, cons
ESP_LOGW(TAG, "HTTP Request failed; URL: %s; Error: %s", url,
HTTPClient::errorToString(container->status_code).c_str());
this->status_momentary_error("failed", 1000);
this->status_momentary_error(1000);
container->end();
return nullptr;
}
if (!is_success(container->status_code)) {
ESP_LOGE(TAG, "HTTP Request failed; URL: %s; Code: %d", url, container->status_code);
this->status_momentary_error("failed", 1000);
this->status_momentary_error(1000);
// Still return the container, so it can be used to get the status code and error message
}
@@ -22,7 +22,7 @@ std::shared_ptr<HttpContainer> HttpRequestHost::perform(const char *url, const c
const std::vector<Header> &request_headers,
const std::vector<std::string> &lower_case_collect_headers) {
if (!network::is_connected()) {
this->status_momentary_error("failed", 1000);
this->status_momentary_error(1000);
ESP_LOGW(TAG, "HTTP Request failed; Not connected to network");
return nullptr;
}
@@ -101,7 +101,7 @@ std::shared_ptr<HttpContainer> HttpRequestHost::perform(const char *url, const c
if (!result) {
ESP_LOGW(TAG, "HTTP Request failed; URL: %s, error code: %u", url, (unsigned) result.error());
container->end();
this->status_momentary_error("failed", 1000);
this->status_momentary_error(1000);
return nullptr;
}
App.feed_wdt();
@@ -109,7 +109,7 @@ std::shared_ptr<HttpContainer> HttpRequestHost::perform(const char *url, const c
container->status_code = response.status;
if (!is_success(response.status)) {
ESP_LOGE(TAG, "HTTP Request failed; URL: %s; Code: %d", url, response.status);
this->status_momentary_error("failed", 1000);
this->status_momentary_error(1000);
// Still return the container, so it can be used to get the status code and error message
}
@@ -54,7 +54,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::perform(const char *url, const ch
const std::vector<Header> &request_headers,
const std::vector<std::string> &lower_case_collect_headers) {
if (!network::is_connected()) {
this->status_momentary_error("failed", ERROR_DURATION_MS);
this->status_momentary_error(ERROR_DURATION_MS);
ESP_LOGE(TAG, "HTTP Request failed; Not connected to network");
return nullptr;
}
@@ -71,7 +71,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::perform(const char *url, const ch
} else if (strcmp(method, "PATCH") == 0) {
method_idf = HTTP_METHOD_PATCH;
} else {
this->status_momentary_error("failed", ERROR_DURATION_MS);
this->status_momentary_error(ERROR_DURATION_MS);
ESP_LOGE(TAG, "HTTP Request failed; Unsupported method");
return nullptr;
}
@@ -110,7 +110,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::perform(const char *url, const ch
esp_http_client_handle_t client = esp_http_client_init(&config);
if (client == nullptr) {
this->status_momentary_error("failed", ERROR_DURATION_MS);
this->status_momentary_error(ERROR_DURATION_MS);
ESP_LOGE(TAG, "HTTP Request failed; client could not be initialized");
return nullptr;
}
@@ -131,7 +131,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::perform(const char *url, const ch
esp_err_t err = esp_http_client_open(client, body_len);
if (err != ESP_OK) {
this->status_momentary_error("failed", ERROR_DURATION_MS);
this->status_momentary_error(ERROR_DURATION_MS);
ESP_LOGE(TAG, "HTTP Request failed: %s", esp_err_to_name(err));
esp_http_client_cleanup(client);
return nullptr;
@@ -154,7 +154,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::perform(const char *url, const ch
}
if (err != ESP_OK) {
this->status_momentary_error("failed", ERROR_DURATION_MS);
this->status_momentary_error(ERROR_DURATION_MS);
ESP_LOGE(TAG, "HTTP Request failed: %s", esp_err_to_name(err));
esp_http_client_cleanup(client);
return nullptr;
@@ -179,7 +179,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::perform(const char *url, const ch
err = esp_http_client_set_redirection(client);
if (err != ESP_OK) {
ESP_LOGE(TAG, "esp_http_client_set_redirection failed: %s", esp_err_to_name(err));
this->status_momentary_error("failed", ERROR_DURATION_MS);
this->status_momentary_error(ERROR_DURATION_MS);
esp_http_client_cleanup(client);
return nullptr;
}
@@ -192,7 +192,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::perform(const char *url, const ch
err = esp_http_client_open(client, 0);
if (err != ESP_OK) {
ESP_LOGE(TAG, "esp_http_client_open failed: %s", esp_err_to_name(err));
this->status_momentary_error("failed", ERROR_DURATION_MS);
this->status_momentary_error(ERROR_DURATION_MS);
esp_http_client_cleanup(client);
return nullptr;
}
@@ -220,7 +220,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::perform(const char *url, const ch
}
ESP_LOGE(TAG, "HTTP Request failed; URL: %s; Code: %d", url, container->status_code);
this->status_momentary_error("failed", ERROR_DURATION_MS);
this->status_momentary_error(ERROR_DURATION_MS);
return container;
}
@@ -397,7 +397,7 @@ void I2SAudioMicrophone::loop() {
if (!this->start_driver_()) {
ESP_LOGE(TAG, "Driver failed to start; retrying in 1 second");
this->status_momentary_error("driver_fail", 1000);
this->status_momentary_error(1000);
this->stop_driver_(); // Stop/frees whatever possibly started
break;
}
@@ -408,7 +408,7 @@ void I2SAudioMicrophone::loop() {
if (this->task_handle_ == nullptr) {
ESP_LOGE(TAG, "Task failed to start, retrying in 1 second");
this->status_momentary_error("task_fail", 1000);
this->status_momentary_error(1000);
this->stop_driver_(); // Stops the driver to return the lock; will be reloaded in next attempt
}
}
@@ -140,7 +140,7 @@ void I2SAudioSpeakerBase::loop() {
if (this->start_i2s_driver(this->audio_stream_info_) != ESP_OK) {
ESP_LOGE(TAG, "Driver failed to start; retrying in 1 second");
this->status_momentary_error("driver-failure", 1000);
this->status_momentary_error(1000);
break;
}
@@ -153,7 +153,7 @@ void I2SAudioSpeakerBase::loop() {
if (this->speaker_task_handle_ == nullptr) {
ESP_LOGE(TAG, "Task failed to start, retrying in 1 second");
this->status_momentary_error("task-failure", 1000);
this->status_momentary_error(1000);
this->stop_i2s_driver_(); // Stops the driver to return the lock; will be reloaded in next attempt
}
break;
@@ -471,14 +471,14 @@ void MicroWakeWord::loop() {
// uses floating point operations.
if (!FrontendPopulateState(&this->frontend_config_, &this->frontend_state_,
this->microphone_source_->get_audio_stream_info().get_sample_rate())) {
this->status_momentary_error("frontend_alloc", 1000);
this->status_momentary_error(1000);
return;
}
if (!this->inference_task_.create(MicroWakeWord::inference_task, "mww", INFERENCE_TASK_STACK_SIZE,
(void *) this, INFERENCE_TASK_PRIORITY, this->task_stack_in_psram_)) {
FrontendFreeStateContents(&this->frontend_state_); // Deallocate frontend state
this->status_momentary_error("task_start", 1000);
this->status_momentary_error(1000);
}
}
break;
@@ -359,7 +359,7 @@ void MixerSpeaker::loop() {
xEventGroupClearBits(this->event_group_, MIXER_TASK_COMMAND_START);
} else {
ESP_LOGE(TAG, "Failed to start; retrying in 1 second");
this->status_momentary_error("failure", 1000);
this->status_momentary_error(1000);
return;
}
}
+1 -1
View File
@@ -20,7 +20,7 @@ void MQTTButtonComponent::setup() {
this->button_->press();
} else {
ESP_LOGW(TAG, "'%s': Received unknown status payload: %s", this->friendly_name_().c_str(), payload.c_str());
this->status_momentary_warning("state", 5000);
this->status_momentary_warning(5000);
}
});
}
+3 -3
View File
@@ -439,7 +439,7 @@ bool MQTTClientComponent::subscribe_(const char *topic, uint8_t qos) {
} else {
delay(5);
ESP_LOGV(TAG, "Subscribe failed for topic='%s'. Will retry", topic);
this->status_momentary_warning("subscribe", 1000);
this->status_momentary_warning(1000);
}
return ret != 0;
}
@@ -499,7 +499,7 @@ void MQTTClientComponent::unsubscribe(const std::string &topic) {
} else {
delay(5);
ESP_LOGV(TAG, "Unsubscribe failed for topic='%s'.", topic.c_str());
this->status_momentary_warning("unsubscribe", 1000);
this->status_momentary_warning(1000);
}
auto it = subscriptions_.begin();
@@ -553,7 +553,7 @@ bool MQTTClientComponent::publish(const char *topic, const char *payload, size_t
ESP_LOGVV(TAG, "Publish payload (len=%u): '%.*s'", payload_length, static_cast<int>(payload_length), payload);
} else {
ESP_LOGV(TAG, "Publish failed for topic='%s' (len=%u). Will retry", topic, payload_length);
this->status_momentary_warning("publish", 1000);
this->status_momentary_warning(1000);
}
}
return ret != 0;
+5 -5
View File
@@ -46,7 +46,7 @@ void MQTTFanComponent::setup() {
case PARSE_NONE:
default:
ESP_LOGW(TAG, "Unknown state payload %s", payload.c_str());
this->status_momentary_warning("state", 5000);
this->status_momentary_warning(5000);
break;
}
});
@@ -71,7 +71,7 @@ void MQTTFanComponent::setup() {
break;
case PARSE_NONE:
ESP_LOGW(TAG, "Unknown direction Payload %s", payload.c_str());
this->status_momentary_warning("direction", 5000);
this->status_momentary_warning(5000);
break;
}
});
@@ -95,7 +95,7 @@ void MQTTFanComponent::setup() {
break;
case PARSE_NONE:
ESP_LOGW(TAG, "Unknown Oscillation Payload %s", payload.c_str());
this->status_momentary_warning("oscillation", 5000);
this->status_momentary_warning(5000);
break;
}
});
@@ -112,11 +112,11 @@ void MQTTFanComponent::setup() {
this->state_->make_call().set_speed(speed_level).perform();
} else {
ESP_LOGW(TAG, "Invalid speed level %d", speed_level);
this->status_momentary_warning("speed", 5000);
this->status_momentary_warning(5000);
}
} else {
ESP_LOGW(TAG, "Invalid speed level %s (int expected)", payload.c_str());
this->status_momentary_warning("speed", 5000);
this->status_momentary_warning(5000);
}
});
}
+1 -1
View File
@@ -25,7 +25,7 @@ void MQTTLockComponent::setup() {
this->lock_->open();
} else {
ESP_LOGW(TAG, "'%s': Received unknown status payload: %s", this->friendly_name_().c_str(), payload.c_str());
this->status_momentary_warning("state", 5000);
this->status_momentary_warning(5000);
}
});
this->lock_->add_on_state_callback(
+1 -1
View File
@@ -29,7 +29,7 @@ void MQTTSwitchComponent::setup() {
case PARSE_NONE:
default:
ESP_LOGW(TAG, "'%s': Received unknown status payload: %s", this->friendly_name_().c_str(), payload.c_str());
this->status_momentary_warning("state", 5000);
this->status_momentary_warning(5000);
break;
}
});
+1 -1
View File
@@ -20,7 +20,7 @@ void MQTTUpdateComponent::setup() {
this->update_->perform();
} else {
ESP_LOGW(TAG, "'%s': Received unknown update payload: %s", this->friendly_name_().c_str(), payload.c_str());
this->status_momentary_warning("state", 5000);
this->status_momentary_warning(5000);
}
});
@@ -171,7 +171,7 @@ bool SoundLevelComponent::start_() {
(stream_info.ms_to_bytes(RING_BUFFER_DURATION_MS) / bytes_per_frame) * bytes_per_frame;
std::shared_ptr<ring_buffer::RingBuffer> temp_ring_buffer = ring_buffer::RingBuffer::create(ring_buffer_size);
if (temp_ring_buffer == nullptr) {
this->status_momentary_error("ring_buffer", 15000);
this->status_momentary_error(15000);
return false;
}
@@ -180,7 +180,7 @@ bool SoundLevelComponent::start_() {
this->audio_source_ = audio::RingBufferAudioSource::create(
temp_ring_buffer, stream_info.ms_to_bytes(MAX_FILL_DURATION_MS), static_cast<uint8_t>(bytes_per_frame));
if (this->audio_source_ == nullptr) {
this->status_momentary_error("audio_source", 15000);
this->status_momentary_error(15000);
return false;
}
this->ring_buffer_ = temp_ring_buffer;
@@ -265,7 +265,7 @@ void VL53L0XSensor::setup() {
void VL53L0XSensor::update() {
if (this->initiated_read_ || this->waiting_for_interrupt_) {
this->publish_state(NAN);
this->status_momentary_warning("update", 5000);
this->status_momentary_warning(5000);
ESP_LOGW(TAG, "%s - update called before prior reading complete - initiated:%d waiting_for_interrupt:%d",
this->name_.c_str(), this->initiated_read_, this->waiting_for_interrupt_);
return;