From 0b3e39958827e60db78222561a5345d680e25a8e Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 19 Aug 2026 12:59:40 -0500 Subject: [PATCH] [web_server] Shorten the offline hint --- esphome/components/web_server/__init__.py | 15 +++++---------- tests/unit_tests/components/test_web_server.py | 9 +-------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/esphome/components/web_server/__init__.py b/esphome/components/web_server/__init__.py index 3e9fa45b28..8ab7be057f 100644 --- a/esphome/components/web_server/__init__.py +++ b/esphome/components/web_server/__init__.py @@ -2,7 +2,6 @@ from __future__ import annotations import base64 import gzip -from html import escape as html_escape import logging import re @@ -349,17 +348,13 @@ def build_index_html(config: ConfigType, offline_hint: bool = True) -> str: if js_url and offline_hint: # The interface is downloaded from the internet. Show a hint instead of a blank # page when the browser cannot reach it, which is common in WiFi AP mode. + # Kept short: this string lives in flash on every build without captive_portal. hint = ( - f"Could not load the web interface from {js_url}. This browser needs internet " - "access to download it. To serve it from the device instead (for example in " - "WiFi access point mode), set local: true under web_server: in the YAML " - "configuration and install the firmware again." + "Could not download the web interface. This browser needs internet access, " + "or set local: true under web_server: in the YAML and reinstall so the " + "device serves it." ) - # Escape for a JS single quoted string inside a double quoted HTML attribute. - hint_js = html_escape( - hint.replace("\\", "\\\\").replace("'", "\\'"), quote=True - ) - html += f'' + html += f'' elif js_url: html += f'' html += "" diff --git a/tests/unit_tests/components/test_web_server.py b/tests/unit_tests/components/test_web_server.py index 021a734109..0de1b8b9ed 100644 --- a/tests/unit_tests/components/test_web_server.py +++ b/tests/unit_tests/components/test_web_server.py @@ -10,15 +10,8 @@ def test_build_index_html_has_offline_hint() -> None: {CONF_JS_URL: "https://oi.esphome.io/v2/www.js", CONF_CSS_URL: ""} ) assert '