fix: no blocking manifest read in event loop (version from const)

This commit is contained in:
JB
2026-07-03 20:07:39 +03:00
parent 0c6f37198f
commit ce0d44d185
2 changed files with 4 additions and 11 deletions
+2 -11
View File
@@ -10,7 +10,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.storage import Store
from . import websocket_api as hp_ws
from .const import DOMAIN, FRONTEND_URL, STORAGE_KEY, STORAGE_VERSION
from .const import DOMAIN, FRONTEND_URL, STORAGE_KEY, STORAGE_VERSION, VERSION
_LOGGER = logging.getLogger(__name__)
@@ -39,21 +39,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
)
except ImportError: # старые версии HA
hass.http.register_static_path(FRONTEND_URL, str(card_path), cache_headers=False)
add_extra_js_url(hass, f"{FRONTEND_URL}?v={_manifest_version(hass)}")
add_extra_js_url(hass, f"{FRONTEND_URL}?v={VERSION}")
else:
_LOGGER.warning("houseplan-card.js не найден рядом с интеграцией: %s", card_path)
return True
def _manifest_version(hass: HomeAssistant) -> str:
try:
import json
manifest = Path(__file__).parent / "manifest.json"
return json.loads(manifest.read_text()).get("version", "0")
except Exception: # noqa: BLE001
return "0"
async def _update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
hass.data[DOMAIN]["entry"] = entry