From d2380756b2a4982e98b4d3a5ab41391dc40e7a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Wed, 25 Jan 2023 23:55:06 +0100 Subject: [PATCH 1/6] Add "content" to deploy-ha-addon-repo dispatch (#4349) --- .github/workflows/release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ec2d6d0ec..d3b96141c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -140,11 +140,10 @@ jobs: TOKEN: ${{ secrets.DEPLOY_HA_ADDON_REPO_TOKEN }} # yamllint disable rule:line-length run: | - TAG="${GITHUB_REF#refs/tags/}" curl \ -u ":$TOKEN" \ -X POST \ -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/esphome/home-assistant-addon/actions/workflows/bump-version.yml/dispatches \ - -d "{\"ref\":\"main\",\"inputs\":{\"version\":\"$TAG\"}}" + -d '{"ref":"main","inputs":{"version":"${{ github.event.release.tag_name }}","content":${{ toJSON(github.event.release.body) }}}}' # yamllint enable rule:line-length From 2d0a08442e2571f11be3661a61c48f608ec91fbc Mon Sep 17 00:00:00 2001 From: "Denis Bodor (aka Lefinnois)" Date: Thu, 26 Jan 2023 00:06:46 +0100 Subject: [PATCH 2/6] fix stepper jump back with small steps (#4339) --- esphome/components/a4988/a4988.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/esphome/components/a4988/a4988.cpp b/esphome/components/a4988/a4988.cpp index 429fa25648..ae2df3233a 100644 --- a/esphome/components/a4988/a4988.cpp +++ b/esphome/components/a4988/a4988.cpp @@ -46,6 +46,7 @@ void A4988::loop() { return; this->dir_pin_->digital_write(dir == 1); + delayMicroseconds(50); this->step_pin_->digital_write(true); delayMicroseconds(5); this->step_pin_->digital_write(false); From aa7f3569ec15664631a49063454803a806a95cca Mon Sep 17 00:00:00 2001 From: Stephan Martin Date: Thu, 26 Jan 2023 00:08:55 +0100 Subject: [PATCH 3/6] rename esp32 CAN to TWAI, so it compiles again (#4334) fixes https://github.com/esphome/issues/issues/4023 --- esphome/components/esp32_can/esp32_can.cpp | 50 +++++++++++----------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/esphome/components/esp32_can/esp32_can.cpp b/esphome/components/esp32_can/esp32_can.cpp index baae683988..3eb2d1f035 100644 --- a/esphome/components/esp32_can/esp32_can.cpp +++ b/esphome/components/esp32_can/esp32_can.cpp @@ -2,7 +2,7 @@ #include "esp32_can.h" #include "esphome/core/log.h" -#include +#include // WORKAROUND, because CAN_IO_UNUSED is just defined as (-1) in this version // of the framework which does not work with -fpermissive @@ -14,25 +14,25 @@ namespace esp32_can { static const char *const TAG = "esp32_can"; -static bool get_bitrate(canbus::CanSpeed bitrate, can_timing_config_t *t_config) { +static bool get_bitrate(canbus::CanSpeed bitrate, twai_timing_config_t *t_config) { switch (bitrate) { case canbus::CAN_50KBPS: - *t_config = (can_timing_config_t) CAN_TIMING_CONFIG_50KBITS(); + *t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_50KBITS(); return true; case canbus::CAN_100KBPS: - *t_config = (can_timing_config_t) CAN_TIMING_CONFIG_100KBITS(); + *t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_100KBITS(); return true; case canbus::CAN_125KBPS: - *t_config = (can_timing_config_t) CAN_TIMING_CONFIG_125KBITS(); + *t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_125KBITS(); return true; case canbus::CAN_250KBPS: - *t_config = (can_timing_config_t) CAN_TIMING_CONFIG_250KBITS(); + *t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_250KBITS(); return true; case canbus::CAN_500KBPS: - *t_config = (can_timing_config_t) CAN_TIMING_CONFIG_500KBITS(); + *t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_500KBITS(); return true; case canbus::CAN_1000KBPS: - *t_config = (can_timing_config_t) CAN_TIMING_CONFIG_1MBITS(); + *t_config = (twai_timing_config_t) TWAI_TIMING_CONFIG_1MBITS(); return true; default: return false; @@ -40,10 +40,10 @@ static bool get_bitrate(canbus::CanSpeed bitrate, can_timing_config_t *t_config) } bool ESP32Can::setup_internal() { - can_general_config_t g_config = - CAN_GENERAL_CONFIG_DEFAULT((gpio_num_t) this->tx_, (gpio_num_t) this->rx_, CAN_MODE_NORMAL); - can_filter_config_t f_config = CAN_FILTER_CONFIG_ACCEPT_ALL(); - can_timing_config_t t_config; + twai_general_config_t g_config = + TWAI_GENERAL_CONFIG_DEFAULT((gpio_num_t) this->tx_, (gpio_num_t) this->rx_, TWAI_MODE_NORMAL); + twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); + twai_timing_config_t t_config; if (!get_bitrate(this->bit_rate_, &t_config)) { // invalid bit rate @@ -51,15 +51,15 @@ bool ESP32Can::setup_internal() { return false; } - // Install CAN driver - if (can_driver_install(&g_config, &t_config, &f_config) != ESP_OK) { + // Install TWAI driver + if (twai_driver_install(&g_config, &t_config, &f_config) != ESP_OK) { // Failed to install driver this->mark_failed(); return false; } - // Start CAN driver - if (can_start() != ESP_OK) { + // Start TWAI driver + if (twai_start() != ESP_OK) { // Failed to start driver this->mark_failed(); return false; @@ -72,15 +72,15 @@ canbus::Error ESP32Can::send_message(struct canbus::CanFrame *frame) { return canbus::ERROR_FAILTX; } - uint32_t flags = CAN_MSG_FLAG_NONE; + uint32_t flags = TWAI_MSG_FLAG_NONE; if (frame->use_extended_id) { - flags |= CAN_MSG_FLAG_EXTD; + flags |= TWAI_MSG_FLAG_EXTD; } if (frame->remote_transmission_request) { - flags |= CAN_MSG_FLAG_RTR; + flags |= TWAI_MSG_FLAG_RTR; } - can_message_t message = { + twai_message_t message = { .flags = flags, .identifier = frame->can_id, .data_length_code = frame->can_data_length_code, @@ -89,7 +89,7 @@ canbus::Error ESP32Can::send_message(struct canbus::CanFrame *frame) { memcpy(message.data, frame->data, frame->can_data_length_code); } - if (can_transmit(&message, pdMS_TO_TICKS(1000)) == ESP_OK) { + if (twai_transmit(&message, pdMS_TO_TICKS(1000)) == ESP_OK) { return canbus::ERROR_OK; } else { return canbus::ERROR_ALLTXBUSY; @@ -97,15 +97,15 @@ canbus::Error ESP32Can::send_message(struct canbus::CanFrame *frame) { } canbus::Error ESP32Can::read_message(struct canbus::CanFrame *frame) { - can_message_t message; + twai_message_t message; - if (can_receive(&message, 0) != ESP_OK) { + if (twai_receive(&message, 0) != ESP_OK) { return canbus::ERROR_NOMSG; } frame->can_id = message.identifier; - frame->use_extended_id = message.flags & CAN_MSG_FLAG_EXTD; - frame->remote_transmission_request = message.flags & CAN_MSG_FLAG_RTR; + frame->use_extended_id = message.flags & TWAI_MSG_FLAG_EXTD; + frame->remote_transmission_request = message.flags & TWAI_MSG_FLAG_RTR; frame->can_data_length_code = message.data_length_code; if (!frame->remote_transmission_request) { From 7f97f4255226472fce6be0d02898e70c1d1b8545 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 26 Jan 2023 02:09:38 +0300 Subject: [PATCH 4/6] Fix BME280 initialization before wifi setup (#4190) fixes https://github.com/esphome/issues/issues/3530 --- esphome/components/bme280/bme280.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/esphome/components/bme280/bme280.cpp b/esphome/components/bme280/bme280.cpp index d8124f5dc3..786fc01d28 100644 --- a/esphome/components/bme280/bme280.cpp +++ b/esphome/components/bme280/bme280.cpp @@ -88,7 +88,10 @@ void BME280Component::setup() { // Mark as not failed before initializing. Some devices will turn off sensors to save on batteries // and when they come back on, the COMPONENT_STATE_FAILED bit must be unset on the component. - this->component_state_ &= ~COMPONENT_STATE_FAILED; + if ((this->component_state_ & COMPONENT_STATE_MASK) == COMPONENT_STATE_FAILED) { + this->component_state_ &= ~COMPONENT_STATE_MASK; + this->component_state_ |= COMPONENT_STATE_CONSTRUCTION; + } if (!this->read_byte(BME280_REGISTER_CHIPID, &chip_id)) { this->error_code_ = COMMUNICATION_FAILED; From e1cdeb7c8f82c143e03a00b9f44886874987196d Mon Sep 17 00:00:00 2001 From: melyux <10296053+melyux@users.noreply.github.com> Date: Wed, 25 Jan 2023 15:11:10 -0800 Subject: [PATCH 5/6] Add a soft reset in setup() for bmp280 (#4329) fixes https://github.com/esphome/issues/issues/3383 --- esphome/components/bmp280/bmp280.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/esphome/components/bmp280/bmp280.cpp b/esphome/components/bmp280/bmp280.cpp index bda34e6c2b..a5b2517893 100644 --- a/esphome/components/bmp280/bmp280.cpp +++ b/esphome/components/bmp280/bmp280.cpp @@ -1,4 +1,5 @@ #include "bmp280.h" +#include "esphome/core/hal.h" #include "esphome/core/log.h" namespace esphome { @@ -11,8 +12,11 @@ static const uint8_t BMP280_REGISTER_CONTROL = 0xF4; static const uint8_t BMP280_REGISTER_CONFIG = 0xF5; static const uint8_t BMP280_REGISTER_PRESSUREDATA = 0xF7; static const uint8_t BMP280_REGISTER_TEMPDATA = 0xFA; +static const uint8_t BMP280_REGISTER_RESET = 0xE0; static const uint8_t BMP280_MODE_FORCED = 0b01; +static const uint8_t BMP280_SOFT_RESET = 0xB6; +static const uint8_t BMP280_STATUS_IM_UPDATE = 0b01; inline uint16_t combine_bytes(uint8_t msb, uint8_t lsb) { return ((msb & 0xFF) << 8) | (lsb & 0xFF); } @@ -66,6 +70,28 @@ void BMP280Component::setup() { return; } + // Send a soft reset. + if (!this->write_byte(BMP280_REGISTER_RESET, BMP280_SOFT_RESET)) { + this->mark_failed(); + return; + } + // Wait until the NVM data has finished loading. + uint8_t status; + uint8_t retry = 5; + do { + delay(2); + if (!this->read_byte(BMP280_REGISTER_STATUS, &status)) { + ESP_LOGW(TAG, "Error reading status register."); + this->mark_failed(); + return; + } + } while ((status & BMP280_STATUS_IM_UPDATE) && (--retry)); + if (status & BMP280_STATUS_IM_UPDATE) { + ESP_LOGW(TAG, "Timeout loading NVM."); + this->mark_failed(); + return; + } + // Read calibration this->calibration_.t1 = this->read_u16_le_(0x88); this->calibration_.t2 = this->read_s16_le_(0x8A); From c8c0bd3351d6348aab241594828bff21a18ef3b8 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Thu, 26 Jan 2023 15:00:18 +1300 Subject: [PATCH 6/6] Bump version to 2022.12.7 --- esphome/const.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/esphome/const.py b/esphome/const.py index 89292c9434..12e7045a49 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -1,6 +1,6 @@ """Constants used by esphome.""" -__version__ = "2022.12.6" +__version__ = "2022.12.7" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"