From aca11f17774b069fa3196eee08023d018bc2a55e Mon Sep 17 00:00:00 2001 From: Mat931 <49403702+Mat931@users.noreply.github.com> Date: Thu, 16 Apr 2026 19:44:25 +0200 Subject: [PATCH] Fix --- esphome/components/esphome/ota/__init__.py | 2 +- esphome/espota2.py | 6 +++--- tests/unit_tests/test_main.py | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/esphome/components/esphome/ota/__init__.py b/esphome/components/esphome/ota/__init__.py index 92e9733f93..44b3997755 100644 --- a/esphome/components/esphome/ota/__init__.py +++ b/esphome/components/esphome/ota/__init__.py @@ -163,7 +163,7 @@ async def to_code(config: ConfigType) -> None: cg.add_define("USE_OTA_PASSWORD") cg.add_define("USE_OTA_VERSION", config[CONF_VERSION]) - if config[CONF_ALLOW_PARTITION_ACCESS]: + if config.get(CONF_ALLOW_PARTITION_ACCESS, False): cg.add_define("USE_OTA_PARTITIONS") # Build flag so lwip_fast_select.c (a .c file that can't include defines.h) sees it. diff --git a/esphome/espota2.py b/esphome/espota2.py index 7ee28a6b1c..f6ecb123b9 100644 --- a/esphome/espota2.py +++ b/esphome/espota2.py @@ -242,7 +242,7 @@ def perform_ota( password: str | None, file_handle: io.IOBase, filename: Path, - ota_type: int, + ota_type: int = OTA_TYPE_UPDATE_APP, ) -> None: file_contents = file_handle.read() file_size = len(file_contents) @@ -413,7 +413,7 @@ def run_ota_impl_( remote_port: int, password: str | None, filename: Path, - ota_type: int, + ota_type: int = OTA_TYPE_UPDATE_APP, ) -> tuple[int, str | None]: from esphome.core import CORE @@ -470,7 +470,7 @@ def run_ota( remote_port: int, password: str | None, filename: Path, - ota_type: int, + ota_type: int = OTA_TYPE_UPDATE_APP, ) -> tuple[int, str | None]: try: return run_ota_impl_(remote_host, remote_port, password, filename, ota_type) diff --git a/tests/unit_tests/test_main.py b/tests/unit_tests/test_main.py index e07b4accf2..09d0ab7512 100644 --- a/tests/unit_tests/test_main.py +++ b/tests/unit_tests/test_main.py @@ -1587,7 +1587,7 @@ def test_upload_program_ota_success( tmp_path / ".esphome" / "build" / "test" / ".pioenvs" / "test" / "firmware.bin" ) mock_run_ota.assert_called_once_with( - ["192.168.1.100"], 3232, "secret", expected_firmware + ["192.168.1.100"], 3232, "secret", expected_firmware, 0 ) @@ -1618,7 +1618,7 @@ def test_upload_program_ota_with_file_arg( assert exit_code == 0 assert host == "192.168.1.100" mock_run_ota.assert_called_once_with( - ["192.168.1.100"], 3232, None, Path("custom.bin") + ["192.168.1.100"], 3232, None, Path("custom.bin"), 0 ) @@ -1676,7 +1676,7 @@ def test_upload_program_ota_with_mqtt_resolution( tmp_path / ".esphome" / "build" / "test" / ".pioenvs" / "test" / "firmware.bin" ) mock_run_ota.assert_called_once_with( - ["192.168.1.100"], 3232, None, expected_firmware + ["192.168.1.100"], 3232, None, expected_firmware, 0 ) @@ -1724,7 +1724,7 @@ def test_upload_program_ota_with_mqtt_empty_broker( tmp_path / ".esphome" / "build" / "test" / ".pioenvs" / "test" / "firmware.bin" ) mock_run_ota.assert_called_once_with( - ["192.168.1.50"], 3232, None, expected_firmware + ["192.168.1.50"], 3232, None, expected_firmware, 0 ) # Verify warning was logged assert "MQTT IP discovery failed" in caplog.text @@ -2698,7 +2698,7 @@ def test_upload_program_ota_static_ip_with_mqttip( tmp_path / ".esphome" / "build" / "test" / ".pioenvs" / "test" / "firmware.bin" ) mock_run_ota.assert_called_once_with( - ["192.168.1.100", "192.168.2.50"], 3232, None, expected_firmware + ["192.168.1.100", "192.168.2.50"], 3232, None, expected_firmware, 0 ) @@ -2741,7 +2741,7 @@ def test_upload_program_ota_multiple_mqttip_resolves_once( tmp_path / ".esphome" / "build" / "test" / ".pioenvs" / "test" / "firmware.bin" ) mock_run_ota.assert_called_once_with( - ["192.168.2.50", "192.168.2.51", "192.168.1.100"], 3232, None, expected_firmware + ["192.168.2.50", "192.168.2.51", "192.168.1.100"], 3232, None, expected_firmware, 0 ) @@ -2906,7 +2906,7 @@ def test_upload_program_ota_mqtt_timeout_fallback( tmp_path / ".esphome" / "build" / "test" / ".pioenvs" / "test" / "firmware.bin" ) mock_run_ota.assert_called_once_with( - ["192.168.1.100"], 3232, None, expected_firmware + ["192.168.1.100"], 3232, None, expected_firmware, 0 )