From e988d445a409f79b9ab6bebd66ed03b655d387be Mon Sep 17 00:00:00 2001 From: SMKRV Date: Wed, 11 Dec 2024 22:01:01 +0300 Subject: [PATCH] - Fixed version reading from manifest.json implementation --- custom_components/ha_text_ai/const.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/custom_components/ha_text_ai/const.py b/custom_components/ha_text_ai/const.py index fd00e00..6acf345 100644 --- a/custom_components/ha_text_ai/const.py +++ b/custom_components/ha_text_ai/const.py @@ -6,6 +6,7 @@ Constants for the HA text AI integration. @github: https://github.com/smkrv/ha-text-ai @source: https://github.com/smkrv/ha-text-ai """ +import os from typing import Final import voluptuous as vol from homeassistant.const import Platform, CONF_API_KEY, CONF_NAME @@ -25,6 +26,15 @@ API_PROVIDERS: Final = [ API_PROVIDER_ANTHROPIC ] +# Read version from manifest.json +MANIFEST_PATH = os.path.join(os.path.dirname(__file__), "manifest.json") +try: + with open(MANIFEST_PATH) as manifest_file: + manifest = json.load(manifest_file) + VERSION = manifest.get("version", "unknown") +except Exception: + VERSION = "unknown" + # Default endpoints DEFAULT_OPENAI_ENDPOINT: Final = "https://api.openai.com/v1" DEFAULT_ANTHROPIC_ENDPOINT: Final = "https://api.anthropic.com"