A proof-of-concept project that summarizes recent home-assistant.log entries using OpenAI’s GPT-4o-mini, either from within Home Assistant or via an optional Streamlit debug interface.
This repository includes:
- A Streamlit-based log viewer and LLM-powered summarizer in
streamlit_app/ - A Home Assistant custom integration in
custom_components/log_summarizer/
• Filters and groups warnings, errors, and critical messages
• Summarizes recent logs using GPT-4o-mini
• Provides actionable fixes with context
• Lets you choose a time window (e.g. last 24h)
• Persistent notification and optional markdown output
• Debug mode for viewing and exporting filtered logs
You can also install this integration via HACS as a custom repository:
- In Home Assistant, go to HACS → Integrations.
- Click the three-dot menu in the upper right → Custom repositories.
- Enter the repository URL:
https://github.com/borsic77/HA_log_analyzer - Select Integration as the category and click Add.
- You’ll now see Log Summarizer available to install under HACS → Integrations.
- After installation, restart Home Assistant and follow the same configuration steps as below, starting from step 3.
This method ensures easier future updates and visibility through HACS.
-
Copy the contents of
custom_components/log_summarizer/into your Home Assistant'sconfig/custom_components/log_summarizer/directory. -
In your
configuration.yaml, add the following block (you can store the API key insecrets.yaml):
log_summarizer:
api_key: !secret openai_api_key- In
secrets.yaml, add:
openai_api_key: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxTo get your API key, create an account and generate a key at OpenAI's API key page.
Note: Accessing the OpenAI API is separate from a ChatGPT Plus subscription. Even if you have ChatGPT Plus, you'll need to create a separate OpenAI account at platform.openai.com and set up billing.
The OpenAI API uses a pay-as-you-go prepaid model, where you're billed per token (roughly per word). As of April 2025, the pricing is:
- GPT-4o: $0.005 / 1K input tokens, $0.015 / 1K output tokens
- GPT-3.5-turbo: $0.0005 / 1K input tokens, $0.0015 / 1K output tokens
This integration is designed to be run manually (e.g., on demand, not constantly), so usage costs are typically very low — often just a few cents per run.
-
Restart Home Assistant.
-
Use Developer Tools → Actions to call the
log_summarizer.summarize_logsservice and optionally provide thefile_pathandmodel.
git clone https://github.com/your-username/HA_log_analyzer.git
cd HA_log_analyzeruv venv
source .venv/bin/activate
uv pip install -e .Create a file called .env in the project root with the following contents:
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxstreamlit run streamlit_app/main.pyCreated by Boris Legradic · MIT License