diff --git a/esphome/components/esphome/ota/__init__.py b/esphome/components/esphome/ota/__init__.py index 3134fadf26..370f50fcbc 100644 --- a/esphome/components/esphome/ota/__init__.py +++ b/esphome/components/esphome/ota/__init__.py @@ -27,10 +27,15 @@ CODEOWNERS = ["@esphome/core"] DEPENDENCIES = ["network"] +def supports_sha256() -> bool: + """Check if the current platform supports SHA256 for OTA authentication.""" + return bool(CORE.is_esp32 or CORE.is_esp8266 or CORE.is_rp2040 or CORE.is_libretiny) + + def AUTO_LOAD(): """Conditionally auto-load sha256 only on platforms that support it.""" base_components = ["md5", "socket"] - if CORE.is_esp32 or CORE.is_esp8266 or CORE.is_rp2040 or CORE.is_libretiny: + if supports_sha256(): return base_components + ["sha256"] return base_components @@ -136,7 +141,7 @@ async def to_code(config): cg.add(var.set_port(config[CONF_PORT])) # Only include SHA256 support on platforms that have it - if CORE.is_esp32 or CORE.is_esp8266 or CORE.is_rp2040 or CORE.is_libretiny: + if supports_sha256(): cg.add_define("USE_OTA_SHA256") if CONF_PASSWORD in config: