From 87ca8784ef969378ff56d78176add92be31471f1 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 19 Oct 2025 11:12:56 -1000 Subject: [PATCH] [openthread] Backport address resolution support to prevent OTA crash (#11312) Co-authored-by: Daniel Stiner --- esphome/core/__init__.py | 4 ++++ tests/unit_tests/test_core.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/esphome/core/__init__.py b/esphome/core/__init__.py index 43febd28a2..2d49d29c5e 100644 --- a/esphome/core/__init__.py +++ b/esphome/core/__init__.py @@ -11,6 +11,7 @@ from esphome.const import ( CONF_COMMENT, CONF_ESPHOME, CONF_ETHERNET, + CONF_OPENTHREAD, CONF_PORT, CONF_USE_ADDRESS, CONF_WEB_SERVER, @@ -641,6 +642,9 @@ class EsphomeCore: if CONF_ETHERNET in self.config: return self.config[CONF_ETHERNET][CONF_USE_ADDRESS] + if CONF_OPENTHREAD in self.config: + return f"{self.name}.local" + return None @property diff --git a/tests/unit_tests/test_core.py b/tests/unit_tests/test_core.py index 48eae06ea6..41114ae18b 100644 --- a/tests/unit_tests/test_core.py +++ b/tests/unit_tests/test_core.py @@ -570,6 +570,13 @@ class TestEsphomeCore: assert target.address == "4.3.2.1" + def test_address__openthread(self, target): + target.name = "test-device" + target.config = {} + target.config[const.CONF_OPENTHREAD] = {} + + assert target.address == "test-device.local" + def test_is_esp32(self, target): target.data[const.KEY_CORE] = {const.KEY_TARGET_PLATFORM: "esp32"}