1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-04 17:11:51 +00:00

Compare commits

...

15 Commits

Author SHA1 Message Date
Jesse Hills
1ef6fd8fb0 Merge pull request #3261 from esphome/bump-2022.2.6
2022.2.6
2022-03-02 22:54:51 +13:00
Jesse Hills
942b0de7fd Bump version to 2022.2.6 2022-03-02 17:07:08 +13:00
Jesse Hills
859cca49d1 Only get free memory size from internal (#3259) 2022-03-02 17:07:08 +13:00
Jesse Hills
8f7ff25624 Merge pull request #3252 from esphome/bump-2022.2.5
2022.2.5
2022-02-24 07:28:56 +13:00
Jesse Hills
97aca8e54c Bump version to 2022.2.5 2022-02-23 11:20:48 +13:00
Nicholas Peters
95acf19067 Fix regression caused by TSL2591 auto gain (#3249) 2022-02-23 11:20:48 +13:00
Martin Weinelt
3d0899aa58 Respect ESPHOME_USE_SUBPROCESS in esp32 post_build script (#3246) 2022-02-23 11:20:48 +13:00
Jesse Hills
138d6e505b Merge pull request #3245 from esphome/bump-2022.2.4
2022.2.4
2022-02-21 10:54:54 +13:00
Jesse Hills
2748e6ba29 Bump version to 2022.2.4 2022-02-21 10:17:25 +13:00
Jesse Hills
dbd4e927d8 Fix fatal erroring in addon startup script (#3244) 2022-02-21 10:17:24 +13:00
Jesse Hills
e73d47918f Fix lilygo touchscreen rotation (#3221) 2022-02-21 10:17:24 +13:00
Tyler Bules
b881bc071e ESP32-C3 deep sleep fix (#3066) 2022-02-21 10:17:24 +13:00
Otto Winter
1d0395d1c7 Improve ESP8266 iram usage (#3223) 2022-02-21 10:17:24 +13:00
Otto Winter
616c787e37 Fix ESP8266 climate memaccess warning (#3226) 2022-02-21 10:17:24 +13:00
Otto Winter
0c4de2bc97 Publish NAN when dallas conversion failed (#3227) 2022-02-21 10:17:24 +13:00
14 changed files with 146 additions and 21 deletions

View File

@@ -7,12 +7,12 @@
# Check SSL requirements, if enabled
if bashio::config.true 'ssl'; then
if ! bashio::config.has_value 'certfile'; then
bashio::fatal 'SSL is enabled, but no certfile was specified.'
bashio::log.fatal 'SSL is enabled, but no certfile was specified.'
bashio::exit.nok
fi
if ! bashio::config.has_value 'keyfile'; then
bashio::fatal 'SSL is enabled, but no keyfile was specified'
bashio::log.fatal 'SSL is enabled, but no keyfile was specified'
bashio::exit.nok
fi

View File

@@ -1,4 +1,5 @@
#include "climate.h"
#include "esphome/core/macros.h"
namespace esphome {
namespace climate {
@@ -326,14 +327,17 @@ optional<ClimateDeviceRestoreState> Climate::restore_state_() {
return recovered;
}
void Climate::save_state_() {
#if defined(USE_ESP_IDF) && !defined(CLANG_TIDY)
#if (defined(USE_ESP_IDF) || (defined(USE_ESP8266) && USE_ARDUINO_VERSION_CODE >= VERSION_CODE(3, 0, 0))) && \
!defined(CLANG_TIDY)
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#define TEMP_IGNORE_MEMACCESS
#endif
ClimateDeviceRestoreState state{};
// initialize as zero to prevent random data on stack triggering erase
memset(&state, 0, sizeof(ClimateDeviceRestoreState));
#if USE_ESP_IDF && !defined(CLANG_TIDY)
#ifdef TEMP_IGNORE_MEMACCESS
#pragma GCC diagnostic pop
#undef TEMP_IGNORE_MEMACCESS
#endif
state.mode = this->mode;

View File

@@ -110,6 +110,9 @@ void DallasComponent::update() {
if (!result) {
ESP_LOGE(TAG, "Requesting conversion failed");
this->status_set_warning();
for (auto *sensor : this->sensors_) {
sensor->publish_state(NAN);
}
return;
}

View File

@@ -11,9 +11,39 @@ from esphome.const import (
CONF_WAKEUP_PIN,
)
from esphome.components.esp32 import get_esp32_variant
from esphome.components.esp32.const import (
VARIANT_ESP32,
VARIANT_ESP32C3,
)
WAKEUP_PINS = {
VARIANT_ESP32: [
0,
2,
4,
12,
13,
14,
15,
25,
26,
27,
32,
33,
34,
35,
36,
37,
38,
39,
],
VARIANT_ESP32C3: [0, 1, 2, 3, 4, 5],
}
def validate_pin_number(value):
valid_pins = [0, 2, 4, 12, 13, 14, 15, 25, 26, 27, 32, 33, 34, 35, 36, 37, 38, 39]
valid_pins = WAKEUP_PINS.get(get_esp32_variant(), WAKEUP_PINS[VARIANT_ESP32])
if value[CONF_NUMBER] not in valid_pins:
raise cv.Invalid(
f"Only pins {', '.join(str(x) for x in valid_pins)} support wakeup"
@@ -21,6 +51,14 @@ def validate_pin_number(value):
return value
def validate_config(config):
if get_esp32_variant() == VARIANT_ESP32C3 and CONF_ESP32_EXT1_WAKEUP in config:
raise cv.Invalid("ESP32-C3 does not support wakeup from touch.")
if get_esp32_variant() == VARIANT_ESP32C3 and CONF_TOUCH_WAKEUP in config:
raise cv.Invalid("ESP32-C3 does not support wakeup from ext1")
return config
deep_sleep_ns = cg.esphome_ns.namespace("deep_sleep")
DeepSleepComponent = deep_sleep_ns.class_("DeepSleepComponent", cg.Component)
EnterDeepSleepAction = deep_sleep_ns.class_("EnterDeepSleepAction", automation.Action)

View File

@@ -104,7 +104,7 @@ void DeepSleepComponent::begin_sleep(bool manual) {
App.run_safe_shutdown_hooks();
#ifdef USE_ESP32
#if defined(USE_ESP32) && !defined(USE_ESP32_VARIANT_ESP32C3)
if (this->sleep_duration_.has_value())
esp_sleep_enable_timer_wakeup(*this->sleep_duration_);
if (this->wakeup_pin_ != nullptr) {
@@ -126,6 +126,18 @@ void DeepSleepComponent::begin_sleep(bool manual) {
esp_deep_sleep_start();
#endif
#ifdef USE_ESP32_VARIANT_ESP32C3
if (this->sleep_duration_.has_value())
esp_sleep_enable_timer_wakeup(*this->sleep_duration_);
if (this->wakeup_pin_ != nullptr) {
bool level = !this->wakeup_pin_->is_inverted();
if (this->wakeup_pin_mode_ == WAKEUP_PIN_MODE_INVERT_WAKEUP && this->wakeup_pin_->digital_read()) {
level = !level;
}
esp_deep_sleep_enable_gpio_wakeup(gpio_num_t(this->wakeup_pin_->get_pin()), level);
}
#endif
#ifdef USE_ESP8266
ESP.deepSleep(*this->sleep_duration_); // NOLINT(readability-static-accessed-through-instance)
#endif

View File

@@ -57,13 +57,16 @@ class DeepSleepComponent : public Component {
public:
/// Set the duration in ms the component should sleep once it's in deep sleep mode.
void set_sleep_duration(uint32_t time_ms);
#ifdef USE_ESP32
#if defined(USE_ESP32)
/** Set the pin to wake up to on the ESP32 once it's in deep sleep mode.
* Use the inverted property to set the wakeup level.
*/
void set_wakeup_pin(InternalGPIOPin *pin) { this->wakeup_pin_ = pin; }
void set_wakeup_pin_mode(WakeupPinMode wakeup_pin_mode);
#endif
#if defined(USE_ESP32) && !defined(USE_ESP32_VARIANT_ESP32C3)
void set_ext1_wakeup(Ext1Wakeup ext1_wakeup);

View File

@@ -1,6 +1,10 @@
# Source https://github.com/letscontrolit/ESPEasy/pull/3845#issuecomment-1005864664
import esptool
import os
if os.environ.get("ESPHOME_USE_SUBPROCESS") is None:
import esptool
else:
import subprocess
from SCons.Script import ARGUMENTS
# pylint: disable=E0602
@@ -42,8 +46,11 @@ def esp32_create_combined_bin(source, target, env):
print()
print(f"Using esptool.py arguments: {' '.join(cmd)}")
print()
esptool.main(cmd)
if os.environ.get("ESPHOME_USE_SUBPROCESS") is None:
esptool.main(cmd)
else:
subprocess.run(["esptool.py", *cmd])
# pylint: disable=E0602
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) # noqa

View File

@@ -22,7 +22,7 @@ std::string build_json(const json_build_t &f) {
#ifdef USE_ESP8266
const size_t free_heap = ESP.getMaxFreeBlockSize() - 2048; // NOLINT(readability-static-accessed-through-instance)
#elif defined(USE_ESP32)
const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT) - 2048;
const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL) - 2048;
#endif
DynamicJsonDocument json_document(free_heap);
@@ -42,7 +42,7 @@ void parse_json(const std::string &data, const json_parse_t &f) {
#ifdef USE_ESP8266
const size_t free_heap = ESP.getMaxFreeBlockSize() - 2048; // NOLINT(readability-static-accessed-through-instance)
#elif defined(USE_ESP32)
const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT) - 2048;
const size_t free_heap = heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL) - 2048;
#endif
DynamicJsonDocument json_document(free_heap);

View File

@@ -113,8 +113,27 @@ void LilygoT547Touchscreen::loop() {
if (tp.state == 0x06)
tp.state = 0x07;
tp.y = (uint16_t)((buffer[i * 5 + 1 + offset] << 4) | ((buffer[i * 5 + 3 + offset] >> 4) & 0x0F));
tp.x = (uint16_t)((buffer[i * 5 + 2 + offset] << 4) | (buffer[i * 5 + 3 + offset] & 0x0F));
uint16_t y = (uint16_t)((buffer[i * 5 + 1 + offset] << 4) | ((buffer[i * 5 + 3 + offset] >> 4) & 0x0F));
uint16_t x = (uint16_t)((buffer[i * 5 + 2 + offset] << 4) | (buffer[i * 5 + 3 + offset] & 0x0F));
switch (this->rotation_) {
case ROTATE_0_DEGREES:
tp.y = this->display_height_ - y;
tp.x = x;
break;
case ROTATE_90_DEGREES:
tp.x = this->display_height_ - y;
tp.y = this->display_width_ - x;
break;
case ROTATE_180_DEGREES:
tp.y = y;
tp.x = this->display_width_ - x;
break;
case ROTATE_270_DEGREES:
tp.x = y;
tp.y = x;
break;
}
this->defer([this, tp]() { this->send_touch_(tp); });
}
@@ -122,8 +141,28 @@ void LilygoT547Touchscreen::loop() {
TouchPoint tp;
tp.id = (buffer[0] >> 4) & 0x0F;
tp.state = 0x06;
tp.y = (uint16_t)((buffer[0 * 5 + 1] << 4) | ((buffer[0 * 5 + 3] >> 4) & 0x0F));
tp.x = (uint16_t)((buffer[0 * 5 + 2] << 4) | (buffer[0 * 5 + 3] & 0x0F));
uint16_t y = (uint16_t)((buffer[0 * 5 + 1] << 4) | ((buffer[0 * 5 + 3] >> 4) & 0x0F));
uint16_t x = (uint16_t)((buffer[0 * 5 + 2] << 4) | (buffer[0 * 5 + 3] & 0x0F));
switch (this->rotation_) {
case ROTATE_0_DEGREES:
tp.y = this->display_height_ - y;
tp.x = x;
break;
case ROTATE_90_DEGREES:
tp.x = this->display_height_ - y;
tp.y = this->display_width_ - x;
break;
case ROTATE_180_DEGREES:
tp.y = y;
tp.x = this->display_width_ - x;
break;
case ROTATE_270_DEGREES:
tp.x = y;
tp.y = x;
break;
}
this->defer([this, tp]() { this->send_touch_(tp); });
}

View File

@@ -43,16 +43,34 @@ void TSL2591Component::disable_if_power_saving_() {
}
void TSL2591Component::setup() {
if (this->component_gain_ == TSL2591_CGAIN_AUTO)
this->gain_ = TSL2591_GAIN_MED;
switch (this->component_gain_) {
case TSL2591_CGAIN_LOW:
this->gain_ = TSL2591_GAIN_LOW;
break;
case TSL2591_CGAIN_MED:
this->gain_ = TSL2591_GAIN_MED;
break;
case TSL2591_CGAIN_HIGH:
this->gain_ = TSL2591_GAIN_HIGH;
break;
case TSL2591_CGAIN_MAX:
this->gain_ = TSL2591_GAIN_MAX;
break;
case TSL2591_CGAIN_AUTO:
this->gain_ = TSL2591_GAIN_MED;
break;
}
uint8_t address = this->address_;
ESP_LOGI(TAG, "Setting up TSL2591 sensor at I2C address 0x%02X", address);
uint8_t id;
if (!this->read_byte(TSL2591_COMMAND_BIT | TSL2591_REGISTER_DEVICE_ID, &id)) {
ESP_LOGE(TAG, "Failed I2C read during setup()");
this->mark_failed();
return;
}
if (id != 0x50) {
ESP_LOGE(TAG,
"Could not find the TSL2591 sensor. The ID register of the device at address 0x%02X reported 0x%02X "
@@ -61,6 +79,7 @@ void TSL2591Component::setup() {
this->mark_failed();
return;
}
this->set_integration_time_and_gain(this->integration_time_, this->gain_);
this->disable_if_power_saving_();
}

View File

@@ -1,6 +1,6 @@
"""Constants used by esphome."""
__version__ = "2022.2.3"
__version__ = "2022.2.6"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"

View File

@@ -116,7 +116,7 @@ optional<uint32_t> HOT Scheduler::next_schedule_in() {
return 0;
return next_time - now;
}
void IRAM_ATTR HOT Scheduler::call() {
void HOT Scheduler::call() {
const uint32_t now = this->millis_();
this->process_to_add();

View File

@@ -262,7 +262,7 @@ power_supply:
deep_sleep:
run_duration: 20s
sleep_duration: 50s
wakeup_pin: GPIO39
wakeup_pin: GPIO2
wakeup_pin_mode: INVERT_WAKEUP
ads1115:

View File

@@ -60,7 +60,7 @@ deep_sleep:
gpio_wakeup_reason: 10s
touch_wakeup_reason: 15s
sleep_duration: 50s
wakeup_pin: GPIO39
wakeup_pin: GPIO2
wakeup_pin_mode: INVERT_WAKEUP
as3935_i2c: