429 files

This commit is contained in:
Home Assistant Version Control
2026-08-30 02:43:31 +00:00
parent 472c19bceb
commit 963cce81a7
566 changed files with 50311 additions and 47616 deletions
@@ -15,6 +15,7 @@ from __future__ import annotations
import asyncio
import logging
import secrets
from contextlib import suppress
from typing import TYPE_CHECKING
from urllib.parse import urlparse
@@ -32,6 +33,7 @@ from .const import (
CHANNEL_DEV,
COMPONENT_MANIFEST_AT_TAG_URL,
DATA_BRINGUP_TASK,
DATA_DCR_SIGNING_KEY,
DATA_MANAGER,
DATA_OAUTH_CLIENT_ID,
DATA_OAUTH_CLIENT_SECRET,
@@ -123,6 +125,16 @@ async def async_bring_up_server(hass: HomeAssistant, entry: ConfigEntry) -> None
# Always set up the loopback forwarding config — the sidebar settings
# panel proxies through it (#1803); the option gates only the public
# webhook endpoint. oauth_* args are ignored unless auth_mode is legacy.
if not entry.data.get(DATA_DCR_SIGNING_KEY):
# Upgrade path: entries created before 2.0.0 have no DCR key.
# entry.data must stay JSON-serializable, so store hex.
hass.config_entries.async_update_entry(
entry,
data={
**entry.data,
DATA_DCR_SIGNING_KEY: secrets.token_bytes(32).hex(),
},
)
oauth_restart_needed = await async_register_webhook(
hass,
entry,
@@ -133,6 +145,7 @@ async def async_bring_up_server(hass: HomeAssistant, entry: ConfigEntry) -> None
oauth_client_id=oauth_client_id,
oauth_client_secret=oauth_client_secret,
oauth_signing_key=entry.data.get(DATA_OAUTH_SIGNING_KEY),
dcr_signing_key=entry.data.get(DATA_DCR_SIGNING_KEY),
)
_async_update_legacy_oauth_issue(hass, oauth_restart_needed)
if not webhook_enabled:
@@ -494,7 +507,9 @@ def _surface_connect_urls(
"(Settings - Devices & Services - HA-MCP Custom Component - "
"HA-MCP Server - Configure) and in the Home Assistant log - both "
"administrator-only, because the URL is the credential.\n\n"
f"{auth_note}\n"
f"{auth_note}\n\n"
"To disable this notification, uncheck the startup notification box "
"on that same configuration screen.\n"
)
persistent_notification.async_create(
hass,
@@ -519,7 +534,7 @@ def _async_update_legacy_oauth_issue(hass: HomeAssistant, restart_needed: bool)
hass,
DOMAIN,
ISSUE_LEGACY_OAUTH_RESTART,
is_fixable=False,
is_fixable=True,
severity=ir.IssueSeverity.WARNING,
translation_key=ISSUE_LEGACY_OAUTH_RESTART,
)
@@ -593,6 +608,10 @@ async def async_maybe_auto_update(
logged at debug and skipped; the next refresh retries. Genuine bugs
propagate per the repo's no-silent-failure convention.
"""
if hass.config.skip_pip:
# The system package manager owns ha-mcp; never reload to mutate it.
return
if not bool(entry.options.get(OPT_AUTO_UPDATE, DEFAULT_AUTO_UPDATE)):
# Auto-update turned off: stay on the currently-installed version.
return