mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
fix: no blocking manifest read in event loop (version from const)
This commit is contained in:
@@ -10,7 +10,7 @@ from homeassistant.core import HomeAssistant
|
|||||||
from homeassistant.helpers.storage import Store
|
from homeassistant.helpers.storage import Store
|
||||||
|
|
||||||
from . import websocket_api as hp_ws
|
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__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -39,21 +39,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
)
|
)
|
||||||
except ImportError: # старые версии HA
|
except ImportError: # старые версии HA
|
||||||
hass.http.register_static_path(FRONTEND_URL, str(card_path), cache_headers=False)
|
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:
|
else:
|
||||||
_LOGGER.warning("houseplan-card.js не найден рядом с интеграцией: %s", card_path)
|
_LOGGER.warning("houseplan-card.js не найден рядом с интеграцией: %s", card_path)
|
||||||
return True
|
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:
|
async def _update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
|
||||||
hass.data[DOMAIN]["entry"] = entry
|
hass.data[DOMAIN]["entry"] = entry
|
||||||
|
|||||||
@@ -5,3 +5,5 @@ STORAGE_KEY = f"{DOMAIN}.layout"
|
|||||||
STORAGE_VERSION = 1
|
STORAGE_VERSION = 1
|
||||||
FRONTEND_URL = "/houseplan_files/houseplan-card.js"
|
FRONTEND_URL = "/houseplan_files/houseplan-card.js"
|
||||||
CONF_ADMIN_ONLY = "admin_only"
|
CONF_ADMIN_ONLY = "admin_only"
|
||||||
|
|
||||||
|
VERSION = "1.0.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user