Speedup is_hass_supervisor check
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 23 Feb 2026 00:36:33 +0000 (01:36 +0100)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Mon, 23 Feb 2026 00:36:33 +0000 (01:36 +0100)
music_assistant/helpers/util.py

index 3e849f685cee28501ed1c92ffdb86a5b89078b47..6797f2ab50718d567e23b40240e9b6c875123e8b 100644 (file)
@@ -515,7 +515,12 @@ async def get_package_version(pkg_name: str) -> str | None:
 
 async def is_hass_supervisor() -> bool:
     """Return if we're running inside the HA Supervisor (e.g. HAOS)."""
+    # Fast path: check for HA supervisor token environment variable
+    # This is always set when running inside the HA supervisor
+    if not os.environ.get("SUPERVISOR_TOKEN"):
+        return False
 
+    # Token exists, verify the supervisor is actually reachable
     def _check() -> bool:
         try:
             urllib.request.urlopen("http://supervisor/core", timeout=1)