1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-12 12:55:46 +00:00

Compare commits

...

32 Commits

Author SHA1 Message Date
Jesse Hills
4c87658503 Merge pull request #7929 from esphome/bump-2024.11.3
2024.11.3
2024-12-06 17:22:32 +13:00
Jesse Hills
c80e035bd5 Bump version to 2024.11.3 2024-12-06 15:55:51 +13:00
Clyde Stubbs
c8ec0bb7ea [esp32] Fix crash with empty platformio_options: value (#7920) 2024-12-06 15:55:51 +13:00
Clyde Stubbs
86ae1c5931 [lvgl] Fix msgbox content (#7912) 2024-12-06 15:55:51 +13:00
Clyde Stubbs
d0958f7cf2 [lvgl] Bugfixes (#7896) 2024-12-06 15:55:51 +13:00
Jesse Hills
982ce1db72 Cast port to int for ota pushing (#7888) 2024-12-06 15:55:51 +13:00
Krzysztof Zdulski
f042c6e643 Fix recalc_timestamp_utc (#7894) 2024-12-06 15:55:51 +13:00
Jesse Hills
5fcd26bfe9 [st7920] Remove unnecessary warning when drawing outside display bounds (#7868) 2024-12-06 15:55:51 +13:00
FreeBear-nc
5717d557f5 Add IRAM_ATTR to all functions used during interrupts on esp8266 chips. (#7840) 2024-12-06 15:55:51 +13:00
guillempages
3bac45e737 [online_image]Don't access decoder if not initialized (#7882) 2024-12-06 15:55:50 +13:00
Samuel Sieb
e623989878 fix local time timestamp calculation (#7807)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
2024-12-06 15:55:50 +13:00
Oleg Tarasov
39cbc6b183 [opentherm] Fix out of memory errors on ESP8266 (#7835) 2024-12-06 15:55:50 +13:00
Jesse Hills
e6da55b925 Merge pull request #7869 from esphome/bump-2024.11.2
2024.11.2
2024-11-28 07:21:44 +13:00
Jesse Hills
c894645747 Bump version to 2024.11.2 2024-11-27 14:06:21 +13:00
Samuel Sieb
2539cba610 [honeywell] use warning instead of failing (#7862)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
2024-11-27 14:06:21 +13:00
Samuel Sieb
5ddbe5cdba [wifi] fix 32 char SSIDs (#7834)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
2024-11-27 14:06:20 +13:00
Samuel Sieb
4c7552eca4 keypad binary sensors should be initially off (#7808)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
2024-11-27 14:06:20 +13:00
Ramil Valitov
72bf0086e4 [fix] Status sensor does not check if required network component is missing (#7734)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2024-11-27 14:06:20 +13:00
TFGF
1b91e0027b [Modbus Controller] Fix issue #6477. Online automation triggering Offline (#7801) 2024-11-27 14:06:20 +13:00
Samuel Sieb
e9851e7eb2 fix modbus crashing when bad data returned (#7810)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
2024-11-27 14:06:20 +13:00
Clyde Stubbs
80fedbc1a5 [qspi_dbi] Fix init sequences (Bugfix) (#7805) 2024-11-27 14:06:20 +13:00
Clyde Stubbs
a4a71797d9 [docker] Leave run-time required libraries installed. (#7804) 2024-11-27 14:06:20 +13:00
Clyde Stubbs
4a97064b2c [lvgl] Bugfixes (#7803) 2024-11-27 14:06:20 +13:00
Jesse Hills
ee3cfb2b76 Merge pull request #7798 from esphome/bump-2024.11.1
2024.11.1
2024-11-22 11:23:56 +13:00
Jesse Hills
2cc2a2153b Bump version to 2024.11.1 2024-11-22 10:08:00 +13:00
J. Nick Koston
e51f3d9498 Ensure storage I/O for ignored devices runs in the executor (#7792) 2024-11-22 10:08:00 +13:00
Alain Turbide
1c1f3f7c55 Fix for OTA mode not activating in safe_mode when OTA section has an on_xxxx action (#7796)
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
2024-11-22 10:08:00 +13:00
Spencer Owen
ea424b0699 Check for min_version earlier in validation (#7797) 2024-11-22 10:08:00 +13:00
Manuel Kasper
489d0d20d2 [qspi_dbi] Fix garbled graphics on RM690B0 (#7795) 2024-11-22 10:08:00 +13:00
Jesse Hills
f04e3de7b8 [speaker] Add missing auto-load for `audio` (#7794) 2024-11-22 10:08:00 +13:00
Jesse Hills
a0693060e4 [rtttl] Clamp gain between 0 and 1 (#7793) 2024-11-22 10:08:00 +13:00
Clyde Stubbs
888b237964 [http_request] Fix within context with parameters. (Bugfix) (#7790) 2024-11-22 10:08:00 +13:00
43 changed files with 266 additions and 143 deletions

View File

@@ -99,15 +99,17 @@ BUILD_DEPS="
libfreetype-dev=2.12.1+dfsg-5+deb12u3
libssl-dev=3.0.15-1~deb12u1
libffi-dev=3.4.4-1
libopenjp2-7=2.5.0-2
libtiff6=4.5.0-6+deb12u1
cargo=0.66.0+ds1-1
pkg-config=1.8.1-1
"
LIB_DEPS="
libtiff6=4.5.0-6+deb12u1
libopenjp2-7=2.5.0-2
"
if [ "$TARGETARCH$TARGETVARIANT" = "arm64" ] || [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]
then
apt-get update
apt-get install -y --no-install-recommends $BUILD_DEPS
apt-get install -y --no-install-recommends $BUILD_DEPS $LIB_DEPS
fi
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse CARGO_HOME=/root/.cargo

View File

@@ -363,7 +363,7 @@ def upload_program(config, args, host):
from esphome import espota2
remote_port = ota_conf[CONF_PORT]
remote_port = int(ota_conf[CONF_PORT])
password = ota_conf.get(CONF_PASSWORD, "")
if (

View File

@@ -58,7 +58,7 @@ class BinarySensor : public EntityBase, public EntityBase_DeviceClass {
void publish_initial_state(bool state);
/// The current reported state of the binary sensor.
bool state;
bool state{false};
void add_filter(Filter *filter);
void add_filters(const std::vector<Filter *> &filters);

View File

@@ -60,9 +60,7 @@ ESPTime DateTimeEntity::state_as_esptime() const {
obj.hour = this->hour_;
obj.minute = this->minute_;
obj.second = this->second_;
obj.day_of_week = 1; // Required to be valid for recalc_timestamp_local but not used.
obj.day_of_year = 1; // Required to be valid for recalc_timestamp_local but not used.
obj.recalc_timestamp_local(false);
obj.recalc_timestamp_local();
return obj;
}

View File

@@ -355,24 +355,20 @@ def _detect_variant(value):
def final_validate(config):
if CONF_PLATFORMIO_OPTIONS not in fv.full_config.get()[CONF_ESPHOME]:
if not (
pio_options := fv.full_config.get()[CONF_ESPHOME].get(CONF_PLATFORMIO_OPTIONS)
):
# Not specified or empty
return config
pio_flash_size_key = "board_upload.flash_size"
pio_partitions_key = "board_build.partitions"
if (
CONF_PARTITIONS in config
and pio_partitions_key
in fv.full_config.get()[CONF_ESPHOME][CONF_PLATFORMIO_OPTIONS]
):
if CONF_PARTITIONS in config and pio_partitions_key in pio_options:
raise cv.Invalid(
f"Do not specify '{pio_partitions_key}' in '{CONF_PLATFORMIO_OPTIONS}' with '{CONF_PARTITIONS}' in esp32"
)
if (
pio_flash_size_key
in fv.full_config.get()[CONF_ESPHOME][CONF_PLATFORMIO_OPTIONS]
):
if pio_flash_size_key in pio_options:
raise cv.Invalid(
f"Please specify {CONF_FLASH_SIZE} within esp32 configuration only"
)

View File

@@ -1,10 +1,9 @@
import logging
import esphome.codegen as cg
import esphome.config_validation as cv
import esphome.final_validate as fv
from esphome.components.ota import BASE_OTA_SCHEMA, ota_to_code, OTAComponent
from esphome.components.ota import BASE_OTA_SCHEMA, OTAComponent, ota_to_code
from esphome.config_helpers import merge_config
import esphome.config_validation as cv
from esphome.const import (
CONF_ESPHOME,
CONF_ID,
@@ -18,6 +17,7 @@ from esphome.const import (
CONF_VERSION,
)
from esphome.core import coroutine_with_priority
import esphome.final_validate as fv
_LOGGER = logging.getLogger(__name__)
@@ -124,7 +124,6 @@ FINAL_VALIDATE_SCHEMA = ota_esphome_final_validate
@coroutine_with_priority(52.0)
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await ota_to_code(var, config)
cg.add(var.set_port(config[CONF_PORT]))
if CONF_PASSWORD in config:
cg.add(var.set_auth_password(config[CONF_PASSWORD]))
@@ -132,3 +131,4 @@ async def to_code(config):
cg.add_define("USE_OTA_VERSION", config[CONF_VERSION])
await cg.register_component(var, config)
await ota_to_code(var, config)

View File

@@ -15,7 +15,7 @@ static const char *const TAG = "honeywellabp2";
void HONEYWELLABP2Sensor::read_sensor_data() {
if (this->read(raw_data_, 7) != i2c::ERROR_OK) {
ESP_LOGE(TAG, "Communication with ABP2 failed!");
this->mark_failed();
this->status_set_warning("couldn't read sensor data");
return;
}
float press_counts = encode_uint24(raw_data_[1], raw_data_[2], raw_data_[3]); // calculate digital pressure counts
@@ -25,12 +25,13 @@ void HONEYWELLABP2Sensor::read_sensor_data() {
(this->max_pressure_ - this->min_pressure_)) +
this->min_pressure_;
this->last_temperature_ = (temp_counts * 200 / 16777215) - 50;
this->status_clear_warning();
}
void HONEYWELLABP2Sensor::start_measurement() {
if (this->write(i2c_cmd_, 3) != i2c::ERROR_OK) {
ESP_LOGE(TAG, "Communication with ABP2 failed!");
this->mark_failed();
this->status_set_warning("couldn't start measurement");
return;
}
this->measurement_running_ = true;
@@ -39,7 +40,7 @@ void HONEYWELLABP2Sensor::start_measurement() {
bool HONEYWELLABP2Sensor::is_measurement_ready() {
if (this->read(raw_data_, 1) != i2c::ERROR_OK) {
ESP_LOGE(TAG, "Communication with ABP2 failed!");
this->mark_failed();
this->status_set_warning("couldn't check measurement");
return false;
}
if ((raw_data_[0] & (0x1 << STATUS_BIT_BUSY)) > 0) {
@@ -52,7 +53,7 @@ bool HONEYWELLABP2Sensor::is_measurement_ready() {
void HONEYWELLABP2Sensor::measurement_timeout() {
ESP_LOGE(TAG, "Timeout!");
this->measurement_running_ = false;
this->mark_failed();
this->status_set_warning("measurement timed out");
}
float HONEYWELLABP2Sensor::get_pressure() { return this->last_pressure_; }
@@ -79,7 +80,7 @@ void HONEYWELLABP2Sensor::update() {
ESP_LOGV(TAG, "Update Honeywell ABP2 Sensor");
this->start_measurement();
this->set_timeout("meas_timeout", 50, [this] { this->measurement_timeout(); });
this->set_timeout("meas_timeout", 100, [this] { this->measurement_timeout(); });
}
void HONEYWELLABP2Sensor::dump_config() {

View File

@@ -189,7 +189,7 @@ template<typename... Ts> class HttpRequestSendAction : public Action<Ts...> {
if (container == nullptr) {
for (auto *trigger : this->error_triggers_)
trigger->trigger(x...);
trigger->trigger();
return;
}

View File

@@ -322,8 +322,8 @@ async def to_code(configs):
await encoders_to_code(lv_component, config, default_group)
await keypads_to_code(lv_component, config, default_group)
await theme_to_code(config)
await styles_to_code(config)
await gradients_to_code(config)
await styles_to_code(config)
await set_obj_properties(lv_scr_act, config)
await add_widgets(lv_scr_act, config)
await add_pages(lv_component, config)

View File

@@ -38,7 +38,7 @@ def literal(arg):
def call_lambda(lamb: LambdaExpression):
expr = lamb.content.strip()
if expr.startswith("return") and expr.endswith(";"):
return expr[7:][:-1]
return expr[6:][:-1].strip()
return f"{lamb}()"

View File

@@ -30,7 +30,7 @@ from .defines import (
call_lambda,
literal,
)
from .helpers import esphome_fonts_used, lv_fonts_used, requires_component
from .helpers import add_lv_use, esphome_fonts_used, lv_fonts_used, requires_component
from .types import lv_font_t, lv_gradient_t, lv_img_t
opacity_consts = LvConstant("LV_OPA_", "TRANSP", "COVER")
@@ -326,6 +326,7 @@ def image_validator(value):
value = requires_component("image")(value)
value = cv.use_id(Image_)(value)
lv_images_used.add(value)
add_lv_use("img", "label")
return value

View File

@@ -56,6 +56,9 @@ static const display::ColorBitness LV_BITNESS = display::ColorBitness::COLOR_BIT
inline void lv_img_set_src(lv_obj_t *obj, esphome::image::Image *image) {
lv_img_set_src(obj, image->get_lv_img_dsc());
}
inline void lv_disp_set_bg_image(lv_disp_t *disp, esphome::image::Image *image) {
lv_disp_set_bg_image(disp, image->get_lv_img_dsc());
}
#endif // USE_LVGL_IMAGE
// Parent class for things that wrap an LVGL object

View File

@@ -341,6 +341,7 @@ FLEX_OBJ_SCHEMA = {
cv.Optional(df.CONF_FLEX_GROW): cv.int_,
}
DISP_BG_SCHEMA = cv.Schema(
{
cv.Optional(df.CONF_DISP_BG_IMAGE): lv_image,

View File

@@ -35,11 +35,20 @@ LINE_SCHEMA = {
cv.GenerateID(CONF_POINT_LIST_ID): cv.declare_id(lv_point_t),
}
LINE_MODIFY_SCHEMA = {
cv.Optional(CONF_POINTS): cv_point_list,
cv.GenerateID(CONF_POINT_LIST_ID): cv.declare_id(lv_point_t),
}
class LineType(WidgetType):
def __init__(self):
super().__init__(
CONF_LINE, LvType("lv_line_t"), (CONF_MAIN,), LINE_SCHEMA, modify_schema={}
CONF_LINE,
LvType("lv_line_t"),
(CONF_MAIN,),
LINE_SCHEMA,
modify_schema=LINE_MODIFY_SCHEMA,
)
async def to_code(self, w: Widget, config):

View File

@@ -29,7 +29,7 @@ from ..lvcode import (
)
from ..schemas import STYLE_SCHEMA, STYLED_TEXT_SCHEMA, container_schema, part_schema
from ..types import LV_EVENT, char_ptr, lv_obj_t
from . import Widget, set_obj_properties
from . import Widget, add_widgets, set_obj_properties
from .button import button_spec
from .buttonmatrix import (
BUTTONMATRIX_BUTTON_SCHEMA,
@@ -119,6 +119,7 @@ async def msgbox_to_code(top_layer, conf):
button_style = {CONF_ITEMS: button_style}
await set_obj_properties(buttonmatrix_widget, button_style)
await set_obj_properties(msgbox_widget, conf)
await add_widgets(msgbox_widget, conf)
async with LambdaContext(EVENT_ARG, where=messagebox_id) as close_action:
outer_widget.add_flag("LV_OBJ_FLAG_HIDDEN")
if close_button:

View File

@@ -6,7 +6,7 @@
namespace esphome {
namespace matrix_keypad {
class MatrixKeypadBinarySensor : public MatrixKeypadListener, public binary_sensor::BinarySensor {
class MatrixKeypadBinarySensor : public MatrixKeypadListener, public binary_sensor::BinarySensorInitiallyOff {
public:
MatrixKeypadBinarySensor(uint8_t key) : has_key_(true), key_(key){};
MatrixKeypadBinarySensor(const char *key) : has_key_(true), key_((uint8_t) key[0]){};

View File

@@ -38,8 +38,9 @@ void Modbus::loop() {
// stop blocking new send commands after sent_wait_time_ ms after response received
if (now - this->last_send_ > send_wait_time_) {
if (waiting_for_response > 0)
if (waiting_for_response > 0) {
ESP_LOGV(TAG, "Stop waiting for response from %d", waiting_for_response);
}
waiting_for_response = 0;
}
}

View File

@@ -163,7 +163,7 @@ CONFIG_SCHEMA = cv.All(
),
cv.Optional(CONF_ON_OFFLINE): automation.validate_automation(
{
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(ModbusOnlineTrigger),
cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(ModbusOfflineTrigger),
}
),
}

View File

@@ -622,51 +622,87 @@ int64_t payload_to_number(const std::vector<uint8_t> &data, SensorValueType sens
uint32_t bitmask) {
int64_t value = 0; // int64_t because it can hold signed and unsigned 32 bits
size_t size = data.size() - offset;
bool error = false;
switch (sensor_value_type) {
case SensorValueType::U_WORD:
value = mask_and_shift_by_rightbit(get_data<uint16_t>(data, offset), bitmask); // default is 0xFFFF ;
if (size >= 2) {
value = mask_and_shift_by_rightbit(get_data<uint16_t>(data, offset), bitmask); // default is 0xFFFF ;
} else {
error = true;
}
break;
case SensorValueType::U_DWORD:
case SensorValueType::FP32:
value = get_data<uint32_t>(data, offset);
value = mask_and_shift_by_rightbit((uint32_t) value, bitmask);
if (size >= 4) {
value = get_data<uint32_t>(data, offset);
value = mask_and_shift_by_rightbit((uint32_t) value, bitmask);
} else {
error = true;
}
break;
case SensorValueType::U_DWORD_R:
case SensorValueType::FP32_R:
value = get_data<uint32_t>(data, offset);
value = static_cast<uint32_t>(value & 0xFFFF) << 16 | (value & 0xFFFF0000) >> 16;
value = mask_and_shift_by_rightbit((uint32_t) value, bitmask);
if (size >= 4) {
value = get_data<uint32_t>(data, offset);
value = static_cast<uint32_t>(value & 0xFFFF) << 16 | (value & 0xFFFF0000) >> 16;
value = mask_and_shift_by_rightbit((uint32_t) value, bitmask);
} else {
error = true;
}
break;
case SensorValueType::S_WORD:
value = mask_and_shift_by_rightbit(get_data<int16_t>(data, offset),
bitmask); // default is 0xFFFF ;
if (size >= 2) {
value = mask_and_shift_by_rightbit(get_data<int16_t>(data, offset),
bitmask); // default is 0xFFFF ;
} else {
error = true;
}
break;
case SensorValueType::S_DWORD:
value = mask_and_shift_by_rightbit(get_data<int32_t>(data, offset), bitmask);
if (size >= 4) {
value = mask_and_shift_by_rightbit(get_data<int32_t>(data, offset), bitmask);
} else {
error = true;
}
break;
case SensorValueType::S_DWORD_R: {
value = get_data<uint32_t>(data, offset);
// Currently the high word is at the low position
// the sign bit is therefore at low before the switch
uint32_t sign_bit = (value & 0x8000) << 16;
value = mask_and_shift_by_rightbit(
static_cast<int32_t>(((value & 0x7FFF) << 16 | (value & 0xFFFF0000) >> 16) | sign_bit), bitmask);
if (size >= 4) {
value = get_data<uint32_t>(data, offset);
// Currently the high word is at the low position
// the sign bit is therefore at low before the switch
uint32_t sign_bit = (value & 0x8000) << 16;
value = mask_and_shift_by_rightbit(
static_cast<int32_t>(((value & 0x7FFF) << 16 | (value & 0xFFFF0000) >> 16) | sign_bit), bitmask);
} else {
error = true;
}
} break;
case SensorValueType::U_QWORD:
case SensorValueType::S_QWORD:
// Ignore bitmask for QWORD
value = get_data<uint64_t>(data, offset);
if (size >= 8) {
value = get_data<uint64_t>(data, offset);
} else {
error = true;
}
break;
case SensorValueType::U_QWORD_R:
case SensorValueType::S_QWORD_R: {
// Ignore bitmask for QWORD
uint64_t tmp = get_data<uint64_t>(data, offset);
value = (tmp << 48) | (tmp >> 48) | ((tmp & 0xFFFF0000) << 16) | ((tmp >> 16) & 0xFFFF0000);
if (size >= 8) {
uint64_t tmp = get_data<uint64_t>(data, offset);
value = (tmp << 48) | (tmp >> 48) | ((tmp & 0xFFFF0000) << 16) | ((tmp >> 16) & 0xFFFF0000);
} else {
error = true;
}
} break;
case SensorValueType::RAW:
default:
break;
}
if (error)
ESP_LOGE(TAG, "not enough data for value");
return value;
}

View File

@@ -49,6 +49,10 @@ void PngDecoder::prepare(uint32_t download_size) {
}
int HOT PngDecoder::decode(uint8_t *buffer, size_t size) {
if (!this->pngle_) {
ESP_LOGE(TAG, "PNG decoder engine not initialized!");
return -1;
}
if (size < 256 && size < this->download_size_ - this->decoded_bytes_) {
ESP_LOGD(TAG, "Waiting for data");
return 0;

View File

@@ -138,7 +138,7 @@ OpenthermHub::OpenthermHub() : Component(), in_pin_{}, out_pin_{} {}
void OpenthermHub::process_response(OpenthermData &data) {
ESP_LOGD(TAG, "Received OpenTherm response with id %d (%s)", data.id,
this->opentherm_->message_id_to_str((MessageId) data.id));
ESP_LOGD(TAG, "%s", this->opentherm_->debug_data(data).c_str());
this->opentherm_->debug_data(data);
switch (data.id) {
OPENTHERM_SENSOR_MESSAGE_HANDLERS(OPENTHERM_MESSAGE_RESPONSE_MESSAGE, OPENTHERM_MESSAGE_RESPONSE_ENTITY, ,
@@ -315,7 +315,7 @@ void OpenthermHub::start_conversation_() {
ESP_LOGD(TAG, "Sending request with id %d (%s)", request.id,
this->opentherm_->message_id_to_str((MessageId) request.id));
ESP_LOGD(TAG, "%s", this->opentherm_->debug_data(request).c_str());
this->opentherm_->debug_data(request);
// Send the request
this->last_conversation_start_ = millis();
this->opentherm_->send(request);
@@ -340,19 +340,18 @@ void OpenthermHub::stop_opentherm_() {
this->opentherm_->stop();
this->last_conversation_end_ = millis();
}
void OpenthermHub::handle_protocol_write_error_() {
ESP_LOGW(TAG, "Error while sending request: %s",
this->opentherm_->operation_mode_to_str(this->opentherm_->get_mode()));
ESP_LOGW(TAG, "%s", this->opentherm_->debug_data(this->last_request_).c_str());
this->opentherm_->debug_data(this->last_request_);
}
void OpenthermHub::handle_protocol_read_error_() {
OpenThermError error;
this->opentherm_->get_protocol_error(error);
ESP_LOGW(TAG, "Protocol error occured while receiving response: %s", this->opentherm_->debug_error(error).c_str());
ESP_LOGW(TAG, "Protocol error occured while receiving response: %s",
this->opentherm_->protocol_error_to_to_str(error.error_type));
this->opentherm_->debug_error(error);
}
void OpenthermHub::handle_timeout_error_() {
ESP_LOGW(TAG, "Receive response timed out at a protocol level");
this->stop_opentherm_();

View File

@@ -15,15 +15,11 @@
#include "Arduino.h"
#endif
#include <string>
#include <sstream>
#include <bitset>
namespace esphome {
namespace opentherm {
using std::string;
using std::bitset;
using std::stringstream;
using std::to_string;
static const char *const TAG = "opentherm";
@@ -224,7 +220,7 @@ void IRAM_ATTR OpenTherm::bit_read_(uint8_t value) {
this->bit_pos_++;
}
ProtocolErrorType OpenTherm::verify_stop_bit_(uint8_t value) {
ProtocolErrorType IRAM_ATTR OpenTherm::verify_stop_bit_(uint8_t value) {
if (value) { // stop bit detected
return check_parity_(this->data_) ? ProtocolErrorType::NO_ERROR : ProtocolErrorType::PARITY_ERROR;
} else { // no stop bit detected, error
@@ -369,7 +365,7 @@ void IRAM_ATTR OpenTherm::stop_timer_() {
#ifdef ESP8266
// 5 kHz timer_
void OpenTherm::start_read_timer_() {
void IRAM_ATTR OpenTherm::start_read_timer_() {
InterruptLock const lock;
timer1_attachInterrupt(OpenTherm::esp8266_timer_isr);
timer1_enable(TIM_DIV16, TIM_EDGE, TIM_LOOP); // 5MHz (5 ticks/us - 1677721.4 us max)
@@ -377,14 +373,14 @@ void OpenTherm::start_read_timer_() {
}
// 2 kHz timer_
void OpenTherm::start_write_timer_() {
void IRAM_ATTR OpenTherm::start_write_timer_() {
InterruptLock const lock;
timer1_attachInterrupt(OpenTherm::esp8266_timer_isr);
timer1_enable(TIM_DIV16, TIM_EDGE, TIM_LOOP); // 5MHz (5 ticks/us - 1677721.4 us max)
timer1_write(2500); // 2kHz
}
void OpenTherm::stop_timer_() {
void IRAM_ATTR OpenTherm::stop_timer_() {
InterruptLock const lock;
timer1_disable();
timer1_detachInterrupt();
@@ -393,7 +389,7 @@ void OpenTherm::stop_timer_() {
#endif // END ESP8266
// https://stackoverflow.com/questions/21617970/how-to-check-if-value-has-even-parity-of-bits-or-odd
bool OpenTherm::check_parity_(uint32_t val) {
bool IRAM_ATTR OpenTherm::check_parity_(uint32_t val) {
val ^= val >> 16;
val ^= val >> 8;
val ^= val >> 4;
@@ -545,29 +541,17 @@ const char *OpenTherm::message_id_to_str(MessageId id) {
}
}
string OpenTherm::debug_data(OpenthermData &data) {
stringstream result;
result << bitset<8>(data.type) << " " << bitset<8>(data.id) << " " << bitset<8>(data.valueHB) << " "
<< bitset<8>(data.valueLB) << "\n";
result << "type: " << this->message_type_to_str((MessageType) data.type) << "; ";
result << "id: " << to_string(data.id) << "; ";
result << "HB: " << to_string(data.valueHB) << "; ";
result << "LB: " << to_string(data.valueLB) << "; ";
result << "uint_16: " << to_string(data.u16()) << "; ";
result << "float: " << to_string(data.f88());
return result.str();
void OpenTherm::debug_data(OpenthermData &data) {
ESP_LOGD(TAG, "%s %s %s %s", format_bin(data.type).c_str(), format_bin(data.id).c_str(),
format_bin(data.valueHB).c_str(), format_bin(data.valueLB).c_str());
ESP_LOGD(TAG, "type: %s; id: %s; HB: %s; LB: %s; uint_16: %s; float: %s",
this->message_type_to_str((MessageType) data.type), to_string(data.id).c_str(),
to_string(data.valueHB).c_str(), to_string(data.valueLB).c_str(), to_string(data.u16()).c_str(),
to_string(data.f88()).c_str());
}
std::string OpenTherm::debug_error(OpenThermError &error) {
stringstream result;
result << "type: " << this->protocol_error_to_to_str(error.error_type) << "; ";
result << "data: ";
result << format_hex(error.data);
result << "; clock: " << to_string(clock_);
result << "; capture: " << bitset<32>(error.capture);
result << "; bit_pos: " << to_string(error.bit_pos);
return result.str();
void OpenTherm::debug_error(OpenThermError &error) const {
ESP_LOGD(TAG, "data: %s; clock: %s; capture: %s; bit_pos: %s", format_hex(error.data).c_str(),
to_string(clock_).c_str(), format_bin(error.capture).c_str(), to_string(error.bit_pos).c_str());
}
float OpenthermData::f88() { return ((float) this->s16()) / 256.0; }

View File

@@ -8,10 +8,9 @@
#pragma once
#include <string>
#include <sstream>
#include <iomanip>
#include "esphome/core/hal.h"
#include "esphome/core/log.h"
#include "esphome/core/helpers.h"
#if defined(ESP32) || defined(USE_ESP_IDF)
#include "driver/timer.h"
@@ -318,8 +317,8 @@ class OpenTherm {
OperationMode get_mode() { return mode_; }
std::string debug_data(OpenthermData &data);
std::string debug_error(OpenThermError &error);
void debug_data(OpenthermData &data);
void debug_error(OpenThermError &error) const;
const char *protocol_error_to_to_str(ProtocolErrorType error_type);
const char *message_type_to_str(MessageType message_type);

View File

@@ -92,6 +92,7 @@ async def to_code(config):
async def ota_to_code(var, config):
await cg.past_safe_mode()
use_state_callback = False
for conf in config.get(CONF_ON_STATE_CHANGE, []):
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)

View File

@@ -1,6 +1,7 @@
# Commands
SW_RESET_CMD = 0x01
SLEEP_OUT = 0x11
NORON = 0x13
INVERT_OFF = 0x20
INVERT_ON = 0x21
ALL_ON = 0x23
@@ -55,6 +56,8 @@ chip.cmd(PAGESEL, 0x00)
chip.cmd(0xC2, 0x00)
chip.delay(10)
chip.cmd(TEON, 0x00)
chip.cmd(PIXFMT, 0x55)
chip.cmd(NORON)
chip = DriverChip("AXS15231")
chip.cmd(0xBB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5A, 0xA5)

View File

@@ -111,7 +111,6 @@ void QspiDbi::reset_params_(bool ready) {
mad |= MADCTL_MY;
this->write_command_(MADCTL_CMD, mad);
this->write_command_(BRIGHTNESS, this->brightness_);
this->write_command_(NORON);
this->write_command_(DISPLAY_ON);
}

View File

@@ -40,13 +40,7 @@ class Rtttl : public Component {
void set_speaker(speaker::Speaker *speaker) { this->speaker_ = speaker; }
#endif
float get_gain() { return gain_; }
void set_gain(float gain) {
if (gain < 0.1f)
gain = 0.1f;
if (gain > 1.0f)
gain = 1.0f;
this->gain_ = gain;
}
void set_gain(float gain) { this->gain_ = clamp(gain, 0.0f, 1.0f); }
void play(std::string rtttl);
void stop();
void dump_config() override;

View File

@@ -7,6 +7,7 @@ from esphome.const import CONF_DATA, CONF_ID, CONF_VOLUME
from esphome.core import CORE
from esphome.coroutine import coroutine_with_priority
AUTO_LOAD = ["audio"]
CODEOWNERS = ["@jesserockz", "@kahrendt"]
IS_PLATFORM_COMPONENT = True

View File

@@ -1,7 +1,7 @@
#include "st7920.h"
#include "esphome/core/log.h"
#include "esphome/core/application.h"
#include "esphome/components/display/display_buffer.h"
#include "esphome/core/application.h"
#include "esphome/core/log.h"
namespace esphome {
namespace st7920 {
@@ -118,7 +118,6 @@ size_t ST7920::get_buffer_length_() {
void HOT ST7920::draw_absolute_pixel_internal(int x, int y, Color color) {
if (x >= this->get_width_internal() || x < 0 || y >= this->get_height_internal() || y < 0) {
ESP_LOGW(TAG, "Position out of area: %dx%d", x, y);
return;
}
int width = this->get_width_internal() / 8u;

View File

@@ -6,6 +6,8 @@ from esphome.const import (
ENTITY_CATEGORY_DIAGNOSTIC,
)
DEPENDENCIES = ["network"]
status_ns = cg.esphome_ns.namespace("status")
StatusBinarySensor = status_ns.class_(
"StatusBinarySensor", binary_sensor.BinarySensor, cg.Component

View File

@@ -137,8 +137,16 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html#_CPPv417wifi_sta_config_t
wifi_config_t conf;
memset(&conf, 0, sizeof(conf));
snprintf(reinterpret_cast<char *>(conf.sta.ssid), sizeof(conf.sta.ssid), "%s", ap.get_ssid().c_str());
snprintf(reinterpret_cast<char *>(conf.sta.password), sizeof(conf.sta.password), "%s", ap.get_password().c_str());
if (ap.get_ssid().size() > sizeof(conf.sta.ssid)) {
ESP_LOGE(TAG, "SSID is too long");
return false;
}
if (ap.get_password().size() > sizeof(conf.sta.password)) {
ESP_LOGE(TAG, "password is too long");
return false;
}
memcpy(reinterpret_cast<char *>(conf.sta.ssid), ap.get_ssid().c_str(), ap.get_ssid().size());
memcpy(reinterpret_cast<char *>(conf.sta.password), ap.get_password().c_str(), ap.get_password().size());
// The weakest authmode to accept in the fast scan mode
if (ap.get_password().empty()) {
@@ -746,7 +754,11 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
wifi_config_t conf;
memset(&conf, 0, sizeof(conf));
snprintf(reinterpret_cast<char *>(conf.ap.ssid), sizeof(conf.ap.ssid), "%s", ap.get_ssid().c_str());
if (ap.get_ssid().size() > sizeof(conf.ap.ssid)) {
ESP_LOGE(TAG, "AP SSID is too long");
return false;
}
memcpy(reinterpret_cast<char *>(conf.ap.ssid), ap.get_ssid().c_str(), ap.get_ssid().size());
conf.ap.channel = ap.get_channel().value_or(1);
conf.ap.ssid_hidden = ap.get_ssid().size();
conf.ap.max_connection = 5;
@@ -757,7 +769,11 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
*conf.ap.password = 0;
} else {
conf.ap.authmode = WIFI_AUTH_WPA2_PSK;
snprintf(reinterpret_cast<char *>(conf.ap.password), sizeof(conf.ap.password), "%s", ap.get_password().c_str());
if (ap.get_password().size() > sizeof(conf.ap.password)) {
ESP_LOGE(TAG, "AP password is too long");
return false;
}
memcpy(reinterpret_cast<char *>(conf.ap.password), ap.get_password().c_str(), ap.get_password().size());
}
// pairwise cipher of SoftAP, group cipher will be derived using this.

View File

@@ -236,8 +236,16 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
struct station_config conf {};
memset(&conf, 0, sizeof(conf));
snprintf(reinterpret_cast<char *>(conf.ssid), sizeof(conf.ssid), "%s", ap.get_ssid().c_str());
snprintf(reinterpret_cast<char *>(conf.password), sizeof(conf.password), "%s", ap.get_password().c_str());
if (ap.get_ssid().size() > sizeof(conf.ssid)) {
ESP_LOGE(TAG, "SSID is too long");
return false;
}
if (ap.get_password().size() > sizeof(conf.password)) {
ESP_LOGE(TAG, "password is too long");
return false;
}
memcpy(reinterpret_cast<char *>(conf.ssid), ap.get_ssid().c_str(), ap.get_ssid().size());
memcpy(reinterpret_cast<char *>(conf.password), ap.get_password().c_str(), ap.get_password().size());
if (ap.get_bssid().has_value()) {
conf.bssid_set = 1;
@@ -775,7 +783,11 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
return false;
struct softap_config conf {};
snprintf(reinterpret_cast<char *>(conf.ssid), sizeof(conf.ssid), "%s", ap.get_ssid().c_str());
if (ap.get_ssid().size() > sizeof(conf.ssid)) {
ESP_LOGE(TAG, "AP SSID is too long");
return false;
}
memcpy(reinterpret_cast<char *>(conf.ssid), ap.get_ssid().c_str(), ap.get_ssid().size());
conf.ssid_len = static_cast<uint8>(ap.get_ssid().size());
conf.channel = ap.get_channel().value_or(1);
conf.ssid_hidden = ap.get_hidden();
@@ -787,7 +799,11 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
*conf.password = 0;
} else {
conf.authmode = AUTH_WPA2_PSK;
snprintf(reinterpret_cast<char *>(conf.password), sizeof(conf.password), "%s", ap.get_password().c_str());
if (ap.get_password().size() > sizeof(conf.password)) {
ESP_LOGE(TAG, "AP password is too long");
return false;
}
memcpy(reinterpret_cast<char *>(conf.password), ap.get_password().c_str(), ap.get_password().size());
}
ETS_UART_INTR_DISABLE();

View File

@@ -289,8 +289,16 @@ bool WiFiComponent::wifi_sta_connect_(const WiFiAP &ap) {
// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html#_CPPv417wifi_sta_config_t
wifi_config_t conf;
memset(&conf, 0, sizeof(conf));
snprintf(reinterpret_cast<char *>(conf.sta.ssid), sizeof(conf.sta.ssid), "%s", ap.get_ssid().c_str());
snprintf(reinterpret_cast<char *>(conf.sta.password), sizeof(conf.sta.password), "%s", ap.get_password().c_str());
if (ap.get_ssid().size() > sizeof(conf.sta.ssid)) {
ESP_LOGE(TAG, "SSID is too long");
return false;
}
if (ap.get_password().size() > sizeof(conf.sta.password)) {
ESP_LOGE(TAG, "password is too long");
return false;
}
memcpy(reinterpret_cast<char *>(conf.sta.ssid), ap.get_ssid().c_str(), ap.get_ssid().size());
memcpy(reinterpret_cast<char *>(conf.sta.password), ap.get_password().c_str(), ap.get_password().size());
// The weakest authmode to accept in the fast scan mode
if (ap.get_password().empty()) {
@@ -902,7 +910,11 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
wifi_config_t conf;
memset(&conf, 0, sizeof(conf));
strncpy(reinterpret_cast<char *>(conf.ap.ssid), ap.get_ssid().c_str(), sizeof(conf.ap.ssid));
if (ap.get_ssid().size() > sizeof(conf.ap.ssid)) {
ESP_LOGE(TAG, "AP SSID is too long");
return false;
}
memcpy(reinterpret_cast<char *>(conf.ap.ssid), ap.get_ssid().c_str(), ap.get_ssid().size());
conf.ap.channel = ap.get_channel().value_or(1);
conf.ap.ssid_hidden = ap.get_ssid().size();
conf.ap.max_connection = 5;
@@ -913,7 +925,11 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
*conf.ap.password = 0;
} else {
conf.ap.authmode = WIFI_AUTH_WPA2_PSK;
strncpy(reinterpret_cast<char *>(conf.ap.password), ap.get_password().c_str(), sizeof(conf.ap.password));
if (ap.get_password().size() > sizeof(conf.ap.password)) {
ESP_LOGE(TAG, "AP password is too long");
return false;
}
memcpy(reinterpret_cast<char *>(conf.ap.password), ap.get_password().c_str(), ap.get_password().size());
}
// pairwise cipher of SoftAP, group cipher will be derived using this.

View File

@@ -1,6 +1,6 @@
"""Constants used by esphome."""
__version__ = "2024.11.0"
__version__ = "2024.11.3"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
VALID_SUBSTITUTIONS_CHARACTERS = (

View File

@@ -184,6 +184,9 @@ PRELOAD_CONFIG_SCHEMA = cv.Schema(
cv.Optional(CONF_ESP8266_RESTORE_FROM_FLASH): cv.valid,
cv.Optional(CONF_BOARD_FLASH_MODE): cv.valid,
cv.Optional(CONF_ARDUINO_VERSION): cv.valid,
cv.Optional(CONF_MIN_VERSION, default=ESPHOME_VERSION): cv.All(
cv.version_number, cv.validate_esphome_version
),
},
extra=cv.ALLOW_EXTRA,
)

View File

@@ -397,6 +397,18 @@ std::string format_hex_pretty(const uint16_t *data, size_t length) {
}
std::string format_hex_pretty(const std::vector<uint16_t> &data) { return format_hex_pretty(data.data(), data.size()); }
std::string format_bin(const uint8_t *data, size_t length) {
std::string result;
result.resize(length * 8);
for (size_t byte_idx = 0; byte_idx < length; byte_idx++) {
for (size_t bit_idx = 0; bit_idx < 8; bit_idx++) {
result[byte_idx * 8 + bit_idx] = ((data[byte_idx] >> (7 - bit_idx)) & 1) + '0';
}
}
return result;
}
ParseOnOffState parse_on_off(const char *str, const char *on, const char *off) {
if (on == nullptr && strcasecmp(str, "on") == 0)
return PARSE_ON;

View File

@@ -420,6 +420,14 @@ template<typename T, enable_if_t<std::is_unsigned<T>::value, int> = 0> std::stri
return format_hex_pretty(reinterpret_cast<uint8_t *>(&val), sizeof(T));
}
/// Format the byte array \p data of length \p len in binary.
std::string format_bin(const uint8_t *data, size_t length);
/// Format an unsigned integer in binary, starting with the most significant byte.
template<typename T, enable_if_t<std::is_unsigned<T>::value, int> = 0> std::string format_bin(T val) {
val = convert_big_endian(val);
return format_bin(reinterpret_cast<uint8_t *>(&val), sizeof(T));
}
/// Return values for parse_on_off().
enum ParseOnOffState {
PARSE_NONE = 0,

View File

@@ -5,20 +5,18 @@
namespace esphome {
bool is_leap_year(uint32_t year) { return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0); }
uint8_t days_in_month(uint8_t month, uint16_t year) {
static const uint8_t DAYS_IN_MONTH[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
uint8_t days = DAYS_IN_MONTH[month];
if (month == 2 && is_leap_year(year))
if (month == 2 && (year % 4 == 0))
return 29;
return days;
return DAYS_IN_MONTH[month];
}
size_t ESPTime::strftime(char *buffer, size_t buffer_len, const char *format) {
struct tm c_tm = this->to_c_tm();
return ::strftime(buffer, buffer_len, format, &c_tm);
}
ESPTime ESPTime::from_c_tm(struct tm *c_tm, time_t c_time) {
ESPTime res{};
res.second = uint8_t(c_tm->tm_sec);
@@ -33,6 +31,7 @@ ESPTime ESPTime::from_c_tm(struct tm *c_tm, time_t c_time) {
res.timestamp = c_time;
return res;
}
struct tm ESPTime::to_c_tm() {
struct tm c_tm {};
c_tm.tm_sec = this->second;
@@ -46,6 +45,7 @@ struct tm ESPTime::to_c_tm() {
c_tm.tm_isdst = this->is_dst;
return c_tm;
}
std::string ESPTime::strftime(const std::string &format) {
std::string timestr;
timestr.resize(format.size() * 4);
@@ -142,6 +142,7 @@ void ESPTime::increment_second() {
this->year++;
}
}
void ESPTime::increment_day() {
this->timestamp += 86400;
@@ -159,23 +160,22 @@ void ESPTime::increment_day() {
this->year++;
}
}
void ESPTime::recalc_timestamp_utc(bool use_day_of_year) {
time_t res = 0;
if (!this->fields_in_range()) {
this->timestamp = -1;
return;
}
for (int i = 1970; i < this->year; i++)
res += is_leap_year(i) ? 366 : 365;
res += (i % 4 == 0) ? 366 : 365;
if (use_day_of_year) {
res += this->day_of_year - 1;
} else {
for (int i = 1; i < this->month; i++)
res += days_in_month(i, this->year);
res += this->day_of_month - 1;
}
@@ -188,13 +188,17 @@ void ESPTime::recalc_timestamp_utc(bool use_day_of_year) {
this->timestamp = res;
}
void ESPTime::recalc_timestamp_local(bool use_day_of_year) {
this->recalc_timestamp_utc(use_day_of_year);
this->timestamp -= ESPTime::timezone_offset();
ESPTime temp = ESPTime::from_epoch_local(this->timestamp);
if (temp.is_dst) {
this->timestamp -= 3600;
}
void ESPTime::recalc_timestamp_local() {
struct tm tm;
tm.tm_year = this->year - 1900;
tm.tm_mon = this->month - 1;
tm.tm_mday = this->day_of_month;
tm.tm_hour = this->hour;
tm.tm_min = this->minute;
tm.tm_sec = this->second;
this->timestamp = mktime(&tm);
}
int32_t ESPTime::timezone_offset() {

View File

@@ -9,8 +9,6 @@ namespace esphome {
template<typename T> bool increment_time_value(T &current, uint16_t begin, uint16_t end);
bool is_leap_year(uint32_t year);
uint8_t days_in_month(uint8_t month, uint16_t year);
/// A more user-friendly version of struct tm from time.h
@@ -100,7 +98,7 @@ struct ESPTime {
void recalc_timestamp_utc(bool use_day_of_year = true);
/// Recalculate the timestamp field from the other fields of this ESPTime instance assuming local fields.
void recalc_timestamp_local(bool use_day_of_year = true);
void recalc_timestamp_local();
/// Convert this ESPTime instance back to a tm struct.
struct tm to_c_tm();

View File

@@ -103,7 +103,7 @@ class ESPHomeDashboard:
self.loop = asyncio.get_running_loop()
self.ping_request = asyncio.Event()
self.entries = DashboardEntries(self)
self.load_ignored_devices()
await self.loop.run_in_executor(None, self.load_ignored_devices)
def load_ignored_devices(self) -> None:
storage_path = Path(ignored_devices_storage_path())

View File

@@ -544,7 +544,7 @@ class ImportRequestHandler(BaseHandler):
class IgnoreDeviceRequestHandler(BaseHandler):
@authenticated
def post(self) -> None:
async def post(self) -> None:
dashboard = DASHBOARD
try:
args = json.loads(self.request.body.decode())
@@ -576,7 +576,8 @@ class IgnoreDeviceRequestHandler(BaseHandler):
else:
dashboard.ignored_devices.discard(ignored_device.device_name)
dashboard.save_ignored_devices()
loop = asyncio.get_running_loop()
await loop.run_in_executor(None, dashboard.save_ignored_devices)
self.set_status(204)
self.finish()

View File

@@ -39,6 +39,14 @@ http_request:
timeout: 10s
verify_ssl: ${verify_ssl}
script:
- id: does_not_compile
parameters:
api_url: string
then:
- http_request.get:
url: "http://google.com"
ota:
- platform: http_request
on_begin:

View File

@@ -109,6 +109,10 @@ lvgl:
close_button: true
title: Messagebox
bg_color: 0xffff
widgets:
- label:
text: Hello Msgbox
id: msgbox_label
body:
text: This is a sample messagebox
bg_color: 0x808080
@@ -137,6 +141,9 @@ lvgl:
- lvgl.widget.focus: mark
- lvgl.widget.redraw: hello_label
- lvgl.widget.redraw:
- lvgl.label.update:
id: msgbox_label
text: Unloaded
on_all_events:
logger.log:
format: "Event %s"
@@ -333,7 +340,7 @@ lvgl:
id: button_button
width: 20%
height: 10%
transform_angle: !lambda return 180*100;
transform_angle: !lambda return(180*100);
arc_width: !lambda return 4;
border_width: !lambda return 6;
shadow_ofs_x: !lambda return 6;
@@ -577,7 +584,7 @@ lvgl:
- 180, 60
- 240, 10
on_click:
- lvgl.widget.update:
- lvgl.line.update:
id: lv_line_id
line_color: 0xFFFF
- lvgl.page.next: