1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-30 06:33:51 +00:00

Refactor API send_message from template to non-template implementation (#9561)

This commit is contained in:
J. Nick Koston
2025-07-17 12:28:14 -10:00
committed by GitHub
parent 91e5bcf787
commit f5afe1145e
10 changed files with 52 additions and 47 deletions

View File

@@ -223,7 +223,8 @@ void VoiceAssistant::loop() {
msg.wake_word_phrase = this->wake_word_;
this->wake_word_ = "";
if (this->api_client_ == nullptr || !this->api_client_->send_message(msg)) {
if (this->api_client_ == nullptr ||
!this->api_client_->send_message(msg, api::VoiceAssistantRequest::MESSAGE_TYPE)) {
ESP_LOGW(TAG, "Could not request start");
this->error_trigger_->trigger("not-connected", "Could not request start");
this->continuous_ = false;
@@ -245,7 +246,7 @@ void VoiceAssistant::loop() {
if (this->audio_mode_ == AUDIO_MODE_API) {
api::VoiceAssistantAudio msg;
msg.data.assign((char *) this->send_buffer_, read_bytes);
this->api_client_->send_message(msg);
this->api_client_->send_message(msg, api::VoiceAssistantAudio::MESSAGE_TYPE);
} else {
if (!this->udp_socket_running_) {
if (!this->start_udp_socket_()) {
@@ -331,7 +332,7 @@ void VoiceAssistant::loop() {
api::VoiceAssistantAnnounceFinished msg;
msg.success = true;
this->api_client_->send_message(msg);
this->api_client_->send_message(msg, api::VoiceAssistantAnnounceFinished::MESSAGE_TYPE);
break;
}
}
@@ -580,7 +581,7 @@ void VoiceAssistant::signal_stop_() {
ESP_LOGD(TAG, "Signaling stop");
api::VoiceAssistantRequest msg;
msg.start = false;
this->api_client_->send_message(msg);
this->api_client_->send_message(msg, api::VoiceAssistantRequest::MESSAGE_TYPE);
}
void VoiceAssistant::start_playback_timeout_() {
@@ -590,7 +591,7 @@ void VoiceAssistant::start_playback_timeout_() {
api::VoiceAssistantAnnounceFinished msg;
msg.success = true;
this->api_client_->send_message(msg);
this->api_client_->send_message(msg, api::VoiceAssistantAnnounceFinished::MESSAGE_TYPE);
});
}