1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-02 08:01:50 +00:00

Compare commits

..

20 Commits

Author SHA1 Message Date
Jesse Hills
52db40eb41 Merge pull request #4845 from esphome/bump-2023.5.0b5
2023.5.0b5
2023-05-17 12:04:22 +12:00
Jesse Hills
3c371a0c59 Bump version to 2023.5.0b5 2023-05-17 09:57:36 +12:00
Samuel Sieb
c941bc4109 handle Wiegand 8-bit keys (#4837)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
2023-05-17 09:57:35 +12:00
Samuel Sieb
cc76e5353c support sending keys to the collector (#4838)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
2023-05-17 09:57:35 +12:00
Jesse Hills
11bb46e393 Merge pull request #4835 from esphome/bump-2023.5.0b4
2023.5.0b4
2023-05-16 12:00:39 +12:00
Jesse Hills
71c4714a6e Bump version to 2023.5.0b4 2023-05-16 11:16:14 +12:00
github-actions[bot]
a4e63c5f86 Synchronise Device Classes from Home Assistant (#4825)
Co-authored-by: esphomebot <esphome@nabucasa.com>
2023-05-16 11:16:14 +12:00
Justin Gerace
c71e7d0132 Start UART assignment at UART0 if the logger is not enabled or is not configured for hardware logging on ESP32 (#4762) 2023-05-16 11:16:13 +12:00
dependabot[bot]
daa966975e Bump tzlocal from 4.2 to 5.0.1 (#4829)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-16 11:16:13 +12:00
Federico G. Schwindt
2e5757a3f0 Fix time period validation for the auto cleaning interval (#4811) 2023-05-16 11:16:13 +12:00
Jesse Hills
f66024b37c Bump esphome-dashboard to 20230516.0 (#4831) 2023-05-16 11:16:13 +12:00
Christian
c16ca7be13 Update PulseLightEffect with range brightness (#4820)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2023-05-16 11:16:13 +12:00
dependabot[bot]
e13e754bc4 Bump aioesphomeapi from 13.7.2 to 13.7.5 (#4830)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-16 11:16:13 +12:00
RoboMagus
6ccea59f71 Fix missing stop trait in send_cover_info (#4826) 2023-05-16 11:16:13 +12:00
Jesse Hills
71b28be3c8 Merge pull request #4822 from esphome/bump-2023.5.0b3
2023.5.0b3
2023-05-15 13:06:10 +12:00
Jesse Hills
e25d92e1f5 Bump version to 2023.5.0b3 2023-05-15 11:37:55 +12:00
Jesse Hills
65cda10884 Dontr try stop if not actually started (#4814) 2023-05-15 11:37:55 +12:00
Jesse Hills
625126df68 Fix i2s media player volume control (#4813) 2023-05-15 11:37:55 +12:00
richardhopton
e0ee8ca17c Tuya: Prevent loop when setting colors on case-sensitive dps (#4809)
Co-authored-by: Samuel Sieb <samuel-github@sieb.net>
2023-05-15 11:37:54 +12:00
Federico G. Schwindt
af95e781f5 Wording (#4805) 2023-05-15 11:37:54 +12:00
21 changed files with 121 additions and 39 deletions

View File

@@ -223,6 +223,7 @@ bool APIConnection::send_cover_info(cover::Cover *cover) {
msg.assumed_state = traits.get_is_assumed_state();
msg.supports_position = traits.get_supports_position();
msg.supports_tilt = traits.get_supports_tilt();
msg.supports_stop = traits.get_supports_stop();
msg.device_class = cover->get_device_class();
msg.disabled_by_default = cover->is_disabled_by_default();
msg.icon = cover->get_icon();

View File

@@ -22,14 +22,14 @@ void I2SAudioMediaPlayer::control(const media_player::MediaPlayerCall &call) {
this->start();
}
}
if (this->i2s_state_ != I2S_STATE_RUNNING) {
return;
}
if (call.get_volume().has_value()) {
this->volume = call.get_volume().value();
this->set_volume_(volume);
this->unmute_();
}
if (this->i2s_state_ != I2S_STATE_RUNNING) {
return;
}
if (call.get_command().has_value()) {
switch (call.get_command().value()) {
case media_player::MEDIA_PLAYER_COMMAND_PLAY:
@@ -97,7 +97,8 @@ void I2SAudioMediaPlayer::unmute_() {
this->muted_ = false;
}
void I2SAudioMediaPlayer::set_volume_(float volume, bool publish) {
this->audio_->setVolume(remap<uint8_t, float>(volume, 0.0f, 1.0f, 0, 21));
if (this->audio_ != nullptr)
this->audio_->setVolume(remap<uint8_t, float>(volume, 0.0f, 1.0f, 0, 21));
if (publish)
this->volume = volume;
}
@@ -157,13 +158,23 @@ void I2SAudioMediaPlayer::start_() {
#endif
this->i2s_state_ = I2S_STATE_RUNNING;
this->high_freq_.start();
this->audio_->setVolume(remap<uint8_t, float>(this->volume, 0.0f, 1.0f, 0, 21));
if (this->current_url_.has_value()) {
this->audio_->connecttohost(this->current_url_.value().c_str());
this->state = media_player::MEDIA_PLAYER_STATE_PLAYING;
this->publish_state();
}
}
void I2SAudioMediaPlayer::stop() { this->i2s_state_ = I2S_STATE_STOPPING; }
void I2SAudioMediaPlayer::stop() {
if (this->i2s_state_ == I2S_STATE_STOPPED) {
return;
}
if (this->i2s_state_ == I2S_STATE_STARTING) {
this->i2s_state_ = I2S_STATE_STOPPED;
return;
}
this->i2s_state_ = I2S_STATE_STOPPING;
}
void I2SAudioMediaPlayer::stop_() {
if (this->audio_->isRunning()) {
this->audio_->stopSong();

View File

@@ -89,6 +89,10 @@ void I2SAudioMicrophone::start_() {
void I2SAudioMicrophone::stop() {
if (this->state_ == microphone::STATE_STOPPED || this->is_failed())
return;
if (this->state_ == microphone::STATE_STARTING) {
this->state_ = microphone::STATE_STOPPED;
return;
}
this->state_ = microphone::STATE_STOPPING;
}

View File

@@ -136,6 +136,10 @@ void I2SAudioSpeaker::player_task(void *params) {
void I2SAudioSpeaker::stop() {
if (this->state_ == speaker::STATE_STOPPED)
return;
if (this->state_ == speaker::STATE_STARTING) {
this->state_ = speaker::STATE_STOPPED;
return;
}
this->state_ = speaker::STATE_STOPPING;
DataEvent data;
data.stop = true;

View File

@@ -33,7 +33,7 @@ CONFIG_SCHEMA = cv.All(
cv.COMPONENT_SCHEMA.extend(
{
cv.GenerateID(): cv.declare_id(KeyCollector),
cv.GenerateID(CONF_SOURCE_ID): cv.use_id(key_provider.KeyProvider),
cv.Optional(CONF_SOURCE_ID): cv.use_id(key_provider.KeyProvider),
cv.Optional(CONF_MIN_LENGTH): cv.int_,
cv.Optional(CONF_MAX_LENGTH): cv.int_,
cv.Optional(CONF_START_KEYS): cv.string,
@@ -55,8 +55,9 @@ CONFIG_SCHEMA = cv.All(
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
source = await cg.get_variable(config[CONF_SOURCE_ID])
cg.add(var.set_provider(source))
if CONF_SOURCE_ID in config:
source = await cg.get_variable(config[CONF_SOURCE_ID])
cg.add(var.set_provider(source))
if CONF_MIN_LENGTH in config:
cg.add(var.set_min_length(config[CONF_MIN_LENGTH]))
if CONF_MAX_LENGTH in config:

View File

@@ -52,6 +52,8 @@ void KeyCollector::clear(bool progress_update) {
this->progress_trigger_->trigger(this->result_, 0);
}
void KeyCollector::send_key(uint8_t key) { this->key_pressed_(key); }
void KeyCollector::key_pressed_(uint8_t key) {
this->last_key_time_ = millis();
if (!this->start_keys_.empty() && !this->start_key_) {

View File

@@ -27,6 +27,7 @@ class KeyCollector : public Component {
void set_timeout(int timeout) { this->timeout_ = timeout; };
void clear(bool progress_update = true);
void send_key(uint8_t key);
protected:
void key_pressed_(uint8_t key);

View File

@@ -25,7 +25,7 @@ class PulseLightEffect : public LightEffect {
return;
}
auto call = this->state_->turn_on();
float out = this->on_ ? 1.0 : 0.0;
float out = this->on_ ? this->max_brightness : this->min_brightness;
call.set_brightness_if_supported(out);
this->on_ = !this->on_;
call.set_transition_length_if_supported(this->transition_length_);
@@ -41,11 +41,18 @@ class PulseLightEffect : public LightEffect {
void set_update_interval(uint32_t update_interval) { this->update_interval_ = update_interval; }
void set_min_max_brightness(float min, float max) {
this->min_brightness = min;
this->max_brightness = max;
}
protected:
bool on_ = false;
uint32_t last_color_change_{0};
uint32_t transition_length_{};
uint32_t update_interval_{};
float min_brightness{0.0};
float max_brightness{1.0};
};
/// Random effect. Sets random colors every 10 seconds and slowly transitions between them.

View File

@@ -28,6 +28,8 @@ from esphome.const import (
CONF_NUM_LEDS,
CONF_RANDOM,
CONF_SEQUENCE,
CONF_MAX_BRIGHTNESS,
CONF_MIN_BRIGHTNESS,
)
from esphome.util import Registry
from .types import (
@@ -174,12 +176,19 @@ async def automation_effect_to_code(config, effect_id):
cv.Optional(
CONF_UPDATE_INTERVAL, default="1s"
): cv.positive_time_period_milliseconds,
cv.Optional(CONF_MIN_BRIGHTNESS, default="0%"): cv.percentage,
cv.Optional(CONF_MAX_BRIGHTNESS, default="100%"): cv.percentage,
},
)
async def pulse_effect_to_code(config, effect_id):
effect = cg.new_Pvariable(effect_id, config[CONF_NAME])
cg.add(effect.set_transition_length(config[CONF_TRANSITION_LENGTH]))
cg.add(effect.set_update_interval(config[CONF_UPDATE_INTERVAL]))
cg.add(
effect.set_min_max_brightness(
config[CONF_MIN_BRIGHTNESS], config[CONF_MAX_BRIGHTNESS]
)
)
return effect

View File

@@ -57,6 +57,7 @@ from esphome.const import (
DEVICE_CLASS_SULPHUR_DIOXIDE,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
DEVICE_CLASS_VOLTAGE,
DEVICE_CLASS_VOLUME,
DEVICE_CLASS_VOLUME_STORAGE,
@@ -109,6 +110,7 @@ DEVICE_CLASSES = [
DEVICE_CLASS_SULPHUR_DIOXIDE,
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
DEVICE_CLASS_VOLTAGE,
DEVICE_CLASS_VOLUME,
DEVICE_CLASS_VOLUME_STORAGE,

View File

@@ -252,7 +252,7 @@ void SEN5XComponent::dump_config() {
ESP_LOGCONFIG(TAG, " Firmware version: %d", this->firmware_version_);
ESP_LOGCONFIG(TAG, " Serial number %02d.%02d.%02d", serial_number_[0], serial_number_[1], serial_number_[2]);
if (this->auto_cleaning_interval_.has_value()) {
ESP_LOGCONFIG(TAG, " Auto auto cleaning interval %d seconds", auto_cleaning_interval_.value());
ESP_LOGCONFIG(TAG, " Auto cleaning interval %d seconds", auto_cleaning_interval_.value());
}
if (this->acceleration_mode_.has_value()) {
switch (this->acceleration_mode_.value()) {

View File

@@ -119,7 +119,7 @@ CONFIG_SCHEMA = (
device_class=DEVICE_CLASS_PM10,
state_class=STATE_CLASS_MEASUREMENT,
),
cv.Optional(CONF_AUTO_CLEANING_INTERVAL): cv.time_period_in_seconds_,
cv.Optional(CONF_AUTO_CLEANING_INTERVAL): cv.update_interval,
cv.Optional(CONF_VOC): sensor.sensor_schema(
icon=ICON_RADIATOR,
accuracy_decimals=0,

View File

@@ -73,6 +73,7 @@ from esphome.const import (
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_TIMESTAMP,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
DEVICE_CLASS_VOLTAGE,
DEVICE_CLASS_VOLUME,
DEVICE_CLASS_VOLUME_STORAGE,
@@ -129,6 +130,7 @@ DEVICE_CLASSES = [
DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_TIMESTAMP,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
DEVICE_CLASS_VOLTAGE,
DEVICE_CLASS_VOLUME,
DEVICE_CLASS_VOLUME_STORAGE,

View File

@@ -23,6 +23,8 @@ from esphome.const import (
DEVICE_CLASS_POWER,
DEVICE_CLASS_VOLTAGE,
DEVICE_CLASS_CURRENT,
CONF_MIN_BRIGHTNESS,
CONF_MAX_BRIGHTNESS,
)
from esphome.core import HexInt, CORE
@@ -41,8 +43,7 @@ CONF_UPDATE = "update"
CONF_LEADING_EDGE = "leading_edge"
CONF_WARMUP_BRIGHTNESS = "warmup_brightness"
# CONF_WARMUP_TIME = "warmup_time"
CONF_MIN_BRIGHTNESS = "min_brightness"
CONF_MAX_BRIGHTNESS = "max_brightness"
CONF_NRST_PIN = "nrst_pin"
CONF_BOOT0_PIN = "boot0_pin"

View File

@@ -57,37 +57,43 @@ void TuyaLight::setup() {
return;
}
float red, green, blue;
switch (*this->color_type_) {
case TuyaColorType::RGBHSV:
case TuyaColorType::RGB: {
auto red = parse_hex<uint8_t>(datapoint.value_string.substr(0, 2));
auto green = parse_hex<uint8_t>(datapoint.value_string.substr(2, 2));
auto blue = parse_hex<uint8_t>(datapoint.value_string.substr(4, 2));
if (red.has_value() && green.has_value() && blue.has_value()) {
auto rgb_call = this->state_->make_call();
rgb_call.set_rgb(float(*red) / 255, float(*green) / 255, float(*blue) / 255);
rgb_call.perform();
}
auto rgb = parse_hex<uint32_t>(datapoint.value_string.substr(0, 6));
if (!rgb.has_value())
return;
red = (*rgb >> 16) / 255.0f;
green = ((*rgb >> 8) & 0xff) / 255.0f;
blue = (*rgb & 0xff) / 255.0f;
break;
}
case TuyaColorType::HSV: {
auto hue = parse_hex<uint16_t>(datapoint.value_string.substr(0, 4));
auto saturation = parse_hex<uint16_t>(datapoint.value_string.substr(4, 4));
auto value = parse_hex<uint16_t>(datapoint.value_string.substr(8, 4));
if (hue.has_value() && saturation.has_value() && value.has_value()) {
float red, green, blue;
hsv_to_rgb(*hue, float(*saturation) / 1000, float(*value) / 1000, red, green, blue);
auto rgb_call = this->state_->make_call();
rgb_call.set_rgb(red, green, blue);
rgb_call.perform();
}
if (!hue.has_value() || !saturation.has_value() || !value.has_value())
return;
hsv_to_rgb(*hue, float(*saturation) / 1000, float(*value) / 1000, red, green, blue);
break;
}
}
float current_red, current_green, current_blue;
this->state_->current_values_as_rgb(&current_red, &current_green, &current_blue);
if (red == current_red && green == current_green && blue == current_blue)
return;
auto rgb_call = this->state_->make_call();
rgb_call.set_rgb(red, green, blue);
rgb_call.perform();
});
}
if (min_value_datapoint_id_.has_value()) {
parent_->set_integer_datapoint_value(*this->min_value_datapoint_id_, this->min_value_);
this->parent_->set_integer_datapoint_value(*this->min_value_datapoint_id_, this->min_value_);
}
}
@@ -156,7 +162,7 @@ void TuyaLight::write_state(light::LightState *state) {
}
if (!state->current_values.is_on() && this->switch_id_.has_value()) {
parent_->set_boolean_datapoint_value(*this->switch_id_, false);
this->parent_->set_boolean_datapoint_value(*this->switch_id_, false);
return;
}
@@ -166,14 +172,14 @@ void TuyaLight::write_state(light::LightState *state) {
if (this->color_temperature_invert_) {
color_temp_int = this->color_temperature_max_value_ - color_temp_int;
}
parent_->set_integer_datapoint_value(*this->color_temperature_id_, color_temp_int);
this->parent_->set_integer_datapoint_value(*this->color_temperature_id_, color_temp_int);
}
if (this->dimmer_id_.has_value()) {
auto brightness_int = static_cast<uint32_t>(brightness * this->max_value_);
brightness_int = std::max(brightness_int, this->min_value_);
parent_->set_integer_datapoint_value(*this->dimmer_id_, brightness_int);
this->parent_->set_integer_datapoint_value(*this->dimmer_id_, brightness_int);
}
}
@@ -210,7 +216,7 @@ void TuyaLight::write_state(light::LightState *state) {
}
if (this->switch_id_.has_value()) {
parent_->set_boolean_datapoint_value(*this->switch_id_, true);
this->parent_->set_boolean_datapoint_value(*this->switch_id_, true);
}
}

View File

@@ -86,10 +86,26 @@ void ESP32ArduinoUARTComponent::setup() {
is_default_tx = tx_pin_ == nullptr || tx_pin_->get_pin() == 1;
is_default_rx = rx_pin_ == nullptr || rx_pin_->get_pin() == 3;
#endif
if (is_default_tx && is_default_rx) {
static uint8_t next_uart_num = 0;
if (is_default_tx && is_default_rx && next_uart_num == 0) {
this->hw_serial_ = &Serial;
next_uart_num++;
} else {
static uint8_t next_uart_num = 1;
#ifdef USE_LOGGER
// The logger doesn't use this UART component, instead it targets the UARTs
// directly (i.e. Serial/Serial0, Serial1, and Serial2). If the logger is
// enabled, skip the UART that it is configured to use.
if (logger::global_logger->get_baud_rate() > 0 && logger::global_logger->get_uart() == next_uart_num) {
next_uart_num++;
}
#endif // USE_LOGGER
if (next_uart_num >= UART_NUM_MAX) {
ESP_LOGW(TAG, "Maximum number of UART components created already.");
this->mark_failed();
return;
}
this->number_ = next_uart_num;
this->hw_serial_ = new HardwareSerial(next_uart_num++); // NOLINT(cppcoreguidelines-owning-memory)
}

View File

@@ -2,6 +2,7 @@
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
#include <driver/uart.h>
#include <HardwareSerial.h>
#include <vector>
#include "esphome/core/component.h"

View File

@@ -102,6 +102,16 @@ void Wiegand::loop() {
uint8_t key = KEYS[value];
this->send_key_(key);
}
} else if (count == 8) {
if ((value ^ 0xf0) >> 4 == (value & 0xf)) {
value &= 0xf;
for (auto *trigger : this->key_triggers_)
trigger->trigger(value);
if (value < 12) {
uint8_t key = KEYS[value];
this->send_key_(key);
}
}
} else {
ESP_LOGD(TAG, "received unknown %d-bit value: %llx", count, value);
}

View File

@@ -1,6 +1,6 @@
"""Constants used by esphome."""
__version__ = "2023.5.0b2"
__version__ = "2023.5.0b5"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
@@ -377,6 +377,7 @@ CONF_MAKE_ID = "make_id"
CONF_MANUAL_IP = "manual_ip"
CONF_MANUFACTURER_ID = "manufacturer_id"
CONF_MASK_DISTURBER = "mask_disturber"
CONF_MAX_BRIGHTNESS = "max_brightness"
CONF_MAX_COOLING_RUN_TIME = "max_cooling_run_time"
CONF_MAX_CURRENT = "max_current"
CONF_MAX_DURATION = "max_duration"
@@ -396,6 +397,7 @@ CONF_MEDIUM = "medium"
CONF_MEMORY_BLOCKS = "memory_blocks"
CONF_METHOD = "method"
CONF_MICROPHONE = "microphone"
CONF_MIN_BRIGHTNESS = "min_brightness"
CONF_MIN_COOLING_OFF_TIME = "min_cooling_off_time"
CONF_MIN_COOLING_RUN_TIME = "min_cooling_run_time"
CONF_MIN_FAN_MODE_SWITCHING_TIME = "min_fan_mode_switching_time"
@@ -1002,6 +1004,7 @@ DEVICE_CLASS_TIMESTAMP = "timestamp"
DEVICE_CLASS_UPDATE = "update"
DEVICE_CLASS_VIBRATION = "vibration"
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS = "volatile_organic_compounds"
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS = "volatile_organic_compounds_parts"
DEVICE_CLASS_VOLTAGE = "voltage"
DEVICE_CLASS_VOLUME = "volume"
DEVICE_CLASS_VOLUME_STORAGE = "volume_storage"

View File

@@ -3,14 +3,14 @@ PyYAML==6.0
paho-mqtt==1.6.1
colorama==0.4.6
tornado==6.3.1
tzlocal==4.2 # from time
tzlocal==5.0.1 # from time
tzdata>=2021.1 # from time
pyserial==3.5
platformio==6.1.6 # When updating platformio, also update Dockerfile
esptool==4.5.1
click==8.1.3
esphome-dashboard==20230214.0
aioesphomeapi==13.7.2
esphome-dashboard==20230516.0
aioesphomeapi==13.7.5
zeroconf==0.60.0
# esp-idf requires this, but doesn't bundle it by default

View File

@@ -489,6 +489,7 @@ sensor:
offset: 0
normalized_offset_slope: 0
time_constant: 0
auto_cleaning_interval: 604800s
acceleration_mode: low
store_baseline: true
address: 0x69