diff --git a/custom_components/houseplan/__init__.py b/custom_components/houseplan/__init__.py index 00e60a1..e4deba7 100755 --- a/custom_components/houseplan/__init__.py +++ b/custom_components/houseplan/__init__.py @@ -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 diff --git a/custom_components/houseplan/const.py b/custom_components/houseplan/const.py index 799a9ee..1b5be76 100755 --- a/custom_components/houseplan/const.py +++ b/custom_components/houseplan/const.py @@ -5,3 +5,5 @@ STORAGE_KEY = f"{DOMAIN}.layout" STORAGE_VERSION = 1 FRONTEND_URL = "/houseplan_files/houseplan-card.js" CONF_ADMIN_ONLY = "admin_only" + +VERSION = "1.0.0"