mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 17:27:45 +01:00
commit
362a19c2e1
17 changed files with 112 additions and 43 deletions
|
@ -76,7 +76,7 @@ void AirthingsWaveBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt
|
|||
}
|
||||
}
|
||||
|
||||
bool AirthingsWaveBase::is_valid_voc_value_(uint16_t voc) { return 0 <= voc && voc <= 16383; }
|
||||
bool AirthingsWaveBase::is_valid_voc_value_(uint16_t voc) { return voc <= 16383; }
|
||||
|
||||
void AirthingsWaveBase::update() {
|
||||
if (this->node_state != espbt::ClientState::ESTABLISHED) {
|
||||
|
|
|
@ -51,9 +51,9 @@ void AirthingsWavePlus::read_sensors(uint8_t *raw_value, uint16_t value_len) {
|
|||
this->response_received_();
|
||||
}
|
||||
|
||||
bool AirthingsWavePlus::is_valid_radon_value_(uint16_t radon) { return 0 <= radon && radon <= 16383; }
|
||||
bool AirthingsWavePlus::is_valid_radon_value_(uint16_t radon) { return radon <= 16383; }
|
||||
|
||||
bool AirthingsWavePlus::is_valid_co2_value_(uint16_t co2) { return 0 <= co2 && co2 <= 16383; }
|
||||
bool AirthingsWavePlus::is_valid_co2_value_(uint16_t co2) { return co2 <= 16383; }
|
||||
|
||||
void AirthingsWavePlus::dump_config() {
|
||||
// these really don't belong here, but there doesn't seem to be a
|
||||
|
|
|
@ -1420,6 +1420,7 @@ message VoiceAssistantRequest {
|
|||
|
||||
bool start = 1;
|
||||
string conversation_id = 2;
|
||||
bool use_vad = 3;
|
||||
}
|
||||
|
||||
message VoiceAssistantResponse {
|
||||
|
|
|
@ -907,12 +907,13 @@ BluetoothConnectionsFreeResponse APIConnection::subscribe_bluetooth_connections_
|
|||
#endif
|
||||
|
||||
#ifdef USE_VOICE_ASSISTANT
|
||||
bool APIConnection::request_voice_assistant(bool start, const std::string &conversation_id) {
|
||||
bool APIConnection::request_voice_assistant(bool start, const std::string &conversation_id, bool use_vad) {
|
||||
if (!this->voice_assistant_subscription_)
|
||||
return false;
|
||||
VoiceAssistantRequest msg;
|
||||
msg.start = start;
|
||||
msg.conversation_id = conversation_id;
|
||||
msg.use_vad = use_vad;
|
||||
return this->send_voice_assistant_request(msg);
|
||||
}
|
||||
void APIConnection::on_voice_assistant_response(const VoiceAssistantResponse &msg) {
|
||||
|
|
|
@ -124,7 +124,7 @@ class APIConnection : public APIServerConnection {
|
|||
void subscribe_voice_assistant(const SubscribeVoiceAssistantRequest &msg) override {
|
||||
this->voice_assistant_subscription_ = msg.subscribe;
|
||||
}
|
||||
bool request_voice_assistant(bool start, const std::string &conversation_id);
|
||||
bool request_voice_assistant(bool start, const std::string &conversation_id, bool use_vad);
|
||||
void on_voice_assistant_response(const VoiceAssistantResponse &msg) override;
|
||||
void on_voice_assistant_event_response(const VoiceAssistantEventResponse &msg) override;
|
||||
#endif
|
||||
|
|
|
@ -6348,6 +6348,10 @@ bool VoiceAssistantRequest::decode_varint(uint32_t field_id, ProtoVarInt value)
|
|||
this->start = value.as_bool();
|
||||
return true;
|
||||
}
|
||||
case 3: {
|
||||
this->use_vad = value.as_bool();
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -6365,6 +6369,7 @@ bool VoiceAssistantRequest::decode_length(uint32_t field_id, ProtoLengthDelimite
|
|||
void VoiceAssistantRequest::encode(ProtoWriteBuffer buffer) const {
|
||||
buffer.encode_bool(1, this->start);
|
||||
buffer.encode_string(2, this->conversation_id);
|
||||
buffer.encode_bool(3, this->use_vad);
|
||||
}
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
void VoiceAssistantRequest::dump_to(std::string &out) const {
|
||||
|
@ -6377,6 +6382,10 @@ void VoiceAssistantRequest::dump_to(std::string &out) const {
|
|||
out.append(" conversation_id: ");
|
||||
out.append("'").append(this->conversation_id).append("'");
|
||||
out.append("\n");
|
||||
|
||||
out.append(" use_vad: ");
|
||||
out.append(YESNO(this->use_vad));
|
||||
out.append("\n");
|
||||
out.append("}");
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1655,6 +1655,7 @@ class VoiceAssistantRequest : public ProtoMessage {
|
|||
public:
|
||||
bool start{false};
|
||||
std::string conversation_id{};
|
||||
bool use_vad{false};
|
||||
void encode(ProtoWriteBuffer buffer) const override;
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
void dump_to(std::string &out) const override;
|
||||
|
|
|
@ -323,16 +323,16 @@ void APIServer::on_shutdown() {
|
|||
}
|
||||
|
||||
#ifdef USE_VOICE_ASSISTANT
|
||||
bool APIServer::start_voice_assistant(const std::string &conversation_id) {
|
||||
bool APIServer::start_voice_assistant(const std::string &conversation_id, bool use_vad) {
|
||||
for (auto &c : this->clients_) {
|
||||
if (c->request_voice_assistant(true, conversation_id))
|
||||
if (c->request_voice_assistant(true, conversation_id, use_vad))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
void APIServer::stop_voice_assistant() {
|
||||
for (auto &c : this->clients_) {
|
||||
if (c->request_voice_assistant(false, ""))
|
||||
if (c->request_voice_assistant(false, "", false))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class APIServer : public Component, public Controller {
|
|||
#endif
|
||||
|
||||
#ifdef USE_VOICE_ASSISTANT
|
||||
bool start_voice_assistant(const std::string &conversation_id);
|
||||
bool start_voice_assistant(const std::string &conversation_id, bool use_vad);
|
||||
void stop_voice_assistant();
|
||||
#endif
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ async def to_code(config):
|
|||
cg.add_build_flag("-DDSMR_WATER_MBUS_ID=" + str(config[CONF_WATER_MBUS_ID]))
|
||||
|
||||
# DSMR Parser
|
||||
cg.add_library("glmnet/Dsmr", "0.7")
|
||||
cg.add_library("glmnet/Dsmr", "0.8")
|
||||
|
||||
# Crypto
|
||||
cg.add_library("rweather/Crypto", "0.4.0")
|
||||
|
|
|
@ -243,6 +243,30 @@ CONFIG_SCHEMA = cv.Schema(
|
|||
device_class=DEVICE_CLASS_WATER,
|
||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
||||
),
|
||||
cv.Optional(
|
||||
"active_energy_import_current_average_demand"
|
||||
): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_KILOWATT,
|
||||
accuracy_decimals=3,
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
cv.Optional(
|
||||
"active_energy_import_maximum_demand_running_month"
|
||||
): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_KILOWATT,
|
||||
accuracy_decimals=3,
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
cv.Optional(
|
||||
"active_energy_import_maximum_demand_last_13_months"
|
||||
): sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_KILOWATT,
|
||||
accuracy_decimals=3,
|
||||
device_class=DEVICE_CLASS_POWER,
|
||||
state_class=STATE_CLASS_MEASUREMENT,
|
||||
),
|
||||
}
|
||||
).extend(cv.COMPONENT_SCHEMA)
|
||||
|
||||
|
|
|
@ -112,7 +112,6 @@ CONFIG_SCHEMA = cv.All(
|
|||
|
||||
FINAL_VALIDATE_SCHEMA = uart.final_validate_device_schema(
|
||||
"ld2410",
|
||||
baud_rate=256000,
|
||||
require_tx=True,
|
||||
require_rx=True,
|
||||
parity="NONE",
|
||||
|
|
57
esphome/components/sigma_delta_output/sigma_delta_output.cpp
Normal file
57
esphome/components/sigma_delta_output/sigma_delta_output.cpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
#include "sigma_delta_output.h"
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace sigma_delta_output {
|
||||
|
||||
static const char *const TAG = "output.sigma_delta";
|
||||
|
||||
void SigmaDeltaOutput::setup() {
|
||||
if (this->pin_)
|
||||
this->pin_->setup();
|
||||
}
|
||||
|
||||
void SigmaDeltaOutput::dump_config() {
|
||||
ESP_LOGCONFIG(TAG, "Sigma Delta Output:");
|
||||
LOG_PIN(" Pin: ", this->pin_);
|
||||
if (this->state_change_trigger_) {
|
||||
ESP_LOGCONFIG(TAG, " State change automation configured");
|
||||
}
|
||||
if (this->turn_on_trigger_) {
|
||||
ESP_LOGCONFIG(TAG, " Turn on automation configured");
|
||||
}
|
||||
if (this->turn_off_trigger_) {
|
||||
ESP_LOGCONFIG(TAG, " Turn off automation configured");
|
||||
}
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
LOG_FLOAT_OUTPUT(this);
|
||||
}
|
||||
|
||||
void SigmaDeltaOutput::update() {
|
||||
this->accum_ += this->state_;
|
||||
const bool next_value = this->accum_ > 0;
|
||||
|
||||
if (next_value) {
|
||||
this->accum_ -= 1.;
|
||||
}
|
||||
|
||||
if (next_value != this->value_) {
|
||||
this->value_ = next_value;
|
||||
if (this->pin_) {
|
||||
this->pin_->digital_write(next_value);
|
||||
}
|
||||
|
||||
if (this->state_change_trigger_) {
|
||||
this->state_change_trigger_->trigger(next_value);
|
||||
}
|
||||
|
||||
if (next_value && this->turn_on_trigger_) {
|
||||
this->turn_on_trigger_->trigger();
|
||||
} else if (!next_value && this->turn_off_trigger_) {
|
||||
this->turn_off_trigger_->trigger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace sigma_delta_output
|
||||
} // namespace esphome
|
|
@ -1,9 +1,12 @@
|
|||
#pragma once
|
||||
#include "esphome/core/automation.h"
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/hal.h"
|
||||
#include "esphome/components/output/float_output.h"
|
||||
|
||||
namespace esphome {
|
||||
namespace sigma_delta_output {
|
||||
|
||||
class SigmaDeltaOutput : public PollingComponent, public output::FloatOutput {
|
||||
public:
|
||||
Trigger<> *get_turn_on_trigger() {
|
||||
|
@ -25,31 +28,9 @@ class SigmaDeltaOutput : public PollingComponent, public output::FloatOutput {
|
|||
|
||||
void set_pin(GPIOPin *pin) { this->pin_ = pin; };
|
||||
void write_state(float state) override { this->state_ = state; }
|
||||
void update() override {
|
||||
this->accum_ += this->state_;
|
||||
const bool next_value = this->accum_ > 0;
|
||||
|
||||
if (next_value) {
|
||||
this->accum_ -= 1.;
|
||||
}
|
||||
|
||||
if (next_value != this->value_) {
|
||||
this->value_ = next_value;
|
||||
if (this->pin_) {
|
||||
this->pin_->digital_write(next_value);
|
||||
}
|
||||
|
||||
if (this->state_change_trigger_) {
|
||||
this->state_change_trigger_->trigger(next_value);
|
||||
}
|
||||
|
||||
if (next_value && this->turn_on_trigger_) {
|
||||
this->turn_on_trigger_->trigger();
|
||||
} else if (!next_value && this->turn_off_trigger_) {
|
||||
this->turn_off_trigger_->trigger();
|
||||
}
|
||||
}
|
||||
}
|
||||
void setup() override;
|
||||
void dump_config() override;
|
||||
void update() override;
|
||||
|
||||
protected:
|
||||
GPIOPin *pin_{nullptr};
|
||||
|
|
|
@ -130,7 +130,7 @@ void VoiceAssistant::start(struct sockaddr_storage *addr, uint16_t port) {
|
|||
|
||||
void VoiceAssistant::request_start(bool continuous) {
|
||||
ESP_LOGD(TAG, "Requesting start...");
|
||||
if (!api::global_api_server->start_voice_assistant(this->conversation_id_)) {
|
||||
if (!api::global_api_server->start_voice_assistant(this->conversation_id_, this->silence_detection_)) {
|
||||
ESP_LOGW(TAG, "Could not request start.");
|
||||
this->error_trigger_->trigger("not-connected", "Could not request start.");
|
||||
this->continuous_ = false;
|
||||
|
|
|
@ -25,10 +25,9 @@ namespace voice_assistant {
|
|||
|
||||
// Version 1: Initial version
|
||||
// Version 2: Adds raw speaker support
|
||||
// Version 3: Adds continuous support
|
||||
// Version 3: Unused/skip
|
||||
static const uint32_t INITIAL_VERSION = 1;
|
||||
static const uint32_t SPEAKER_SUPPORT = 2;
|
||||
static const uint32_t SILENCE_DETECTION_SUPPORT = 3;
|
||||
|
||||
class VoiceAssistant : public Component {
|
||||
public:
|
||||
|
@ -48,9 +47,6 @@ class VoiceAssistant : public Component {
|
|||
uint32_t get_version() const {
|
||||
#ifdef USE_SPEAKER
|
||||
if (this->speaker_ != nullptr) {
|
||||
if (this->silence_detection_) {
|
||||
return SILENCE_DETECTION_SUPPORT;
|
||||
}
|
||||
return SPEAKER_SUPPORT;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
"""Constants used by esphome."""
|
||||
|
||||
__version__ = "2023.7.0b2"
|
||||
__version__ = "2023.7.0b3"
|
||||
|
||||
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
|
||||
VALID_SUBSTITUTIONS_CHARACTERS = (
|
||||
|
|
Loading…
Reference in a new issue