1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-05 09:31:54 +00:00

Compare commits

..

52 Commits

Author SHA1 Message Date
Jesse Hills
6c96281a1d Merge pull request #7035 from esphome/bump-2024.6.6
2024.6.6
2024-07-03 21:03:25 +12:00
Jesse Hills
3727342bce Bump version to 2024.6.6 2024-07-03 20:14:27 +12:00
Jesse Hills
fc3f806555 [docker] Fix docker build error fall through (#7021) 2024-07-03 20:14:27 +12:00
Jesse Hills
c013c3bf61 [docker] Bump versions inside armv7 block (#7022) 2024-07-03 20:14:27 +12:00
Jesse Hills
849a98d5b4 Bump dockerfile dependencies (#7017) 2024-07-03 20:14:27 +12:00
Jesse Hills
e4e404d54f Merge pull request #7034 from esphome/bump-2024.6.5
2024.6.5
2024-07-03 20:04:18 +12:00
Jesse Hills
995db1d0e1 Bump version to 2024.6.5 2024-07-03 15:45:30 +12:00
Jesse Hills
5cb80619dd [wifi] Only set default ttls phase 2 on esp-idf (#7033)
* [wifi] Only set default ttls phase 2 on esp-idf

* Add eap arduino test
2024-07-03 15:45:30 +12:00
Keith Burzinski
0914dc7198 Move some consts for #4585 (#7023) 2024-07-03 15:45:30 +12:00
Jesse Hills
12f00a9d3d [mpr121] await register parented (#7014)
fixes https://github.com/esphome/issues/issues/5913
2024-07-03 15:45:30 +12:00
Jesse Hills
7b3d6747d5 Merge pull request #7004 from esphome/bump-2024.6.4
2024.6.4
2024-06-27 18:39:53 +12:00
Jesse Hills
7904d3b157 Bump version to 2024.6.4 2024-06-27 17:19:13 +12:00
Markus
3a48b10757 Fix LEDC 100% is not 100% duty with ESP32 IDF (#6997) 2024-06-27 17:19:12 +12:00
Keith Burzinski
0e50cac399 [ota-esphome] Merge configurations by port (#7001) 2024-06-27 17:19:12 +12:00
Jesse Hills
04225d5717 Merge pull request #6994 from esphome/bump-2024.6.3
2024.6.3
2024-06-26 23:17:44 +12:00
Jesse Hills
86791422f0 Bump version to 2024.6.3 2024-06-26 22:41:48 +12:00
Sergey Dudanov
9c2af6318c [modbus-text-sensor] fix potential buffer overflow (#6993) 2024-06-26 22:41:48 +12:00
Samuel Sieb
c747d7d45d [dallas_temp] fix ds18s20 temp calc (#6988) 2024-06-26 22:41:48 +12:00
Petapton
bbd7c9cf86 Fix float encoding in modbus server (#6986) 2024-06-26 22:41:48 +12:00
Pieter Viljoen
169fb79c97 [ds1307] Initialize uninitialized struct members (#6985) 2024-06-26 22:41:48 +12:00
Kevin P. Fleming
1579dfeb80 Improve 'body' handling in http_request on_response triggers (#6968) 2024-06-26 22:41:48 +12:00
Keith Burzinski
d8a6d8594a [ota-esphome] Validate for multiple esphome ota instances (#6984) 2024-06-26 22:41:48 +12:00
Jesse Hills
7be071a0e9 [safe_mode] Set safe mode core data in disabled cases (#6983) 2024-06-26 22:41:47 +12:00
Jesse Hills
0262a99274 Merge pull request #6981 from esphome/bump-2024.6.2
2024.6.2
2024-06-25 13:45:15 +12:00
Jesse Hills
09a947beaa Bump version to 2024.6.2 2024-06-25 08:57:38 +12:00
Sergey Dudanov
a6e1ef2dd1 [midea] fix fan speed compatibility with some models (#6978) 2024-06-25 08:57:38 +12:00
Samuel Sieb
c5aae8ee25 fix potential hang (#6976)
Co-authored-by: Samuel Sieb <samuel@sieb.net>
2024-06-25 08:57:38 +12:00
Brian Kaufman
5bd5b777a6 Await cg.get_variable in Update component (#6974) 2024-06-25 08:57:38 +12:00
Gábor Poczkodi
e39961f7f1 [http_request] memory leak fix (#6973) 2024-06-25 08:57:38 +12:00
Samuel Sieb
0d3cf5cb78 Onewire (#6967)
* retry scan

* setup pin and log retries

* fix retries

* remove retries

---------

Co-authored-by: Samuel Sieb <samuel@sieb.net>
2024-06-25 08:57:37 +12:00
Kevin P. Fleming
96d63de292 ESP-IDF 4.x expects seconds for esp_task_wdt_init(), not milliseconds. (#6964) 2024-06-25 08:57:37 +12:00
Kevin P. Fleming
ae2962259e Fix infinite loop in http_request for ESP-IDF. (#6963) 2024-06-25 08:57:37 +12:00
Jesse Hills
7dbc20b776 [update] Set entity_category to config & Publish state to logs (#6954) 2024-06-25 08:57:37 +12:00
Jesse Hills
a21dab334c [core] Fix package merging with lists of primitives (#6952) 2024-06-25 08:57:37 +12:00
Jesse Hills
1863523cfd Merge pull request #6946 from esphome/bump-2024.6.1
2024.6.1
2024-06-20 17:05:37 +12:00
Jesse Hills
a7a9eb6f71 Bump version to 2024.6.1 2024-06-20 15:59:27 +12:00
Jesse Hills
c868dae44a Bump esphome-dashboard to 20240620.0 (#6944) 2024-06-20 15:59:27 +12:00
Cossid
ad8cf69897 debug_libretiny - Fix typo (#6942) 2024-06-20 15:59:27 +12:00
Jesse Hills
0fe18a6144 Merge pull request #6940 from esphome/bump-2024.6.0
2024.6.0
2024-06-20 08:26:41 +12:00
Jesse Hills
a6d1aa91de Bump version to 2024.6.0 2024-06-19 21:52:47 +12:00
Jesse Hills
9747811b82 Merge pull request #6938 from esphome/bump-2024.6.0b5
2024.6.0b5
2024-06-19 18:19:14 +12:00
Jesse Hills
ff803aa108 Rename test files 2024-06-19 16:37:33 +12:00
Jesse Hills
8bac82f804 Bump version to 2024.6.0b5 2024-06-19 15:37:43 +12:00
Jesse Hills
6682451ee0 [network] Default ipv6 to false to always set the flags (#6937)
* [network] Default ipv6 to false to always set the flags

* Separate tests for ipv6 disabled and enabled

* Forgot other platforms wouldnt have the variable in config
2024-06-19 15:37:43 +12:00
dependabot[bot]
c17090c1e5 Bump docker/build-push-action from 6.0.0 to 6.0.1 in /.github/actions/build-image (#6934)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-19 15:37:43 +12:00
dependabot[bot]
acf69bb56f Bump docker/build-push-action from 5.4.0 to 6.0.0 in /.github/actions/build-image (#6927)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-19 15:37:43 +12:00
dependabot[bot]
fd7a212562 Bump pypa/gh-action-pypi-publish from 1.8.14 to 1.9.0 (#6926)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-19 15:37:43 +12:00
Jesse Hills
c053a33fe8 Merge pull request #6930 from esphome/bump-2024.6.0b4
2024.6.0b4
2024-06-18 16:12:04 +12:00
Jesse Hills
ff07637dfd Bump version to 2024.6.0b4 2024-06-18 14:26:24 +12:00
Jesse Hills
43b5c2deb7 Rename legacy/modern to ota/factory (#6922)
* Rename legacy/modern to ota/factory

* Add modern/legacy in brackets
2024-06-18 14:26:24 +12:00
Jesse Hills
d27e7b3b70 [wifi] Fix some access point bugs related to esp-idf 4.4.7 (#6928)
* Set dhcp server range to only 10 IPs

* Change log level to errors to make it clearer

* We want to stop the dhcp server, not client
2024-06-18 14:26:24 +12:00
Giel van Schijndel
5dec62bf1e fix(dallas): make recovery time for 1-bit equal to that of 0-bit (#6763) 2024-06-18 14:26:24 +12:00
50 changed files with 369 additions and 143 deletions

View File

@@ -46,7 +46,7 @@ runs:
- name: Build and push to ghcr by digest - name: Build and push to ghcr by digest
id: build-ghcr id: build-ghcr
uses: docker/build-push-action@v5.4.0 uses: docker/build-push-action@v6.0.1
with: with:
context: . context: .
file: ./docker/Dockerfile file: ./docker/Dockerfile
@@ -69,7 +69,7 @@ runs:
- name: Build and push to dockerhub by digest - name: Build and push to dockerhub by digest
id: build-dockerhub id: build-dockerhub
uses: docker/build-push-action@v5.4.0 uses: docker/build-push-action@v6.0.1
with: with:
context: . context: .
file: ./docker/Dockerfile file: ./docker/Dockerfile

View File

@@ -65,7 +65,7 @@ jobs:
pip3 install build pip3 install build
python3 -m build python3 -m build
- name: Publish - name: Publish
uses: pypa/gh-action-pypi-publish@v1.8.14 uses: pypa/gh-action-pypi-publish@v1.9.0
deploy-docker: deploy-docker:
name: Build ESPHome ${{ matrix.platform }} name: Build ESPHome ${{ matrix.platform }}

View File

@@ -34,28 +34,32 @@ RUN \
python3-wheel=0.38.4-2 \ python3-wheel=0.38.4-2 \
iputils-ping=3:20221126-1 \ iputils-ping=3:20221126-1 \
git=1:2.39.2-1.1 \ git=1:2.39.2-1.1 \
curl=7.88.1-10+deb12u5 \ curl=7.88.1-10+deb12u6 \
openssh-client=1:9.2p1-2+deb12u2 \ openssh-client=1:9.2p1-2+deb12u2 \
python3-cffi=1.15.1-5 \ python3-cffi=1.15.1-5 \
libcairo2=1.16.0-7 \ libcairo2=1.16.0-7 \
libmagic1=1:5.44-3 \ libmagic1=1:5.44-3 \
patch=2.7.6-7; \ patch=2.7.6-7 \
if [ "$TARGETARCH$TARGETVARIANT" = "armv7" ]; then \ && ( \
apt-get install -y --no-install-recommends \ ( \
build-essential=12.9 \ [ "$TARGETARCH$TARGETVARIANT" = "armv7" ] && \
python3-dev=3.11.2-1+b1 \ apt-get install -y --no-install-recommends \
zlib1g-dev=1:1.2.13.dfsg-1 \ build-essential=12.9 \
libjpeg-dev=1:2.1.5-2 \ python3-dev=3.11.2-1+b1 \
libfreetype-dev=2.12.1+dfsg-5 \ zlib1g-dev=1:1.2.13.dfsg-1 \
libssl-dev=3.0.11-1~deb12u2 \ libjpeg-dev=1:2.1.5-2 \
libffi-dev=3.4.4-1 \ libfreetype-dev=2.12.1+dfsg-5+deb12u3 \
libopenjp2-7=2.5.0-2 \ libssl-dev=3.0.13-1~deb12u1 \
libtiff6=4.5.0-6+deb12u1 \ libffi-dev=3.4.4-1 \
cargo=0.66.0+ds1-1 \ libopenjp2-7=2.5.0-2 \
pkg-config=1.8.1-1 \ libtiff6=4.5.0-6+deb12u1 \
gcc-arm-linux-gnueabihf=4:12.2.0-3; \ cargo=0.66.0+ds1-1 \
fi; \ pkg-config=1.8.1-1 \
rm -rf \ gcc-arm-linux-gnueabihf=4:12.2.0-3 \
) \
|| [ "$TARGETARCH$TARGETVARIANT" != "armv7" ] \
) \
&& rm -rf \
/tmp/* \ /tmp/* \
/var/{cache,log}/* \ /var/{cache,log}/* \
/var/lib/apt/lists/* /var/lib/apt/lists/*
@@ -190,8 +194,8 @@ RUN \
clang-format-13=1:13.0.1-11+b2 \ clang-format-13=1:13.0.1-11+b2 \
clang-tidy-14=1:14.0.6-12 \ clang-tidy-14=1:14.0.6-12 \
patch=2.7.6-7 \ patch=2.7.6-7 \
software-properties-common=0.99.30-4 \ software-properties-common=0.99.30-4.1~deb12u1 \
nano=7.2-1 \ nano=7.2-1+deb12u1 \
build-essential=12.9 \ build-essential=12.9 \
python3-dev=3.11.2-1+b1 \ python3-dev=3.11.2-1+b1 \
&& rm -rf \ && rm -rf \

View File

@@ -60,6 +60,7 @@ from esphome.cpp_types import ( # noqa
std_ns, std_ns,
std_shared_ptr, std_shared_ptr,
std_string, std_string,
std_string_ref,
std_vector, std_vector,
uint8, uint8,
uint16, uint16,

View File

@@ -1,7 +1,7 @@
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.components import i2c, esp32 from esphome.components import i2c, esp32
from esphome.const import CONF_ID, CONF_TEMPERATURE_OFFSET from esphome.const import CONF_ID, CONF_SAMPLE_RATE, CONF_TEMPERATURE_OFFSET
CODEOWNERS = ["@trvrnrth"] CODEOWNERS = ["@trvrnrth"]
DEPENDENCIES = ["i2c"] DEPENDENCIES = ["i2c"]
@@ -11,7 +11,6 @@ MULTI_CONF = True
CONF_BME680_BSEC_ID = "bme680_bsec_id" CONF_BME680_BSEC_ID = "bme680_bsec_id"
CONF_IAQ_MODE = "iaq_mode" CONF_IAQ_MODE = "iaq_mode"
CONF_SUPPLY_VOLTAGE = "supply_voltage" CONF_SUPPLY_VOLTAGE = "supply_voltage"
CONF_SAMPLE_RATE = "sample_rate"
CONF_STATE_SAVE_INTERVAL = "state_save_interval" CONF_STATE_SAVE_INTERVAL = "state_save_interval"
bme680_bsec_ns = cg.esphome_ns.namespace("bme680_bsec") bme680_bsec_ns = cg.esphome_ns.namespace("bme680_bsec")

View File

@@ -4,33 +4,33 @@ from esphome.components import sensor
from esphome.const import ( from esphome.const import (
CONF_GAS_RESISTANCE, CONF_GAS_RESISTANCE,
CONF_HUMIDITY, CONF_HUMIDITY,
CONF_IAQ_ACCURACY,
CONF_PRESSURE, CONF_PRESSURE,
CONF_SAMPLE_RATE,
CONF_TEMPERATURE, CONF_TEMPERATURE,
DEVICE_CLASS_ATMOSPHERIC_PRESSURE,
DEVICE_CLASS_CARBON_DIOXIDE, DEVICE_CLASS_CARBON_DIOXIDE,
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
DEVICE_CLASS_ATMOSPHERIC_PRESSURE,
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TEMPERATURE,
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS_PARTS,
ICON_GAS_CYLINDER,
ICON_GAUGE,
STATE_CLASS_MEASUREMENT, STATE_CLASS_MEASUREMENT,
UNIT_CELSIUS, UNIT_CELSIUS,
UNIT_HECTOPASCAL, UNIT_HECTOPASCAL,
UNIT_OHM, UNIT_OHM,
UNIT_PARTS_PER_MILLION, UNIT_PARTS_PER_MILLION,
UNIT_PERCENT, UNIT_PERCENT,
ICON_GAS_CYLINDER,
ICON_GAUGE,
) )
from . import ( from . import (
BME680BSECComponent, BME680BSECComponent,
CONF_BME680_BSEC_ID, CONF_BME680_BSEC_ID,
CONF_SAMPLE_RATE,
SAMPLE_RATE_OPTIONS, SAMPLE_RATE_OPTIONS,
) )
DEPENDENCIES = ["bme680_bsec"] DEPENDENCIES = ["bme680_bsec"]
CONF_IAQ = "iaq" CONF_IAQ = "iaq"
CONF_IAQ_ACCURACY = "iaq_accuracy"
CONF_CO2_EQUIVALENT = "co2_equivalent" CONF_CO2_EQUIVALENT = "co2_equivalent"
CONF_BREATH_VOC_EQUIVALENT = "breath_voc_equivalent" CONF_BREATH_VOC_EQUIVALENT = "breath_voc_equivalent"
UNIT_IAQ = "IAQ" UNIT_IAQ = "IAQ"

View File

@@ -1,11 +1,11 @@
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv import esphome.config_validation as cv
from esphome.components import text_sensor from esphome.components import text_sensor
from esphome.const import CONF_IAQ_ACCURACY
from . import BME680BSECComponent, CONF_BME680_BSEC_ID from . import BME680BSECComponent, CONF_BME680_BSEC_ID
DEPENDENCIES = ["bme680_bsec"] DEPENDENCIES = ["bme680_bsec"]
CONF_IAQ_ACCURACY = "iaq_accuracy"
ICON_ACCURACY = "mdi:checkbox-marked-circle-outline" ICON_ACCURACY = "mdi:checkbox-marked-circle-outline"
TYPES = [CONF_IAQ_ACCURACY] TYPES = [CONF_IAQ_ACCURACY]

View File

@@ -145,24 +145,21 @@ bool DallasTemperatureSensor::check_scratch_pad_() {
float DallasTemperatureSensor::get_temp_c_() { float DallasTemperatureSensor::get_temp_c_() {
int16_t temp = (this->scratch_pad_[1] << 8) | this->scratch_pad_[0]; int16_t temp = (this->scratch_pad_[1] << 8) | this->scratch_pad_[0];
if ((this->address_ & 0xff) == DALLAS_MODEL_DS18S20) { if ((this->address_ & 0xff) == DALLAS_MODEL_DS18S20) {
if (this->scratch_pad_[7] != 0x10) return (temp >> 1) + (this->scratch_pad_[7] - this->scratch_pad_[6]) / float(this->scratch_pad_[7]) - 0.25;
ESP_LOGE(TAG, "unexpected COUNT_PER_C value: %u", this->scratch_pad_[7]); }
temp = ((temp & 0xfff7) << 3) + (0x10 - this->scratch_pad_[6]) - 4; switch (this->resolution_) {
} else { case 9:
switch (this->resolution_) { temp &= 0xfff8;
case 9: break;
temp &= 0xfff8; case 10:
break; temp &= 0xfffc;
case 10: break;
temp &= 0xfffc; case 11:
break; temp &= 0xfffe;
case 11: break;
temp &= 0xfffe; case 12:
break; default:
case 12: break;
default:
break;
}
} }
return temp / 16.0f; return temp / 16.0f;

View File

@@ -12,7 +12,7 @@ std::string DebugComponent::get_reset_reason_() { return lt_get_reboot_reason_na
uint32_t DebugComponent::get_free_heap_() { return lt_heap_get_free(); } uint32_t DebugComponent::get_free_heap_() { return lt_heap_get_free(); }
void DebugComponent::get_device_info_(std::string &device_info) { void DebugComponent::get_device_info_(std::string &device_info) {
str::string reset_reason = get_reset_reason_(); std::string reset_reason = get_reset_reason_();
ESP_LOGD(TAG, "LibreTiny Version: %s", lt_get_version()); ESP_LOGD(TAG, "LibreTiny Version: %s", lt_get_version());
ESP_LOGD(TAG, "Chip: %s (%04x) @ %u MHz", lt_cpu_get_model_name(), lt_cpu_get_model(), lt_cpu_get_freq_mhz()); ESP_LOGD(TAG, "Chip: %s (%04x) @ %u MHz", lt_cpu_get_model_name(), lt_cpu_get_model(), lt_cpu_get_freq_mhz());
ESP_LOGD(TAG, "Chip ID: 0x%06X", lt_cpu_get_mac_id()); ESP_LOGD(TAG, "Chip ID: 0x%06X", lt_cpu_get_mac_id());

View File

@@ -37,14 +37,18 @@ void DS1307Component::read_time() {
ESP_LOGW(TAG, "RTC halted, not syncing to system clock."); ESP_LOGW(TAG, "RTC halted, not syncing to system clock.");
return; return;
} }
ESPTime rtc_time{.second = uint8_t(ds1307_.reg.second + 10 * ds1307_.reg.second_10), ESPTime rtc_time{
.minute = uint8_t(ds1307_.reg.minute + 10u * ds1307_.reg.minute_10), .second = uint8_t(ds1307_.reg.second + 10 * ds1307_.reg.second_10),
.hour = uint8_t(ds1307_.reg.hour + 10u * ds1307_.reg.hour_10), .minute = uint8_t(ds1307_.reg.minute + 10u * ds1307_.reg.minute_10),
.day_of_week = uint8_t(ds1307_.reg.weekday), .hour = uint8_t(ds1307_.reg.hour + 10u * ds1307_.reg.hour_10),
.day_of_month = uint8_t(ds1307_.reg.day + 10u * ds1307_.reg.day_10), .day_of_week = uint8_t(ds1307_.reg.weekday),
.day_of_year = 1, // ignored by recalc_timestamp_utc(false) .day_of_month = uint8_t(ds1307_.reg.day + 10u * ds1307_.reg.day_10),
.month = uint8_t(ds1307_.reg.month + 10u * ds1307_.reg.month_10), .day_of_year = 1, // ignored by recalc_timestamp_utc(false)
.year = uint16_t(ds1307_.reg.year + 10u * ds1307_.reg.year_10 + 2000)}; .month = uint8_t(ds1307_.reg.month + 10u * ds1307_.reg.month_10),
.year = uint16_t(ds1307_.reg.year + 10u * ds1307_.reg.year_10 + 2000),
.is_dst = false, // not used
.timestamp = 0 // overwritten by recalc_timestamp_utc(false)
};
rtc_time.recalc_timestamp_utc(false); rtc_time.recalc_timestamp_utc(false);
if (!rtc_time.is_valid()) { if (!rtc_time.is_valid()) {
ESP_LOGE(TAG, "Invalid RTC time, not syncing to system clock."); ESP_LOGE(TAG, "Invalid RTC time, not syncing to system clock.");

View File

@@ -96,16 +96,16 @@ def get_board(core_obj=None):
def get_download_types(storage_json): def get_download_types(storage_json):
return [ return [
{ {
"title": "Modern format", "title": "Factory format (Previously Modern)",
"description": "For use with ESPHome Web and other tools.", "description": "For use with ESPHome Web and other tools.",
"file": "firmware-factory.bin", "file": "firmware.factory.bin",
"download": f"{storage_json.name}-factory.bin", "download": f"{storage_json.name}.factory.bin",
}, },
{ {
"title": "Legacy format", "title": "OTA format (Previously Legacy)",
"description": "For use with ESPHome Flasher.", "description": "For OTA updating a device.",
"file": "firmware.bin", "file": "firmware.ota.bin",
"download": f"{storage_json.name}.bin", "download": f"{storage_json.name}.ota.bin",
}, },
] ]

View File

@@ -17,17 +17,19 @@ from SCons.Script import ARGUMENTS
# Copy over the default sdkconfig. # Copy over the default sdkconfig.
from os import path from os import path
if path.exists("./sdkconfig.defaults"): if path.exists("./sdkconfig.defaults"):
os.makedirs(".temp", exist_ok=True) os.makedirs(".temp", exist_ok=True)
shutil.copy("./sdkconfig.defaults", "./.temp/sdkconfig-esp32-idf") shutil.copy("./sdkconfig.defaults", "./.temp/sdkconfig-esp32-idf")
def esp32_create_combined_bin(source, target, env): def esp32_create_combined_bin(source, target, env):
verbose = bool(int(ARGUMENTS.get("PIOVERBOSE", "0"))) verbose = bool(int(ARGUMENTS.get("PIOVERBOSE", "0")))
if verbose: if verbose:
print("Generating combined binary for serial flashing") print("Generating combined binary for serial flashing")
app_offset = 0x10000 app_offset = 0x10000
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}-factory.bin") new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin")
sections = env.subst(env.get("FLASH_EXTRA_IMAGES")) sections = env.subst(env.get("FLASH_EXTRA_IMAGES"))
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin") firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
chip = env.get("BOARD_MCU") chip = env.get("BOARD_MCU")
@@ -62,5 +64,14 @@ def esp32_create_combined_bin(source, target, env):
else: else:
subprocess.run(["esptool.py", *cmd]) subprocess.run(["esptool.py", *cmd])
def esp32_copy_ota_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
shutil.copyfile(firmware_name, new_file_name)
# pylint: disable=E0602 # pylint: disable=E0602
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) # noqa env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) # noqa
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_copy_ota_bin) # noqa

View File

@@ -6,10 +6,18 @@ Import("env") # noqa
def esp8266_copy_factory_bin(source, target, env): def esp8266_copy_factory_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin") firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}-factory.bin") new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin")
shutil.copyfile(firmware_name, new_file_name)
def esp8266_copy_ota_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
shutil.copyfile(firmware_name, new_file_name) shutil.copyfile(firmware_name, new_file_name)
# pylint: disable=E0602 # pylint: disable=E0602
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_factory_bin) # noqa env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_factory_bin) # noqa
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp8266_copy_ota_bin) # noqa

View File

@@ -1,10 +1,17 @@
import logging
import esphome.codegen as cg import esphome.codegen as cg
import esphome.config_validation as cv 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, ota_to_code, OTAComponent
from esphome.config_helpers import merge_config
from esphome.const import ( from esphome.const import (
CONF_ESPHOME,
CONF_ID, CONF_ID,
CONF_NUM_ATTEMPTS, CONF_NUM_ATTEMPTS,
CONF_OTA,
CONF_PASSWORD, CONF_PASSWORD,
CONF_PLATFORM,
CONF_PORT, CONF_PORT,
CONF_REBOOT_TIMEOUT, CONF_REBOOT_TIMEOUT,
CONF_SAFE_MODE, CONF_SAFE_MODE,
@@ -12,6 +19,8 @@ from esphome.const import (
) )
from esphome.core import coroutine_with_priority from esphome.core import coroutine_with_priority
_LOGGER = logging.getLogger(__name__)
CODEOWNERS = ["@esphome/core"] CODEOWNERS = ["@esphome/core"]
AUTO_LOAD = ["md5", "socket"] AUTO_LOAD = ["md5", "socket"]
@@ -21,6 +30,65 @@ esphome = cg.esphome_ns.namespace("esphome")
ESPHomeOTAComponent = esphome.class_("ESPHomeOTAComponent", OTAComponent) ESPHomeOTAComponent = esphome.class_("ESPHomeOTAComponent", OTAComponent)
def ota_esphome_final_validate(config):
full_conf = fv.full_config.get()
full_ota_conf = full_conf[CONF_OTA]
new_ota_conf = []
merged_ota_esphome_configs_by_port = {}
ports_with_merged_configs = []
for ota_conf in full_ota_conf:
if ota_conf.get(CONF_PLATFORM) == CONF_ESPHOME:
if (
conf_port := ota_conf.get(CONF_PORT)
) not in merged_ota_esphome_configs_by_port:
merged_ota_esphome_configs_by_port[conf_port] = ota_conf
else:
if merged_ota_esphome_configs_by_port[conf_port][
CONF_VERSION
] != ota_conf.get(CONF_VERSION):
raise cv.Invalid(
f"Found multiple configurations but {CONF_VERSION} is inconsistent"
)
if (
merged_ota_esphome_configs_by_port[conf_port][CONF_ID].is_manual
and ota_conf.get(CONF_ID).is_manual
):
raise cv.Invalid(
f"Found multiple configurations but {CONF_ID} is inconsistent"
)
if (
CONF_PASSWORD in merged_ota_esphome_configs_by_port[conf_port]
and CONF_PASSWORD in ota_conf
and merged_ota_esphome_configs_by_port[conf_port][CONF_PASSWORD]
!= ota_conf.get(CONF_PASSWORD)
):
raise cv.Invalid(
f"Found multiple configurations but {CONF_PASSWORD} is inconsistent"
)
ports_with_merged_configs.append(conf_port)
merged_ota_esphome_configs_by_port[conf_port] = merge_config(
merged_ota_esphome_configs_by_port[conf_port], ota_conf
)
else:
new_ota_conf.append(ota_conf)
for port_conf in merged_ota_esphome_configs_by_port.values():
new_ota_conf.append(port_conf)
full_conf[CONF_OTA] = new_ota_conf
fv.full_config.set(full_conf)
if len(ports_with_merged_configs) > 0:
_LOGGER.warning(
"Found and merged multiple configurations for %s %s %s port(s) %s",
CONF_OTA,
CONF_PLATFORM,
CONF_ESPHOME,
ports_with_merged_configs,
)
CONFIG_SCHEMA = ( CONFIG_SCHEMA = (
cv.Schema( cv.Schema(
{ {
@@ -50,6 +118,8 @@ CONFIG_SCHEMA = (
.extend(cv.COMPONENT_SCHEMA) .extend(cv.COMPONENT_SCHEMA)
) )
FINAL_VALIDATE_SCHEMA = ota_esphome_final_validate
@coroutine_with_priority(52.0) @coroutine_with_priority(52.0)
async def to_code(config): async def to_code(config):

View File

@@ -9,6 +9,10 @@ static const char *const TAG = "gpio.one_wire";
void GPIOOneWireBus::setup() { void GPIOOneWireBus::setup() {
ESP_LOGCONFIG(TAG, "Setting up 1-wire bus..."); ESP_LOGCONFIG(TAG, "Setting up 1-wire bus...");
this->t_pin_->setup();
// clear bus with 480µs high, otherwise initial reset in search might fail
this->t_pin_->pin_mode(gpio::FLAG_INPUT | gpio::FLAG_PULLUP);
delayMicroseconds(480);
this->search(); this->search();
} }
@@ -60,7 +64,7 @@ void HOT IRAM_ATTR GPIOOneWireBus::write_bit_(bool bit) {
// recovery time: t_rec: min=1µs // recovery time: t_rec: min=1µs
// ds18b20 appears to read the bus after roughly 14µs // ds18b20 appears to read the bus after roughly 14µs
uint32_t delay0 = bit ? 6 : 60; uint32_t delay0 = bit ? 6 : 60;
uint32_t delay1 = bit ? 54 : 5; uint32_t delay1 = bit ? 59 : 5;
// delay A/C // delay A/C
delayMicroseconds(delay0); delayMicroseconds(delay0);
@@ -90,13 +94,15 @@ bool HOT IRAM_ATTR GPIOOneWireBus::read_bit_() {
// measure from start value directly, to get best accurate timing no matter // measure from start value directly, to get best accurate timing no matter
// how long pin_mode/delayMicroseconds took // how long pin_mode/delayMicroseconds took
delayMicroseconds(12 - (micros() - start)); uint32_t now = micros();
if (now - start < 12)
delayMicroseconds(12 - (now - start));
// sample bus to read bit from peer // sample bus to read bit from peer
bool r = pin_.digital_read(); bool r = pin_.digital_read();
// read slot is at least 60µs; get as close to 60µs to spend less time with interrupts locked // read slot is at least 60µs; get as close to 60µs to spend less time with interrupts locked
uint32_t now = micros(); now = micros();
if (now - start < 60) if (now - start < 60)
delayMicroseconds(60 - (now - start)); delayMicroseconds(60 - (now - start));

View File

@@ -257,7 +257,7 @@ async def http_request_action_to_code(config, action_id, template_arg, args):
trigger, trigger,
[ [
(cg.std_shared_ptr.template(HttpContainer), "response"), (cg.std_shared_ptr.template(HttpContainer), "response"),
(cg.std_string, "body"), (cg.std_string_ref, "body"),
], ],
conf, conf,
) )

View File

@@ -43,10 +43,10 @@ class HttpContainer : public Parented<HttpRequestComponent> {
bool secure_{false}; bool secure_{false};
}; };
class HttpRequestResponseTrigger : public Trigger<std::shared_ptr<HttpContainer>, std::string> { class HttpRequestResponseTrigger : public Trigger<std::shared_ptr<HttpContainer>, std::string &> {
public: public:
void process(std::shared_ptr<HttpContainer> container, std::string response_body) { void process(std::shared_ptr<HttpContainer> container, std::string &response_body) {
this->trigger(std::move(container), std::move(response_body)); this->trigger(std::move(container), response_body);
} }
}; };
@@ -149,11 +149,21 @@ template<typename... Ts> class HttpRequestSendAction : public Action<Ts...> {
} }
response_body.reserve(read_index); response_body.reserve(read_index);
response_body.assign((char *) buf, read_index); response_body.assign((char *) buf, read_index);
allocator.deallocate(buf, max_length);
} }
} }
for (auto *trigger : this->response_triggers_) { if (this->response_triggers_.size() == 1) {
trigger->process(container, response_body); // if there is only one trigger, no need to copy the response body
this->response_triggers_[0]->process(container, response_body);
} else {
for (auto *trigger : this->response_triggers_) {
// with multiple triggers, pass a copy of the response body to each
// one so that modifications made in one trigger are not visible to
// the others
auto response_body_copy = std::string(response_body);
trigger->process(container, response_body_copy);
}
} }
container->end(); container->end();
} }

View File

@@ -90,7 +90,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
int write_left = body_len; int write_left = body_len;
int write_index = 0; int write_index = 0;
const char *buf = body.c_str(); const char *buf = body.c_str();
while (body_len > 0) { while (write_left > 0) {
int written = esp_http_client_write(client, buf + write_index, write_left); int written = esp_http_client_write(client, buf + write_index, write_left);
if (written < 0) { if (written < 0) {
err = ESP_FAIL; err = ESP_FAIL;

View File

@@ -46,7 +46,7 @@ void WatchdogManager::set_timeout_(uint32_t timeout_ms) {
}; };
esp_task_wdt_reconfigure(&wdt_config); esp_task_wdt_reconfigure(&wdt_config);
#else #else
esp_task_wdt_init(timeout_ms, true); esp_task_wdt_init(timeout_ms / 1000, true);
#endif // ESP_IDF_VERSION_MAJOR #endif // ESP_IDF_VERSION_MAJOR
#endif // USE_ESP32 #endif // USE_ESP32

View File

@@ -2,7 +2,7 @@ import esphome.config_validation as cv
import esphome.codegen as cg import esphome.codegen as cg
from esphome import pins from esphome import pins
from esphome.const import CONF_CHANNEL, CONF_ID, CONF_NUMBER from esphome.const import CONF_CHANNEL, CONF_ID, CONF_NUMBER, CONF_SAMPLE_RATE
from esphome.components import microphone, esp32 from esphome.components import microphone, esp32
from esphome.components.adc import ESP32_VARIANT_ADC1_PIN_TO_CHANNEL, validate_adc_pin from esphome.components.adc import ESP32_VARIANT_ADC1_PIN_TO_CHANNEL, validate_adc_pin
@@ -20,7 +20,6 @@ DEPENDENCIES = ["i2s_audio"]
CONF_ADC_PIN = "adc_pin" CONF_ADC_PIN = "adc_pin"
CONF_ADC_TYPE = "adc_type" CONF_ADC_TYPE = "adc_type"
CONF_PDM = "pdm" CONF_PDM = "pdm"
CONF_SAMPLE_RATE = "sample_rate"
CONF_BITS_PER_SAMPLE = "bits_per_sample" CONF_BITS_PER_SAMPLE = "bits_per_sample"
CONF_USE_APLL = "use_apll" CONF_USE_APLL = "use_apll"

View File

@@ -115,12 +115,15 @@ void LEDCOutput::write_state(float state) {
const uint32_t max_duty = (uint32_t(1) << this->bit_depth_) - 1; const uint32_t max_duty = (uint32_t(1) << this->bit_depth_) - 1;
const float duty_rounded = roundf(state * max_duty); const float duty_rounded = roundf(state * max_duty);
auto duty = static_cast<uint32_t>(duty_rounded); auto duty = static_cast<uint32_t>(duty_rounded);
#ifdef USE_ARDUINO #ifdef USE_ARDUINO
ESP_LOGV(TAG, "Setting duty: %u on channel %u", duty, this->channel_); ESP_LOGV(TAG, "Setting duty: %u on channel %u", duty, this->channel_);
ledcWrite(this->channel_, duty); ledcWrite(this->channel_, duty);
#endif #endif
#ifdef USE_ESP_IDF #ifdef USE_ESP_IDF
// ensure that 100% on is not 99.975% on
if ((duty == max_duty) && (max_duty != 1)) {
duty = max_duty + 1;
}
auto speed_mode = get_speed_mode(channel_); auto speed_mode = get_speed_mode(channel_);
auto chan_num = static_cast<ledc_channel_t>(channel_ % 8); auto chan_num = static_cast<ledc_channel_t>(channel_ % 8);
int hpoint = ledc_angle_to_htop(this->phase_angle_, this->bit_depth_); int hpoint = ledc_angle_to_htop(this->phase_angle_, this->bit_depth_);

View File

@@ -293,4 +293,4 @@ async def to_code(config):
if CONF_HUMIDITY_SETPOINT in config: if CONF_HUMIDITY_SETPOINT in config:
sens = await sensor.new_sensor(config[CONF_HUMIDITY_SETPOINT]) sens = await sensor.new_sensor(config[CONF_HUMIDITY_SETPOINT])
cg.add(var.set_humidity_setpoint_sensor(sens)) cg.add(var.set_humidity_setpoint_sensor(sens))
cg.add_library("dudanov/MideaUART", "1.1.8") cg.add_library("dudanov/MideaUART", "1.1.9")

View File

@@ -116,7 +116,8 @@ void ModbusController::on_modbus_read_registers(uint8_t function_code, uint16_t
ESP_LOGD(TAG, "Matched register. Address: 0x%02X. Value type: %zu. Register count: %u. Value: %0.1f.", ESP_LOGD(TAG, "Matched register. Address: 0x%02X. Value type: %zu. Register count: %u. Value: %0.1f.",
server_register->address, static_cast<uint8_t>(server_register->value_type), server_register->address, static_cast<uint8_t>(server_register->value_type),
server_register->register_count, value); server_register->register_count, value);
number_to_payload(sixteen_bit_response, value, server_register->value_type); std::vector<uint16_t> payload = float_to_payload(value, server_register->value_type);
sixteen_bit_response.insert(sixteen_bit_response.end(), payload.cbegin(), payload.cend());
current_address += server_register->register_count; current_address += server_register->register_count;
found = true; found = true;
break; break;

View File

@@ -15,7 +15,7 @@ void ModbusTextSensor::parse_and_publish(const std::vector<uint8_t> &data) {
std::ostringstream output; std::ostringstream output;
uint8_t items_left = this->response_bytes; uint8_t items_left = this->response_bytes;
uint8_t index = this->offset; uint8_t index = this->offset;
char buffer[4]; char buffer[5];
while ((items_left > 0) && index < data.size()) { while ((items_left > 0) && index < data.size()) {
uint8_t b = data[index]; uint8_t b = data[index];
switch (this->encode_) { switch (this->encode_) {

View File

@@ -27,7 +27,7 @@ async def to_code(config):
var = await binary_sensor.new_binary_sensor(config) var = await binary_sensor.new_binary_sensor(config)
hub = await cg.get_variable(config[CONF_MPR121_ID]) hub = await cg.get_variable(config[CONF_MPR121_ID])
cg.add(var.set_channel(config[CONF_CHANNEL])) cg.add(var.set_channel(config[CONF_CHANNEL]))
cg.register_parented(var, hub) await cg.register_parented(var, hub)
if CONF_TOUCH_THRESHOLD in config: if CONF_TOUCH_THRESHOLD in config:
cg.add(var.set_touch_threshold(config[CONF_TOUCH_THRESHOLD])) cg.add(var.set_touch_threshold(config[CONF_TOUCH_THRESHOLD]))

View File

@@ -19,7 +19,12 @@ IPAddress = network_ns.class_("IPAddress")
CONFIG_SCHEMA = cv.Schema( CONFIG_SCHEMA = cv.Schema(
{ {
cv.SplitDefault(CONF_ENABLE_IPV6): cv.All( cv.SplitDefault(
CONF_ENABLE_IPV6,
esp8266=False,
esp32=False,
rp2040=False,
): cv.All(
cv.boolean, cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_RP2040]) cv.boolean, cv.only_on([PLATFORM_ESP32, PLATFORM_ESP8266, PLATFORM_RP2040])
), ),
cv.Optional(CONF_MIN_IPV6_ADDR_COUNT, default=0): cv.positive_int, cv.Optional(CONF_MIN_IPV6_ADDR_COUNT, default=0): cv.positive_int,
@@ -28,18 +33,17 @@ CONFIG_SCHEMA = cv.Schema(
async def to_code(config): async def to_code(config):
if CONF_ENABLE_IPV6 in config: if (enable_ipv6 := config.get(CONF_ENABLE_IPV6, None)) is not None:
cg.add_define("USE_NETWORK_IPV6", config[CONF_ENABLE_IPV6]) cg.add_define("USE_NETWORK_IPV6", enable_ipv6)
cg.add_define( if enable_ipv6:
"USE_NETWORK_MIN_IPV6_ADDR_COUNT", config[CONF_MIN_IPV6_ADDR_COUNT] cg.add_define(
) "USE_NETWORK_MIN_IPV6_ADDR_COUNT", config[CONF_MIN_IPV6_ADDR_COUNT]
if CORE.using_esp_idf:
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", config[CONF_ENABLE_IPV6])
add_idf_sdkconfig_option(
"CONFIG_LWIP_IPV6_AUTOCONFIG", config[CONF_ENABLE_IPV6]
) )
if CORE.using_esp_idf:
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", enable_ipv6)
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6_AUTOCONFIG", enable_ipv6)
else: else:
if config[CONF_ENABLE_IPV6]: if enable_ipv6:
cg.add_build_flag("-DCONFIG_LWIP_IPV6") cg.add_build_flag("-DCONFIG_LWIP_IPV6")
cg.add_build_flag("-DCONFIG_LWIP_IPV6_AUTOCONFIG") cg.add_build_flag("-DCONFIG_LWIP_IPV6_AUTOCONFIG")
if CORE.is_rp2040: if CORE.is_rp2040:

View File

@@ -47,10 +47,16 @@ def set_core_data(config):
def get_download_types(storage_json): def get_download_types(storage_json):
return [ return [
{ {
"title": "UF2 format", "title": "UF2 factory format",
"description": "For copying to RP2040 over USB.", "description": "For copying to RP2040 over USB.",
"file": "firmware.uf2", "file": "firmware.uf2",
"download": f"{storage_json.name}.uf2", "download": f"{storage_json.name}.factory.uf2",
},
{
"title": "OTA format",
"description": "For OTA updating a device.",
"file": "firmware.ota.bin",
"download": f"{storage_json.name}.ota.bin",
}, },
] ]
@@ -160,6 +166,8 @@ async def to_code(config):
cg.add_define("ESPHOME_BOARD", config[CONF_BOARD]) cg.add_define("ESPHOME_BOARD", config[CONF_BOARD])
cg.add_define("ESPHOME_VARIANT", "RP2040") cg.add_define("ESPHOME_VARIANT", "RP2040")
cg.add_platformio_option("extra_scripts", ["post:post_build.py"])
conf = config[CONF_FRAMEWORK] conf = config[CONF_FRAMEWORK]
cg.add_platformio_option("framework", "arduino") cg.add_platformio_option("framework", "arduino")
cg.add_build_flag("-DUSE_ARDUINO") cg.add_build_flag("-DUSE_ARDUINO")
@@ -225,4 +233,10 @@ def generate_pio_files() -> bool:
# Called by writer.py # Called by writer.py
def copy_files() -> bool: def copy_files() -> bool:
dir = os.path.dirname(__file__)
post_build_file = os.path.join(dir, "post_build.py.script")
copy_file_if_changed(
post_build_file,
CORE.relative_build_path("post_build.py"),
)
return generate_pio_files() return generate_pio_files()

View File

@@ -0,0 +1,23 @@
import shutil
# pylint: disable=E0602
Import("env") # noqa
def rp2040_copy_factory_uf2(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.uf2")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.uf2")
shutil.copyfile(firmware_name, new_file_name)
def rp2040_copy_ota_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.ota.bin")
shutil.copyfile(firmware_name, new_file_name)
# pylint: disable=E0602
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", rp2040_copy_factory_uf2) # noqa
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", rp2040_copy_ota_bin) # noqa

View File

@@ -56,21 +56,20 @@ CONFIG_SCHEMA = cv.All(
@coroutine_with_priority(50.0) @coroutine_with_priority(50.0)
async def to_code(config): async def to_code(config):
if config[CONF_DISABLED]: if not config[CONF_DISABLED]:
return var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
var = cg.new_Pvariable(config[CONF_ID]) for conf in config.get(CONF_ON_SAFE_MODE, []):
await cg.register_component(var, config) trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var)
await automation.build_automation(trigger, [], conf)
for conf in config.get(CONF_ON_SAFE_MODE, []): condition = var.should_enter_safe_mode(
trigger = cg.new_Pvariable(conf[CONF_TRIGGER_ID], var) config[CONF_NUM_ATTEMPTS],
await automation.build_automation(trigger, [], conf) config[CONF_REBOOT_TIMEOUT],
config[CONF_BOOT_IS_GOOD_AFTER],
)
cg.add(RawExpression(f"if ({condition}) return"))
condition = var.should_enter_safe_mode(
config[CONF_NUM_ATTEMPTS],
config[CONF_REBOOT_TIMEOUT],
config[CONF_BOOT_IS_GOOD_AFTER],
)
cg.add(RawExpression(f"if ({condition}) return"))
CORE.data[CONF_SAFE_MODE] = {} CORE.data[CONF_SAFE_MODE] = {}
CORE.data[CONF_SAFE_MODE][KEY_PAST_SAFE_MODE] = True CORE.data[CONF_SAFE_MODE][KEY_PAST_SAFE_MODE] = True

View File

@@ -4,11 +4,13 @@ import esphome.config_validation as cv
import esphome.codegen as cg import esphome.codegen as cg
from esphome.const import ( from esphome.const import (
CONF_DEVICE_CLASS, CONF_DEVICE_CLASS,
CONF_ENTITY_CATEGORY,
CONF_ID, CONF_ID,
CONF_MQTT_ID, CONF_MQTT_ID,
CONF_WEB_SERVER_ID, CONF_WEB_SERVER_ID,
DEVICE_CLASS_EMPTY, DEVICE_CLASS_EMPTY,
DEVICE_CLASS_FIRMWARE, DEVICE_CLASS_FIRMWARE,
ENTITY_CATEGORY_CONFIG,
) )
from esphome.core import CORE, coroutine_with_priority from esphome.core import CORE, coroutine_with_priority
from esphome.cpp_helpers import setup_entity from esphome.cpp_helpers import setup_entity
@@ -41,6 +43,9 @@ UPDATE_SCHEMA = (
cv.Optional(CONF_ON_UPDATE_AVAILABLE): automation.validate_automation( cv.Optional(CONF_ON_UPDATE_AVAILABLE): automation.validate_automation(
single=True single=True
), ),
cv.Optional(
CONF_ENTITY_CATEGORY, default=ENTITY_CATEGORY_CONFIG
): cv.entity_category,
} }
) )
) )
@@ -64,7 +69,7 @@ async def setup_update_core_(var, config):
await mqtt.register_mqtt_component(mqtt_, config) await mqtt.register_mqtt_component(mqtt_, config)
if web_server_id_config := config.get(CONF_WEB_SERVER_ID): if web_server_id_config := config.get(CONF_WEB_SERVER_ID):
web_server_ = cg.get_variable(web_server_id_config) web_server_ = await cg.get_variable(web_server_id_config)
web_server.add_entity_to_sorting_list(web_server_, var, config) web_server.add_entity_to_sorting_list(web_server_, var, config)

View File

@@ -1,9 +1,35 @@
#include "update_entity.h" #include "update_entity.h"
#include "esphome/core/log.h"
namespace esphome { namespace esphome {
namespace update { namespace update {
static const char *const TAG = "update";
void UpdateEntity::publish_state() { void UpdateEntity::publish_state() {
ESP_LOGD(TAG, "'%s' - Publishing:", this->name_.c_str());
ESP_LOGD(TAG, " Current Version: %s", this->update_info_.current_version.c_str());
if (!this->update_info_.md5.empty()) {
ESP_LOGD(TAG, " Latest Version: %s", this->update_info_.latest_version.c_str());
}
if (!this->update_info_.firmware_url.empty()) {
ESP_LOGD(TAG, " Firmware URL: %s", this->update_info_.firmware_url.c_str());
}
ESP_LOGD(TAG, " Title: %s", this->update_info_.title.c_str());
if (!this->update_info_.summary.empty()) {
ESP_LOGD(TAG, " Summary: %s", this->update_info_.summary.c_str());
}
if (!this->update_info_.release_url.empty()) {
ESP_LOGD(TAG, " Release URL: %s", this->update_info_.release_url.c_str());
}
if (this->update_info_.has_progress) {
ESP_LOGD(TAG, " Progress: %.0f%%", this->update_info_.progress);
}
this->has_state_ = true; this->has_state_ = true;
this->state_callback_.call(); this->state_callback_.call();
} }

View File

@@ -114,7 +114,7 @@ EAP_AUTH_SCHEMA = cv.All(
cv.Optional(CONF_USERNAME): cv.string_strict, cv.Optional(CONF_USERNAME): cv.string_strict,
cv.Optional(CONF_PASSWORD): cv.string_strict, cv.Optional(CONF_PASSWORD): cv.string_strict,
cv.Optional(CONF_CERTIFICATE_AUTHORITY): wpa2_eap.validate_certificate, cv.Optional(CONF_CERTIFICATE_AUTHORITY): wpa2_eap.validate_certificate,
cv.Optional(CONF_TTLS_PHASE_2): cv.All( cv.SplitDefault(CONF_TTLS_PHASE_2, esp32_idf="mschapv2"): cv.All(
cv.enum(TTLS_PHASE_2), cv.only_with_esp_idf cv.enum(TTLS_PHASE_2), cv.only_with_esp_idf
), ),
cv.Inclusive( cv.Inclusive(
@@ -350,7 +350,7 @@ def eap_auth(config):
("ca_cert", ca_cert), ("ca_cert", ca_cert),
("client_cert", client_cert), ("client_cert", client_cert),
("client_key", key), ("client_key", key),
("ttls_phase_2", config.get(CONF_TTLS_PHASE_2, TTLS_PHASE_2["mschapv2"])), ("ttls_phase_2", config.get(CONF_TTLS_PHASE_2)),
) )

View File

@@ -694,15 +694,15 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
info.netmask = network::IPAddress(255, 255, 255, 0); info.netmask = network::IPAddress(255, 255, 255, 0);
} }
err = esp_netif_dhcpc_stop(s_ap_netif); err = esp_netif_dhcps_stop(s_ap_netif);
if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) { if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
ESP_LOGV(TAG, "esp_netif_dhcpc_stop failed: %s", esp_err_to_name(err)); ESP_LOGE(TAG, "esp_netif_dhcps_stop failed: %s", esp_err_to_name(err));
return false; return false;
} }
err = esp_netif_set_ip_info(s_ap_netif, &info); err = esp_netif_set_ip_info(s_ap_netif, &info);
if (err != ESP_OK) { if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_netif_set_ip_info failed! %d", err); ESP_LOGE(TAG, "esp_netif_set_ip_info failed! %d", err);
return false; return false;
} }
@@ -712,20 +712,20 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
start_address += 99; start_address += 99;
lease.start_ip = start_address; lease.start_ip = start_address;
ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str()); ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
start_address += 100; start_address += 10;
lease.end_ip = start_address; lease.end_ip = start_address;
ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str()); ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease, sizeof(lease)); err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease, sizeof(lease));
if (err != ESP_OK) { if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_netif_dhcps_option failed! %d", err); ESP_LOGE(TAG, "esp_netif_dhcps_option failed! %d", err);
return false; return false;
} }
err = esp_netif_dhcps_start(s_ap_netif); err = esp_netif_dhcps_start(s_ap_netif);
if (err != ESP_OK) { if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_netif_dhcps_start failed! %d", err); ESP_LOGE(TAG, "esp_netif_dhcps_start failed! %d", err);
return false; return false;
} }

View File

@@ -716,12 +716,12 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
if (wifi_softap_dhcps_status() == DHCP_STARTED) { if (wifi_softap_dhcps_status() == DHCP_STARTED) {
if (!wifi_softap_dhcps_stop()) { if (!wifi_softap_dhcps_stop()) {
ESP_LOGV(TAG, "Stopping DHCP server failed!"); ESP_LOGW(TAG, "Stopping DHCP server failed!");
} }
} }
if (!wifi_set_ip_info(SOFTAP_IF, &info)) { if (!wifi_set_ip_info(SOFTAP_IF, &info)) {
ESP_LOGV(TAG, "Setting SoftAP info failed!"); ESP_LOGE(TAG, "Setting SoftAP info failed!");
return false; return false;
} }
@@ -735,17 +735,17 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
start_address += 99; start_address += 99;
lease.start_ip = start_address; lease.start_ip = start_address;
ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str()); ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
start_address += 100; start_address += 10;
lease.end_ip = start_address; lease.end_ip = start_address;
ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str()); ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
if (!wifi_softap_set_dhcps_lease(&lease)) { if (!wifi_softap_set_dhcps_lease(&lease)) {
ESP_LOGV(TAG, "Setting SoftAP DHCP lease failed!"); ESP_LOGE(TAG, "Setting SoftAP DHCP lease failed!");
return false; return false;
} }
// lease time 1440 minutes (=24 hours) // lease time 1440 minutes (=24 hours)
if (!wifi_softap_set_dhcps_lease_time(1440)) { if (!wifi_softap_set_dhcps_lease_time(1440)) {
ESP_LOGV(TAG, "Setting SoftAP DHCP lease time failed!"); ESP_LOGE(TAG, "Setting SoftAP DHCP lease time failed!");
return false; return false;
} }
@@ -755,13 +755,13 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
uint8_t mode = 1; uint8_t mode = 1;
// bit0, 1 enables router information from ESP8266 SoftAP DHCP server. // bit0, 1 enables router information from ESP8266 SoftAP DHCP server.
if (!wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &mode)) { if (!wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &mode)) {
ESP_LOGV(TAG, "wifi_softap_set_dhcps_offer_option failed!"); ESP_LOGE(TAG, "wifi_softap_set_dhcps_offer_option failed!");
return false; return false;
} }
#endif #endif
if (!wifi_softap_dhcps_start()) { if (!wifi_softap_dhcps_start()) {
ESP_LOGV(TAG, "Starting SoftAP DHCPS failed!"); ESP_LOGE(TAG, "Starting SoftAP DHCPS failed!");
return false; return false;
} }

View File

@@ -823,15 +823,15 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
info.netmask = network::IPAddress(255, 255, 255, 0); info.netmask = network::IPAddress(255, 255, 255, 0);
} }
err = esp_netif_dhcpc_stop(s_ap_netif); err = esp_netif_dhcps_stop(s_ap_netif);
if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) { if (err != ESP_OK && err != ESP_ERR_ESP_NETIF_DHCP_ALREADY_STOPPED) {
ESP_LOGV(TAG, "esp_netif_dhcpc_stop failed: %s", esp_err_to_name(err)); ESP_LOGE(TAG, "esp_netif_dhcps_stop failed: %s", esp_err_to_name(err));
return false; return false;
} }
err = esp_netif_set_ip_info(s_ap_netif, &info); err = esp_netif_set_ip_info(s_ap_netif, &info);
if (err != ESP_OK) { if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_netif_set_ip_info failed! %d", err); ESP_LOGE(TAG, "esp_netif_set_ip_info failed! %d", err);
return false; return false;
} }
@@ -841,20 +841,20 @@ bool WiFiComponent::wifi_ap_ip_config_(optional<ManualIP> manual_ip) {
start_address += 99; start_address += 99;
lease.start_ip = start_address; lease.start_ip = start_address;
ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str()); ESP_LOGV(TAG, "DHCP server IP lease start: %s", start_address.str().c_str());
start_address += 100; start_address += 10;
lease.end_ip = start_address; lease.end_ip = start_address;
ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str()); ESP_LOGV(TAG, "DHCP server IP lease end: %s", start_address.str().c_str());
err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease, sizeof(lease)); err = esp_netif_dhcps_option(s_ap_netif, ESP_NETIF_OP_SET, ESP_NETIF_REQUESTED_IP_ADDRESS, &lease, sizeof(lease));
if (err != ESP_OK) { if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_netif_dhcps_option failed! %d", err); ESP_LOGE(TAG, "esp_netif_dhcps_option failed! %d", err);
return false; return false;
} }
err = esp_netif_dhcps_start(s_ap_netif); err = esp_netif_dhcps_start(s_ap_netif);
if (err != ESP_OK) { if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_netif_dhcps_start failed! %d", err); ESP_LOGE(TAG, "esp_netif_dhcps_start failed! %d", err);
return false; return false;
} }
@@ -887,12 +887,12 @@ bool WiFiComponent::wifi_start_ap_(const WiFiAP &ap) {
esp_err_t err = esp_wifi_set_config(WIFI_IF_AP, &conf); esp_err_t err = esp_wifi_set_config(WIFI_IF_AP, &conf);
if (err != ESP_OK) { if (err != ESP_OK) {
ESP_LOGV(TAG, "esp_wifi_set_config failed! %d", err); ESP_LOGE(TAG, "esp_wifi_set_config failed! %d", err);
return false; return false;
} }
if (!this->wifi_ap_ip_config_(ap.get_manual_ip())) { if (!this->wifi_ap_ip_config_(ap.get_manual_ip())) {
ESP_LOGV(TAG, "wifi_ap_ip_config_ failed!"); ESP_LOGE(TAG, "wifi_ap_ip_config_ failed!");
return false; return false;
} }

View File

@@ -58,17 +58,21 @@ def merge_config(full_old, full_new):
ids = { ids = {
v_id: i v_id: i
for i, v in enumerate(res) for i, v in enumerate(res)
if (v_id := v.get(CONF_ID)) and isinstance(v_id, str) if isinstance(v, dict)
and (v_id := v.get(CONF_ID))
and isinstance(v_id, str)
} }
extend_ids = { extend_ids = {
v_id.value: i v_id.value: i
for i, v in enumerate(res) for i, v in enumerate(res)
if (v_id := v.get(CONF_ID)) and isinstance(v_id, Extend) if isinstance(v, dict)
and (v_id := v.get(CONF_ID))
and isinstance(v_id, Extend)
} }
ids_to_delete = [] ids_to_delete = []
for v in new: for v in new:
if new_id := v.get(CONF_ID): if isinstance(v, dict) and (new_id := v.get(CONF_ID)):
if isinstance(new_id, Extend): if isinstance(new_id, Extend):
new_id = new_id.value new_id = new_id.value
if new_id in ids: if new_id in ids:

View File

@@ -1,6 +1,6 @@
"""Constants used by esphome.""" """Constants used by esphome."""
__version__ = "2024.6.0b3" __version__ = "2024.6.6"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
VALID_SUBSTITUTIONS_CHARACTERS = ( VALID_SUBSTITUTIONS_CHARACTERS = (
@@ -355,6 +355,7 @@ CONF_HUMIDITY_SENSOR = "humidity_sensor"
CONF_HYSTERESIS = "hysteresis" CONF_HYSTERESIS = "hysteresis"
CONF_I2C = "i2c" CONF_I2C = "i2c"
CONF_I2C_ID = "i2c_id" CONF_I2C_ID = "i2c_id"
CONF_IAQ_ACCURACY = "iaq_accuracy"
CONF_IBEACON_MAJOR = "ibeacon_major" CONF_IBEACON_MAJOR = "ibeacon_major"
CONF_IBEACON_MINOR = "ibeacon_minor" CONF_IBEACON_MINOR = "ibeacon_minor"
CONF_IBEACON_UUID = "ibeacon_uuid" CONF_IBEACON_UUID = "ibeacon_uuid"
@@ -719,6 +720,7 @@ CONF_RX_BUFFER_SIZE = "rx_buffer_size"
CONF_RX_ONLY = "rx_only" CONF_RX_ONLY = "rx_only"
CONF_RX_PIN = "rx_pin" CONF_RX_PIN = "rx_pin"
CONF_SAFE_MODE = "safe_mode" CONF_SAFE_MODE = "safe_mode"
CONF_SAMPLE_RATE = "sample_rate"
CONF_SAMSUNG = "samsung" CONF_SAMSUNG = "samsung"
CONF_SATELLITES = "satellites" CONF_SATELLITES = "satellites"
CONF_SCAN = "scan" CONF_SCAN = "scan"

View File

@@ -10,6 +10,7 @@ int_ = global_ns.namespace("int")
std_ns = global_ns.namespace("std") std_ns = global_ns.namespace("std")
std_shared_ptr = std_ns.class_("shared_ptr") std_shared_ptr = std_ns.class_("shared_ptr")
std_string = std_ns.class_("string") std_string = std_ns.class_("string")
std_string_ref = std_ns.namespace("string &")
std_vector = std_ns.class_("vector") std_vector = std_ns.class_("vector")
uint8 = global_ns.namespace("uint8_t") uint8 = global_ns.namespace("uint8_t")
uint16 = global_ns.namespace("uint16_t") uint16 = global_ns.namespace("uint16_t")

View File

@@ -64,7 +64,7 @@ lib_deps =
freekode/TM1651@1.0.1 ; tm1651 freekode/TM1651@1.0.1 ; tm1651
glmnet/Dsmr@0.7 ; dsmr glmnet/Dsmr@0.7 ; dsmr
rweather/Crypto@0.4.0 ; dsmr rweather/Crypto@0.4.0 ; dsmr
dudanov/MideaUART@1.1.8 ; midea dudanov/MideaUART@1.1.9 ; midea
tonia/HeatpumpIR@1.0.23 ; heatpumpir tonia/HeatpumpIR@1.0.23 ; heatpumpir
build_flags = build_flags =
${common.build_flags} ${common.build_flags}

View File

@@ -12,7 +12,7 @@ pyserial==3.5
platformio==6.1.15 # When updating platformio, also update Dockerfile platformio==6.1.15 # When updating platformio, also update Dockerfile
esptool==4.7.0 esptool==4.7.0
click==8.1.7 click==8.1.7
esphome-dashboard==20240613.0 esphome-dashboard==20240620.0
aioesphomeapi==24.3.0 aioesphomeapi==24.3.0
zeroconf==0.132.2 zeroconf==0.132.2
python-magic==0.4.27 python-magic==0.4.27

View File

@@ -1,6 +1,9 @@
substitutions:
network_enable_ipv6: "false"
wifi: wifi:
ssid: MySSID ssid: MySSID
password: password1 password: password1
network: network:
enable_ipv6: true enable_ipv6: ${network_enable_ipv6}

View File

@@ -0,0 +1,4 @@
substitutions:
network_enable_ipv6: "true"
<<: !include common.yaml

View File

@@ -0,0 +1,4 @@
substitutions:
network_enable_ipv6: "true"
<<: !include common.yaml

View File

@@ -0,0 +1,4 @@
substitutions:
network_enable_ipv6: "true"
<<: !include common.yaml

View File

@@ -0,0 +1,4 @@
substitutions:
network_enable_ipv6: "true"
<<: !include common.yaml

View File

@@ -0,0 +1,4 @@
substitutions:
network_enable_ipv6: "true"
<<: !include common.yaml

View File

@@ -0,0 +1,4 @@
substitutions:
network_enable_ipv6: "true"
<<: !include common.yaml

View File

@@ -0,0 +1 @@
network:

View File

@@ -0,0 +1,7 @@
wifi:
networks:
- ssid: MySSID
eap:
username: username
password: password
identity: identity