1
0
mirror of https://github.com/esphome/esphome.git synced 2025-11-06 10:01:51 +00:00

Compare commits

...

47 Commits

Author SHA1 Message Date
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
Jesse Hills
cfe28ce7a3 Merge pull request #6915 from esphome/bump-2024.6.0b3
2024.6.0b3
2024-06-17 16:27:24 +12:00
Jesse Hills
25a3db1637 Bump version to 2024.6.0b3 2024-06-17 15:35:53 +12:00
Jesse Hills
65638bf614 [mqtt] Fix datetime copy pasta (#6914) 2024-06-17 15:35:52 +12:00
Jesse Hills
1e66241b26 [ili9xxx] Fix init for GC9A01A (#6913) 2024-06-17 15:35:52 +12:00
esphomebot
eb50f0eafd Synchronise Device Classes from Home Assistant (#6904) 2024-06-17 15:35:52 +12:00
46 changed files with 351 additions and 119 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

@@ -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

@@ -145,10 +145,8 @@ 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;
} else {
switch (this->resolution_) { switch (this->resolution_) {
case 9: case 9:
temp &= 0xfff8; temp &= 0xfff8;
@@ -163,7 +161,6 @@ float DallasTemperatureSensor::get_temp_c_() {
default: default:
break; 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{
.second = uint8_t(ds1307_.reg.second + 10 * ds1307_.reg.second_10),
.minute = uint8_t(ds1307_.reg.minute + 10u * ds1307_.reg.minute_10), .minute = uint8_t(ds1307_.reg.minute + 10u * ds1307_.reg.minute_10),
.hour = uint8_t(ds1307_.reg.hour + 10u * ds1307_.reg.hour_10), .hour = uint8_t(ds1307_.reg.hour + 10u * ds1307_.reg.hour_10),
.day_of_week = uint8_t(ds1307_.reg.weekday), .day_of_week = uint8_t(ds1307_.reg.weekday),
.day_of_month = uint8_t(ds1307_.reg.day + 10u * ds1307_.reg.day_10), .day_of_month = uint8_t(ds1307_.reg.day + 10u * ds1307_.reg.day_10),
.day_of_year = 1, // ignored by recalc_timestamp_utc(false) .day_of_year = 1, // ignored by recalc_timestamp_utc(false)
.month = uint8_t(ds1307_.reg.month + 10u * ds1307_.reg.month_10), .month = uint8_t(ds1307_.reg.month + 10u * ds1307_.reg.month_10),
.year = uint16_t(ds1307_.reg.year + 10u * ds1307_.reg.year_10 + 2000)}; .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);
} }
} }
if (this->response_triggers_.size() == 1) {
// 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_) { for (auto *trigger : this->response_triggers_) {
trigger->process(container, response_body); // 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

@@ -34,8 +34,8 @@ void ILI9XXXDisplay::setup() {
ESP_LOGD(TAG, "Setting up ILI9xxx"); ESP_LOGD(TAG, "Setting up ILI9xxx");
this->setup_pins_(); this->setup_pins_();
this->init_lcd_(this->init_sequence_); this->init_lcd(this->init_sequence_);
this->init_lcd_(this->extra_init_sequence_.data()); this->init_lcd(this->extra_init_sequence_.data());
switch (this->pixel_mode_) { switch (this->pixel_mode_) {
case PIXEL_MODE_16: case PIXEL_MODE_16:
if (this->is_18bitdisplay_) { if (this->is_18bitdisplay_) {
@@ -405,7 +405,7 @@ void ILI9XXXDisplay::reset_() {
} }
} }
void ILI9XXXDisplay::init_lcd_(const uint8_t *addr) { void ILI9XXXDisplay::init_lcd(const uint8_t *addr) {
if (addr == nullptr) if (addr == nullptr)
return; return;
uint8_t cmd, x, num_args; uint8_t cmd, x, num_args;
@@ -427,6 +427,20 @@ void ILI9XXXDisplay::init_lcd_(const uint8_t *addr) {
} }
} }
void ILI9XXXGC9A01A::init_lcd(const uint8_t *addr) {
if (addr == nullptr)
return;
uint8_t cmd, x, num_args;
while ((cmd = *addr++) != 0) {
x = *addr++;
num_args = x & 0x7F;
this->send_command(cmd, addr, num_args);
addr += num_args;
if (x & 0x80)
delay(150); // NOLINT
}
}
// Tell the display controller where we want to draw pixels. // Tell the display controller where we want to draw pixels.
void ILI9XXXDisplay::set_addr_window_(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) { void ILI9XXXDisplay::set_addr_window_(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
x1 += this->offset_x_; x1 += this->offset_x_;

View File

@@ -109,7 +109,7 @@ class ILI9XXXDisplay : public display::DisplayBuffer,
virtual void set_madctl(); virtual void set_madctl();
void display_(); void display_();
void init_lcd_(const uint8_t *addr); virtual void init_lcd(const uint8_t *addr);
void set_addr_window_(uint16_t x, uint16_t y, uint16_t x2, uint16_t y2); void set_addr_window_(uint16_t x, uint16_t y, uint16_t x2, uint16_t y2);
void reset_(); void reset_();
@@ -269,6 +269,7 @@ class ILI9XXXS3BoxLite : public ILI9XXXDisplay {
class ILI9XXXGC9A01A : public ILI9XXXDisplay { class ILI9XXXGC9A01A : public ILI9XXXDisplay {
public: public:
ILI9XXXGC9A01A() : ILI9XXXDisplay(INITCMD_GC9A01A, 240, 240, true) {} ILI9XXXGC9A01A() : ILI9XXXDisplay(INITCMD_GC9A01A, 240, 240, true) {}
void init_lcd(const uint8_t *addr) override;
}; };
//----------- ILI9XXX_24_TFT display -------------- //----------- ILI9XXX_24_TFT display --------------

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

@@ -6,12 +6,12 @@
#include "mqtt_const.h" #include "mqtt_const.h"
#ifdef USE_MQTT #ifdef USE_MQTT
#ifdef USE_DATETIME_TIME #ifdef USE_DATETIME_DATETIME
namespace esphome { namespace esphome {
namespace mqtt { namespace mqtt {
static const char *const TAG = "mqtt.datetime.time"; static const char *const TAG = "mqtt.datetime.datetime";
using namespace esphome::datetime; using namespace esphome::datetime;
@@ -80,5 +80,5 @@ bool MQTTDateTimeComponent::publish_state(uint16_t year, uint8_t month, uint8_t
} // namespace mqtt } // namespace mqtt
} // namespace esphome } // namespace esphome
#endif // USE_DATETIME_TIME #endif // USE_DATETIME_DATETIME
#endif // USE_MQTT #endif // USE_MQTT

View File

@@ -3,7 +3,7 @@
#include "esphome/core/defines.h" #include "esphome/core/defines.h"
#ifdef USE_MQTT #ifdef USE_MQTT
#ifdef USE_DATETIME_TIME #ifdef USE_DATETIME_DATETIME
#include "esphome/components/datetime/datetime_entity.h" #include "esphome/components/datetime/datetime_entity.h"
#include "mqtt_component.h" #include "mqtt_component.h"
@@ -17,7 +17,7 @@ class MQTTDateTimeComponent : public mqtt::MQTTComponent {
* *
* @param time The time entity. * @param time The time entity.
*/ */
explicit MQTTDateTimeComponent(datetime::DateTimeEntity *time); explicit MQTTDateTimeComponent(datetime::DateTimeEntity *datetime);
// ========== INTERNAL METHODS ========== // ========== INTERNAL METHODS ==========
// (In most use cases you won't need these) // (In most use cases you won't need these)
@@ -41,5 +41,5 @@ class MQTTDateTimeComponent : public mqtt::MQTTComponent {
} // namespace mqtt } // namespace mqtt
} // namespace esphome } // namespace esphome
#endif // USE_DATETIME_DATE #endif // USE_DATETIME_DATETIME
#endif // USE_MQTT #endif // USE_MQTT

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)
if enable_ipv6:
cg.add_define( cg.add_define(
"USE_NETWORK_MIN_IPV6_ADDR_COUNT", config[CONF_MIN_IPV6_ADDR_COUNT] "USE_NETWORK_MIN_IPV6_ADDR_COUNT", config[CONF_MIN_IPV6_ADDR_COUNT]
) )
if CORE.using_esp_idf: if CORE.using_esp_idf:
add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", config[CONF_ENABLE_IPV6]) add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", enable_ipv6)
add_idf_sdkconfig_option( add_idf_sdkconfig_option("CONFIG_LWIP_IPV6_AUTOCONFIG", enable_ipv6)
"CONFIG_LWIP_IPV6_AUTOCONFIG", config[CONF_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,9 +56,7 @@ 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]) var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config) await cg.register_component(var, config)
@@ -72,5 +70,6 @@ async def to_code(config):
config[CONF_BOOT_IS_GOOD_AFTER], config[CONF_BOOT_IS_GOOD_AFTER],
) )
cg.add(RawExpression(f"if ({condition}) return")) 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,10 +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_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
@@ -24,6 +27,7 @@ PerformAction = update_ns.class_("PerformAction", automation.Action)
IsAvailableCondition = update_ns.class_("IsAvailableCondition", automation.Condition) IsAvailableCondition = update_ns.class_("IsAvailableCondition", automation.Condition)
DEVICE_CLASSES = [ DEVICE_CLASSES = [
DEVICE_CLASS_EMPTY,
DEVICE_CLASS_FIRMWARE, DEVICE_CLASS_FIRMWARE,
] ]
@@ -39,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,
} }
) )
) )
@@ -62,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

@@ -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.0b2" __version__ = "2024.6.4"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
VALID_SUBSTITUTIONS_CHARACTERS = ( VALID_SUBSTITUTIONS_CHARACTERS = (

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: