Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024.2.0b3 #6249

Merged
merged 6 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions esphome/components/dallas/dallas_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,6 @@ bool IRAM_ATTR DallasTemperatureSensor::read_scratch_pad() {
if (!wire->reset()) {
return false;
}
}

{
InterruptLock lock;

wire->select(this->address_);
wire->write8(DALLAS_COMMAND_READ_SCRATCH_PAD);
Expand Down
2 changes: 2 additions & 0 deletions esphome/components/fingerprint_grow/fingerprint_grow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ void FingerprintGrowComponent::aura_led_control(uint8_t state, uint8_t speed, ui
}

uint8_t FingerprintGrowComponent::send_command_() {
while (this->available())
this->read();
this->write((uint8_t) (START_CODE >> 8));
this->write((uint8_t) (START_CODE & 0xFF));
this->write(this->address_[0]);
Expand Down
7 changes: 4 additions & 3 deletions esphome/components/tm1651/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
CODEOWNERS = ["@freekode"]

tm1651_ns = cg.esphome_ns.namespace("tm1651")
TM1651Brightness = tm1651_ns.enum("TM1651Brightness")
TM1651Display = tm1651_ns.class_("TM1651Display", cg.Component)

SetLevelPercentAction = tm1651_ns.class_("SetLevelPercentAction", automation.Action)
Expand All @@ -24,9 +25,9 @@
CONF_LEVEL_PERCENT = "level_percent"

TM1651_BRIGHTNESS_OPTIONS = {
1: TM1651Display.TM1651_BRIGHTNESS_LOW,
2: TM1651Display.TM1651_BRIGHTNESS_MEDIUM,
3: TM1651Display.TM1651_BRIGHTNESS_HIGH,
1: TM1651Brightness.TM1651_BRIGHTNESS_LOW,
2: TM1651Brightness.TM1651_BRIGHTNESS_MEDIUM,
3: TM1651Brightness.TM1651_BRIGHTNESS_HIGH,
}

CONFIG_SCHEMA = cv.All(
Expand Down
14 changes: 7 additions & 7 deletions esphome/components/tm1651/tm1651.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ static const char *const TAG = "tm1651.display";
static const uint8_t MAX_INPUT_LEVEL_PERCENT = 100;
static const uint8_t TM1651_MAX_LEVEL = 7;

static const uint8_t TM1651_BRIGHTNESS_LOW = 0;
static const uint8_t TM1651_BRIGHTNESS_MEDIUM = 2;
static const uint8_t TM1651_BRIGHTNESS_HIGH = 7;
static const uint8_t TM1651_BRIGHTNESS_LOW_HW = 0;
static const uint8_t TM1651_BRIGHTNESS_MEDIUM_HW = 2;
static const uint8_t TM1651_BRIGHTNESS_HIGH_HW = 7;

void TM1651Display::setup() {
ESP_LOGCONFIG(TAG, "Setting up TM1651...");
Expand Down Expand Up @@ -78,14 +78,14 @@ uint8_t TM1651Display::calculate_level_(uint8_t new_level) {

uint8_t TM1651Display::calculate_brightness_(uint8_t new_brightness) {
if (new_brightness <= 1) {
return TM1651_BRIGHTNESS_LOW;
return TM1651_BRIGHTNESS_LOW_HW;
} else if (new_brightness == 2) {
return TM1651_BRIGHTNESS_MEDIUM;
return TM1651_BRIGHTNESS_MEDIUM_HW;
} else if (new_brightness >= 3) {
return TM1651_BRIGHTNESS_HIGH;
return TM1651_BRIGHTNESS_HIGH_HW;
}

return TM1651_BRIGHTNESS_LOW;
return TM1651_BRIGHTNESS_LOW_HW;
}

} // namespace tm1651
Expand Down
7 changes: 7 additions & 0 deletions esphome/components/tm1651/tm1651.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
namespace esphome {
namespace tm1651 {

enum TM1651Brightness : uint8_t {
TM1651_BRIGHTNESS_LOW = 1,
TM1651_BRIGHTNESS_MEDIUM = 2,
TM1651_BRIGHTNESS_HIGH = 3,
};

class TM1651Display : public Component {
public:
void set_clk_pin(InternalGPIOPin *pin) { clk_pin_ = pin; }
Expand All @@ -24,6 +30,7 @@ class TM1651Display : public Component {
void set_level_percent(uint8_t new_level);
void set_level(uint8_t new_level);
void set_brightness(uint8_t new_brightness);
void set_brightness(TM1651Brightness new_brightness) { this->set_brightness(static_cast<uint8_t>(new_brightness)); }

void turn_on();
void turn_off();
Expand Down
10 changes: 9 additions & 1 deletion esphome/components/tuya/fan/tuya_fan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ void TuyaFan::setup() {
}
if (this->oscillation_id_.has_value()) {
this->parent_->register_listener(*this->oscillation_id_, [this](const TuyaDatapoint &datapoint) {
// Whether data type is BOOL or ENUM, it will still be a 1 or a 0, so the functions below are valid in both
// scenarios
ESP_LOGV(TAG, "MCU reported oscillation is: %s", ONOFF(datapoint.value_bool));
this->oscillating = datapoint.value_bool;
this->publish_state();

this->oscillation_type_ = datapoint.type;
});
}
if (this->direction_id_.has_value()) {
Expand Down Expand Up @@ -80,7 +84,11 @@ void TuyaFan::control(const fan::FanCall &call) {
this->parent_->set_boolean_datapoint_value(*this->switch_id_, *call.get_state());
}
if (this->oscillation_id_.has_value() && call.get_oscillating().has_value()) {
this->parent_->set_boolean_datapoint_value(*this->oscillation_id_, *call.get_oscillating());
if (this->oscillation_type_ == TuyaDatapointType::ENUM) {
this->parent_->set_enum_datapoint_value(*this->oscillation_id_, *call.get_oscillating());
} else if (this->speed_type_ == TuyaDatapointType::BOOLEAN) {
this->parent_->set_boolean_datapoint_value(*this->oscillation_id_, *call.get_oscillating());
}
}
if (this->direction_id_.has_value() && call.get_direction().has_value()) {
bool enable = *call.get_direction() == fan::FanDirection::REVERSE;
Expand Down
1 change: 1 addition & 0 deletions esphome/components/tuya/fan/tuya_fan.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class TuyaFan : public Component, public fan::Fan {
optional<uint8_t> direction_id_{};
int speed_count_{};
TuyaDatapointType speed_type_{};
TuyaDatapointType oscillation_type_{};
};

} // namespace tuya
Expand Down
9 changes: 9 additions & 0 deletions esphome/components/voice_assistant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
CONF_ON_TTS_STREAM_START = "on_tts_stream_start"
CONF_ON_TTS_STREAM_END = "on_tts_stream_end"
CONF_ON_WAKE_WORD_DETECTED = "on_wake_word_detected"
CONF_ON_IDLE = "on_idle"

CONF_SILENCE_DETECTION = "silence_detection"
CONF_USE_WAKE_WORD = "use_wake_word"
Expand Down Expand Up @@ -127,6 +128,7 @@ def tts_stream_validate(config):
cv.Optional(CONF_ON_TTS_STREAM_END): automation.validate_automation(
single=True
),
cv.Optional(CONF_ON_IDLE): automation.validate_automation(single=True),
}
).extend(cv.COMPONENT_SCHEMA),
tts_stream_validate,
Expand Down Expand Up @@ -259,6 +261,13 @@ async def to_code(config):
config[CONF_ON_TTS_STREAM_END],
)

if CONF_ON_IDLE in config:
await automation.build_automation(
var.get_idle_trigger(),
[],
config[CONF_ON_IDLE],
)

cg.add_define("USE_VOICE_ASSISTANT")


Expand Down
5 changes: 5 additions & 0 deletions esphome/components/voice_assistant/voice_assistant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ void VoiceAssistant::loop() {
switch (this->state_) {
case State::IDLE: {
if (this->continuous_ && this->desired_state_ == State::IDLE) {
this->idle_trigger_->trigger();

this->ring_buffer_->reset();
#ifdef USE_ESP_ADF
if (this->use_wake_word_) {
Expand Down Expand Up @@ -618,6 +620,9 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) {
{
this->set_state_(State::IDLE, State::IDLE);
}
} else if (this->state_ == State::AWAITING_RESPONSE) {
// No TTS start event ("nevermind")
this->set_state_(State::IDLE, State::IDLE);
}
this->defer([this]() { this->end_trigger_->trigger(); });
break;
Expand Down
2 changes: 2 additions & 0 deletions esphome/components/voice_assistant/voice_assistant.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class VoiceAssistant : public Component {
Trigger<std::string> *get_tts_end_trigger() const { return this->tts_end_trigger_; }
Trigger<std::string> *get_tts_start_trigger() const { return this->tts_start_trigger_; }
Trigger<std::string, std::string> *get_error_trigger() const { return this->error_trigger_; }
Trigger<> *get_idle_trigger() const { return this->idle_trigger_; }

Trigger<> *get_client_connected_trigger() const { return this->client_connected_trigger_; }
Trigger<> *get_client_disconnected_trigger() const { return this->client_disconnected_trigger_; }
Expand Down Expand Up @@ -148,6 +149,7 @@ class VoiceAssistant : public Component {
Trigger<std::string> *tts_end_trigger_ = new Trigger<std::string>();
Trigger<std::string> *tts_start_trigger_ = new Trigger<std::string>();
Trigger<std::string, std::string> *error_trigger_ = new Trigger<std::string, std::string>();
Trigger<> *idle_trigger_ = new Trigger<>();

Trigger<> *client_connected_trigger_ = new Trigger<>();
Trigger<> *client_disconnected_trigger_ = new Trigger<>();
Expand Down
2 changes: 1 addition & 1 deletion esphome/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Constants used by esphome."""

__version__ = "2024.2.0b2"
__version__ = "2024.2.0b3"

ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
VALID_SUBSTITUTIONS_CHARACTERS = (
Expand Down
Loading