🤖 HA Text AI for Home Assistant
Transform your smart home experience with powerful AI assistance powered by multiple AI providers including OpenAI GPT and Anthropic Claude models. Get intelligent responses, automate complex scenarios, and enhance your home automation with advanced natural language processing.
🌟 Features
- 🧠 Multi-Provider AI Integration:
- Support for OpenAI GPT models
- Anthropic Claude integration
- Custom API endpoints
- Flexible model selection
- 💬 Advanced Language Processing:
- Context-aware responses
- Multi-turn conversations
- Custom system instructions
- Natural conversation flow
- 📝 Enhanced Memory Management:
- Persistent conversation history
- Context-aware responses
- Customizable history limits
- Model-specific filtering
- ⚡ Performance Optimization:
- Efficient token usage
- Smart rate limiting
- Response caching
- Request interval control
- 🎯 Advanced Customization:
- Per-request model selection
- Adjustable parameters
- Custom system prompts
- Temperature control
- 🔒 Enhanced Security:
- Secure API key storage
- Rate limiting protection
- Error handling
- Usage monitoring
- 🎨 Improved User Experience:
- Intuitive configuration UI
- Detailed sensor attributes
- Rich service interface
- Model selection UI
- 🔄 Automation Integration:
- Event-driven responses
- Conditional logic support
- Template compatibility
- Model-specific automation
📋 Prerequisites
- Home Assistant 2023.8.0 or newer
- API key from supported providers:
- Python 3.9 or newer
- Stable internet connection
⚡ Installation
HACS Installation (Recommended)
- Open HACS in Home Assistant
- Click on the three dots in the top right corner
- Select "Custom repositories"
- Add
https://github.com/smkrv/ha-text-aias Integration - Click "Add"
- Click on "Integrations" in HACS
- Search for "HA Text AI"
- Click "Download"
- Restart Home Assistant
Manual Installation
- Download the latest release
- Extract and copy
custom_components/ha_text_aito yourcustom_componentsdirectory - Restart Home Assistant
- Add configuration via UI or YAML
⚙️ Configuration
Via UI (Recommended)
- Go to Settings → Devices & Services
- Click "Add Integration"
- Search for "HA Text AI"
- Follow the configuration steps
Via YAML
ha_text_ai:
api_key: !secret ai_api_key
model: gpt-3.5-turbo # or claude-3-sonnet
temperature: 0.7
max_tokens: 1000
request_interval: 1.0
api_endpoint: https://api.openai.com/v1 # optional, for custom endpoints
system_prompt: |
You are a home automation expert assistant.
Focus on practical and efficient solutions.
🛠️ Available Services
ask_question
service: ha_text_ai.ask_question
data:
question: "What's the optimal temperature for sleeping?"
model: "claude-3-sonnet" # optional
temperature: 0.5 # optional
max_tokens: 500 # optional
system_prompt: "You are a sleep optimization expert" # optional
set_system_prompt
service: ha_text_ai.set_system_prompt
data:
prompt: |
You are a home automation expert focused on:
1. Energy efficiency
2. Comfort optimization
3. Security considerations
Provide practical, actionable advice.
clear_history
service: ha_text_ai.clear_history
get_history
service: ha_text_ai.get_history
data:
limit: 5 # optional
filter_model: "gpt-4" # optional
[... rest of the README remains the same with updated FAQ section ...]
📘 FAQ
Q: Which AI providers are supported? A: Currently OpenAI (GPT models) and Anthropic (Claude models) are supported, with more providers planned.
Q: How can I reduce API costs? A: Use GPT-3.5-Turbo or Claude-3-Sonnet for most queries, implement caching, and optimize token usage.
Q: Can I use custom models? A: Yes, you can configure custom endpoints and use any compatible model by specifying it in the configuration.
Q: How do I switch between different AI providers? A: Simply change the model parameter in your configuration or service calls to use the desired provider's model.
Q: How can I reduce API costs? A: Use GPT-3.5-Turbo for most queries, implement caching, and optimize token usage.
Q: Is my data secure? A: Yes, API keys are stored securely and data is transmitted via encrypted connections.
Q: Can I use custom models? A: Yes, configure custom endpoints and models via configuration options.
🤝 Contributing
Contributions welcome! Please read our Contributing Guide.
- Fork the repository
- Create feature branch (
git checkout -b feature/Enhancement) - Commit changes (
git commit -m 'Add Enhancement') - Push branch (
git push origin feature/Enhancement) - Open Pull Request
📝 License
MIT License - see LICENSE for details.
Made with ❤️ for the Home Assistant Community