Skip to content

Commit 5c16eee

Browse files
author
SMKRV
committed
fix: Read version from manifest.json
1 parent e988d44 commit 5c16eee

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

custom_components/ha_text_ai/const.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
@source: https://github.com/smkrv/ha-text-ai
88
"""
99
import os
10+
import json
1011
from typing import Final
1112
import voluptuous as vol
1213
from homeassistant.const import Platform, CONF_API_KEY, CONF_NAME
@@ -32,8 +33,15 @@
3233
with open(MANIFEST_PATH) as manifest_file:
3334
manifest = json.load(manifest_file)
3435
VERSION = manifest.get("version", "unknown")
35-
except Exception:
36+
except FileNotFoundError:
3637
VERSION = "unknown"
38+
_LOGGER.warning("manifest.json not found at %s", MANIFEST_PATH)
39+
except json.JSONDecodeError as err:
40+
VERSION = "unknown"
41+
_LOGGER.error("Error decoding JSON from manifest.json: %s", err)
42+
except Exception as err:
43+
VERSION = "unknown"
44+
_LOGGER.error("Error reading manifest.json: %s", err)
3745

3846
# Default endpoints
3947
DEFAULT_OPENAI_ENDPOINT: Final = "https://api.openai.com/v1"

0 commit comments

Comments
 (0)