diff --git a/README.md b/README.md
index acb42c0..247ff1d 100644
--- a/README.md
+++ b/README.md
@@ -1,29 +1,68 @@
# AI Automation Suggester
-
-
-[](https://github.com/ITSpecialist111/AI_AUTOMATION_SUGGESTER/releases)
-[](https://github.com/hacs/integration)
+[]()
+[]()
+[]()
+[]()
-An integration for Home Assistant that leverages AI models to analyze your entities and suggest potential automations. Now supporting multiple providers including OpenAI, Google, and local models for enhanced privacy.
+An integration for Home Assistant that leverages AI models to understand your unique home environment and propose intelligent automations. By analyzing your entities, devices, areas, and existing automations, the AI Automation Suggester helps you discover new, context-aware use cases you might not have considered, ultimately streamlining your home management and improving efficiency, comfort, and convenience.
---
-## Support the Project
+## Purpose and Problem Statement
+
+As a modern smart home grows in complexity—encompassing lights, sensors, locks, climate systems, cameras, and more—it can be challenging to figure out how these devices should interact to achieve a seamless, automated living experience. Many users find themselves overwhelmed by the sheer number of possibilities, unsure which triggers and conditions would genuinely enhance their daily routines.
-If you find this project helpful and would like to support its development, you can buy me a coffee!
+**This integration solves that challenge** by acting as a personal automation consultant. It taps into advanced AI language models to:
-
-
-
+- **Analyze your home’s state**: Understand what devices and sensors you have, their capabilities, and how they relate to one another.
+- **Identify opportunities for improvement**: Suggest automations that can save energy, improve security, enhance comfort, and reduce manual intervention.
+- **Provide step-by-step automation ideas**: Present actionable YAML-based automations that you can tweak and implement directly, cutting down the complexity of writing automations from scratch.
-Your support is greatly appreciated and helps maintain and improve this project!
+**In essence**, the AI Automation Suggester turns the complexity of a large Home Assistant environment into actionable insights and tangible benefits.
+
+---
+
+## The Solution and How It Works
+
+1. **Entity and Automation Analysis**:
+ The integration collects data on your Home Assistant entities (like sensors, switches, lights, and climate devices) and existing automations. It also pulls in device and area information for richer context. Instead of generic, one-size-fits-all suggestions, the AI can consider, for example, that a temperature sensor in the living room and a motion sensor in the hallway could jointly trigger specific lighting or climate adjustments.
+
+2. **AI-Powered Suggestions**:
+ By using cutting-edge AI models (OpenAI, Anthropic, Google, Groq, LocalAI, and Ollama), the integration transforms this snapshot of your home into meaningful suggestions. These suggestions can include:
+ - Energy-saving strategies: Turn off lights or appliances automatically when certain conditions are met.
+ - Security enhancements: Alert you if doors remain open too long or if certain presence conditions are detected.
+ - Comfort improvements: Adjust lights, climate, or media devices based on time of day, occupancy, or environmental conditions.
+ - Maintenance and convenience: Remind you when it's time to run appliances, or combine multiple conditions into a single efficient routine.
+
+3. **Prompt Customization and Scope Control**:
+ You’re not stuck with a single set of suggestions. Filter entities by domain, limit how many entities the AI considers, and provide custom prompts (e.g., "Focus on presence-based lighting control" or "Suggest cost-saving automations"). Randomized entity selection ensures that each analysis can present fresh ideas rather than repeating the same suggestions.
+
+4. **Integration with Your Workflow**:
+ Suggestions appear as persistent notifications, allowing you to review and implement them at your own pace. They’re presented as Home Assistant YAML snippets, making it straightforward to adapt and integrate them into your actual `automation.yaml` or UI-based automations.
+
+---
+
+## Expected Output and Benefits
+
+**Expected Output**:
+- **Actionable Automation Scenarios**: Concrete YAML examples that you can copy and paste into your Home Assistant configuration.
+- **Context-Aware Recommendations**: Ideas that consider both the location and capabilities of your devices, so you get realistic and tailored suggestions, not just generic advice.
+- **Optimized Home Management**: By refining the automations, you can reduce energy usage, enhance security, and increase convenience, turning your home into a more efficient and responsive environment.
+
+**Key Benefits**:
+- **Time Saving**: Cuts down the guesswork of designing automations from scratch.
+- **Improved Usability**: Makes Home Assistant more approachable for those without deep automation writing experience.
+- **Dynamic Inspiration**: Keeps your automations evolving as your home changes, devices are added, or new goals arise.
+- **Enhanced Control**: Custom prompts, entity limits, and domain filters give you command over what kinds of suggestions are generated.
---
## Table of Contents
-- [Background and Purpose](#background-and-purpose)
+- [Purpose and Problem Statement](#purpose-and-problem-statement)
+- [The Solution and How It Works](#the-solution-and-how-it-works)
+- [Expected Output and Benefits](#expected-output-and-benefits)
- [Features](#features)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
@@ -33,154 +72,73 @@ Your support is greatly appreciated and helps maintain and improve this project!
- [Usage](#usage)
- [Automatic Suggestions](#automatic-suggestions)
- [Manual Trigger](#manual-trigger)
- - [Example Automations](Example-Automations)
- - [Implementing Automations](#implementing-automations)
+- [Customization and Advanced Usage](#customization-and-advanced-usage)
+ - [Random Entity Selection](#random-entity-selection)
+ - [Domain Filtering](#domain-filtering)
+ - [Entity Limit](#entity-limit)
+ - [Custom Prompts](#custom-prompts)
+- [Implementing Automations](#implementing-automations)
- [Sensors](#sensors)
- [Important Notes](#important-notes)
- [Troubleshooting](#troubleshooting)
- [Roadmap](#roadmap)
- - [Future Enhancements](#future-enhancements)
- [License](#license)
- [Acknowledgments](#acknowledgments)
- [Contributions](#contributions)
- [Disclaimer](#disclaimer)
- [Support the Project](#support-the-project)
- [Additional Information](#additional-information)
-- [Frequently Asked Questions (FAQ)](#frequently-asked-questions-faq)
-
----
-
-## Background and Purpose
-
-Managing and automating devices in a smart home can be complex, especially as the number of devices grows. The **AI Automation Suggester** integration aims to simplify this process by leveraging AI models to analyze your entities in Home Assistant and provide intelligent automation suggestions.
+- [FAQ](#faq)
---
## Features
-- **Automatic Automation Suggestions**: Receive AI-generated automation ideas whenever new entities are added to your Home Assistant instance.
-- **Manual Analysis Trigger**: Allows you to manually trigger the AI analysis at any time, providing flexibility and control.
-- **Supports Multiple AI Providers**: Choose from a variety of AI models including OpenAI, Anthropic, Google, Groq, and local models like LocalAI and Ollama for privacy-focused users.
-- **Customizable Prompts**: Override the default system prompt to tailor the suggestions to your specific needs.
-- **Custom LLM Variants**: Users can select their preferred AI model variant, such as OpenAI's `gpt-3.5-turbo`.
-- **Persistent Notifications**: Suggestions are delivered via Home Assistant's persistent notifications.
-- **Sensor Entities**: Provides sensors to display the status of suggestions and provider connection status.
-- **German Translation**: Added support for German language to reach a global audience.
+- **Multi-Provider Support**: Use OpenAI, Anthropic, Google, Groq, LocalAI, or Ollama.
+- **Customizable Prompts and Filters**: Tailor suggestions to focus on energy saving, presence, or any theme of your choice.
+- **Randomized and Domain-Filtered Entities**: Control the pool of entities and prevent repetitive or too-generic suggestions.
+- **Context-Rich Insights**: Incorporates device and area registry info, making suggestions smarter and more relevant.
+- **Persistent Notifications**: Receive suggestions right in your Home Assistant interface.
---
## Prerequisites
-- **Home Assistant**: Version 2023.5 or later.
-- **API Keys**: Depending on the provider you choose, you may need API keys for OpenAI, Anthropic, Google, or Groq.
-- **Local AI Setup**: For LocalAI and Ollama, you need to have the respective servers running on your local network.
-
+- **Home Assistant:** Version 2023.5 or later.
+- **AI Provider Setup:**
+ For cloud providers (OpenAI, Anthropic, Google, Groq), you’ll need API keys.
+ For local models (LocalAI, Ollama), ensure the local servers are running.
+
---
## Installation
### Installing via HACS (Recommended)
-The easiest way to install the **AI Automation Suggester** is through [HACS (Home Assistant Community Store)](https://hacs.xyz/).
-
-#### **Step 1: Install HACS**
-
-If you haven't installed HACS yet, follow the [official installation guide](https://hacs.xyz/docs/setup/download) to set it up.
-
-#### **Step 2: Add Custom Repository**
-
-1. Open your Home Assistant instance.
-2. Navigate to **HACS** in the sidebar.
-3. Click on the **Integrations** tab.
-4. Click on the three-dot menu (⋮) in the top right corner.
-5. Select **Custom repositories**.
-
- 
-
-6. In the **Add custom repository URL** field, enter:
-
- ```
- https://github.com/ITSpecialist111/ai_automation_suggester
- ```
-
-7. In the **Category** dropdown, select **Integration**.
-8. Click **Add**.
-
-#### **Step 3: Install the Integration**
-
-1. After adding the repository, search for **AI Automation Suggester** in HACS.
-2. Click on the integration to view details.
-3. Click **Download** to install the integration.
-
-#### **Step 4: Restart Home Assistant**
-
-After installation, you need to restart Home Assistant for the integration to be recognized.
-
-1. Go to **Settings** > **System** > **Restart**.
-2. Click **Restart** and wait for Home Assistant to restart.
+1. **Install HACS** if not already done.
+2. **Add Custom Repository**:
+ In HACS > Integrations, add `https://github.com/ITSpecialist111/ai_automation_suggester`.
+3. **Install Integration** from HACS.
+4. **Restart Home Assistant**.
### Manual Installation
-If you prefer to install the integration manually, follow these steps:
-
-1. **Download the Integration**
-
- - Clone or download the `ai_automation_suggester` repository from GitHub.
-
-2. **Copy to Home Assistant**
-
- - Place the `ai_automation_suggester` directory inside the `custom_components` directory of your Home Assistant configuration folder.
- - Your directory structure should look like this:
-
- ```
- └── config/
- ├── configuration.yaml
- └── custom_components/
- └── ai_automation_suggester/
- ├── __init__.py
- ├── config_flow.py
- ├── const.py
- ├── coordinator.py
- ├── manifest.json
- ├── sensor.py
- ├── services.yaml
- ├── strings.json
- └── translations/
- ├── en.json
- └── de.json
- ```
-
- - If the `custom_components` directory doesn't exist, create it.
-
-3. **Restart Home Assistant**
-
- - After copying the files, restart Home Assistant to recognize the new integration.
+1. **Download** this repository.
+2. **Copy** `ai_automation_suggester` to `custom_components/`.
+3. **Restart Home Assistant**.
---
## Configuration
-### 1. **Add the Integration via Home Assistant UI**
-
-- Navigate to **Settings** > **Devices & Services**.
-- Click on **Add Integration**.
-- Search for **AI Automation Suggester** and select it.
-
-### 2. **Configure the Integration**
-
-- **Provider**: Choose your preferred AI provider from the list (OpenAI, Anthropic, Google, Groq, LocalAI, Ollama, or Custom OpenAI).
-- **API Key or Server Details**: Depending on the provider, you may need to enter an API key or provide server details for local models.
-- **Model Selection**: Choose the AI model variant you wish to use (e.g., OpenAI's `gpt-3.5-turbo`).
-- **Maximum Output Tokens**: Controls the length of the AI's response (default is 500). Increase if you need longer responses.
-- **Custom System Prompt**: (Optional) Override the built-in system prompt with your own for more granular control.
-
-### 3. **Obtain API Keys or Set Up Local AI Servers**
-
-- **OpenAI**: Obtain an API key from the [OpenAI Dashboard](https://platform.openai.com/account/api-keys).
-- **Anthropic**: Sign up for an API key at [Anthropic](https://www.anthropic.com/).
-- **Google**: Get an API key from the [Google Cloud Console](https://console.cloud.google.com/).
-- **Groq**: Register and obtain an API key from [Groq](https://groq.com/).
-- **LocalAI/Ollama**: Set up the respective servers on your local network.
+1. **Add Integration via UI**:
+ Go to Settings > Devices & Services > Add Integration > AI Automation Suggester.
+2. **Select Provider and Keys**:
+ Provide API keys or local model details as needed.
+3. **Set Model and Max Tokens**:
+ Choose your model variant and output length.
+4. **(Optional) Custom Prompt**:
+ Add a custom system prompt during integration setup or when triggering services.
---
@@ -188,353 +146,150 @@ If you prefer to install the integration manually, follow these steps:
### Automatic Suggestions
-Once configured, the integration will automatically generate automation suggestions when new entities are added to your Home Assistant instance. Suggestions are sent as persistent notifications.
+- **On New Entities**: The integration suggests automations whenever new entities are added, helping you quickly integrate them into your ecosystem.
+- **Weekly Reviews**: Example automations can trigger comprehensive scans weekly or at custom intervals.
### Manual Trigger
-You can manually trigger the AI analysis at any time:
+- **Service Call**:
+ Developer Tools > Services > `ai_automation_suggester.generate_suggestions`
+ - **all_entities**: Consider all or only new ones.
+ - **domains**: Limit to specific domains.
+ - **entity_limit**: Control how many entities to consider.
+ - **custom_prompt**: Steer suggestions towards energy saving, presence, or other goals.
-- Go to **Developer Tools** > **Services**.
-- Select `ai_automation_suggester.generate_suggestions` from the list.
-- In the service data, you can specify:
- - **Provider Configuration**: If you have multiple providers configured, select which one to use.
- - **Custom Prompt**: Provide a custom prompt to tailor the suggestions.
-- Click **Call Service**.
+---
-### Implementing Automations
+## Customization and Advanced Usage
-- Review the suggestions provided in the persistent notifications.
-- Implement the automations that suit your needs.
+### Random Entity Selection
----
-## Example Automations
-
-To help you get started, we provide two example automation files that demonstrate how to effectively use the AI Automation Suggester in your Home Assistant setup:
-
-1. **[New Entity Detection Automation](automations/ai_suggestions_new_entity.yaml)**
- ```yaml
- alias: "AI Suggestions - New Entity Detection"
- description: "Generates automation suggestions whenever new entities are registered in Home Assistant"
-
- trigger:
- - platform: event
- event_type: entity_registry_updated
- event_data:
- action: create
-
- # Optional: Trigger when an entity is updated
- - platform: event
- event_type: entity_registry_updated
- event_data:
- action: update
-
- condition:
- - condition: template
- value_template: >
- {% set last_triggered = state_attr('automation.ai_suggestions_new_entity_detection', 'last_triggered') %}
- {% if last_triggered %}
- {% set hours_since = ((now() - as_datetime(last_triggered)) | as_timedelta).total_seconds() / 3600 %}
- {{ hours_since > 1 }}
- {% else %}
- true
- {% endif %}
-
- action:
- - service: ai_automation_suggester.generate_suggestions
- target: {}
- data: {}
- ```
-
-2. **[Weekly System Review Automation](automations/ai_suggestions_weekly_review.yaml)**
- ```yaml
- alias: "AI Suggestions - Weekly Review"
- description: "Performs a weekly scan of all entities to suggest new automation opportunities"
-
- trigger:
- - platform: time
- at: "03:00:00"
-
- condition:
- - condition: time
- weekday:
- - sun
-
- action:
- - service: ai_automation_suggester.generate_suggestions
- target: {}
- data: {}
-
- - service: persistent_notification.create
- data:
- title: "Weekly Automation Review"
- message: "The AI Automation Suggester has completed its weekly review. Check the suggestions sensor for new automation ideas!"
- notification_id: "weekly_automation_review"
- ```
-
-### Key Features of the Automations
-
-#### New Entity Detection
-- Automatically triggers when new entities are added to Home Assistant
-- Includes optional trigger for entity updates
-- Built-in hour-long cooldown to prevent excessive API calls
-- Works with any configured AI provider
-- Simple and reliable implementation
-
-#### Weekly Review
-- Runs automatically every Sunday at 3 AM
-- Performs a comprehensive system review
-- Creates a notification when complete
-- Easy to customize schedule and frequency
-
-### Implementation Guide
-
-1. **Download the Automations**
- - Download both YAML files from the [automations folder](automations/)
- - Save them to your Home Assistant's automations directory
-
-2. **Installation Methods**
-
- **Option 1: Using automation.yaml**
- ```yaml
- # In your automation.yaml
- - !include automations/ai_suggestions_new_entity.yaml
- - !include automations/ai_suggestions_weekly_review.yaml
- ```
-
- **Option 2: Through the UI**
- - Go to Configuration → Automations
- - Click "+ Add Automation"
- - Choose "Import YAML"
- - Paste the content of each automation
-
-3. **Customization**
-
- New Entity Detection:
- - Remove the update trigger if you only want notifications for new entities
- - Adjust the cooldown period by changing the `hours_since > 1` value
-
- Weekly Review:
- - Change the `at` time to your preferred schedule
- - Modify the `weekday` condition to run on different days
-
-4. **Validation**
- - Check that the automations appear in your automations list
- - Verify they show as enabled
- - Test trigger conditions manually if desired
-
-### Notes
-
-- These automations are designed to work with any configured AI provider
-- They include built-in throttling to prevent excessive API usage
-- No custom prompts are required - the integration handles all the AI interaction
-- Notifications will appear in your Home Assistant interface
-- Monitor the automation status through the Home Assistant automations page
-
-### Troubleshooting
-
-If the automations aren't working as expected:
-1. Check that the AI Automation Suggester integration is properly configured
-2. Verify that the automation names match your configuration
-3. Ensure the services are available in your Home Assistant instance
-4. Check the Home Assistant logs for any error messages
+Ensures that each run may surface new or previously overlooked entities, sparking fresh automation ideas.
----
-## Sensors
+### Domain Filtering
-The integration provides two sensors:
+Focus suggestions on `light`, `sensor`, or any domain to refine the results and avoid irrelevant suggestions.
-- **AI Automation Suggestions**: Displays the status of suggestions and stores the latest suggestions in its attributes.
-- **AI Provider Status**: Shows the connection status of the AI provider.
+### Entity Limit
-### Adding to Lovelace Dashboard
+Set a maximum number of entities analyzed to avoid overwhelming the AI model or hitting token limits.
-You can display the suggestions on your dashboard using an **Entities** card:
+### Custom Prompts
-```yaml
-type: entities
-entities:
- - entity: sensor.ai_automation_suggestions
- - entity: sensor.ai_provider_status
-```
+Add directions like "Focus on cost-saving strategies" or "Emphasize presence-based lighting" to shape the AI’s recommendations to your current priorities.
---
-## Important Notes
-
-### **AI Provider API Key Security**
+## Implementing Automations
-- **Do Not Share Your API Keys**: Keep your API keys confidential.
-- **Revoking Compromised Keys**: If you suspect your API key has been compromised, revoke it immediately and generate a new one.
+- **Review Suggestions in Notifications**:
+ Each suggestion is a ready-to-use YAML snippet.
+- **Copy and Adapt**:
+ Paste suggestions into your `automation.yaml` or edit via the UI. Adjust triggers, conditions, or actions as needed.
-### **API Usage**
+---
-- **Costs**: Using AI provider APIs may incur costs. Monitor your usage in your provider's dashboard.
-- **Usage Limits**: Set usage limits in your account to avoid unexpected charges.
+## Sensors
-### **Compatibility**
+- **AI Automation Suggestions Sensor**:
+ Displays the current suggestion status and stores the latest suggestions.
+- **AI Provider Status Sensor**:
+ Indicates the connection health with your chosen AI provider.
-- **Home Assistant Version**: Ensure you are running Home Assistant version 2023.5 or later.
-- **Local AI Models**: If using local models, ensure your local servers are correctly set up and accessible.
+---
-### **Data Privacy**
+## Important Notes
-- **Data Sent to AI Providers**: The integration sends entity information to the selected AI provider's API for analysis.
-- **User Consent**: By using this integration, you consent to this data being sent to the chosen AI provider.
+- **Privacy Considerations**:
+ Cloud-based AI providers receive entity data. Consider local providers for full data control.
+- **API Costs**:
+ Some providers charge for API usage. Monitor your usage and configure limits.
+- **No Guarantees**:
+ Suggestions are best-effort. Always review before implementing them in your live system.
---
## Troubleshooting
-### **Common Issues**
-
-1. **API Errors**
-
- - **Symptom**: Error messages related to AI provider APIs in notifications or logs.
- - **Solution**:
- - Verify your API key or server details are correct.
- - Ensure your API key has not expired or been revoked.
- - Check your account for any usage limits or account issues.
- - If using local models, ensure the server is running and accessible.
-
-2. **Integration Not Showing Up**
-
- - **Symptom**: After installation, the integration doesn't appear in Home Assistant.
- - **Solution**:
- - Ensure the `ai_automation_suggester` directory is in the correct location.
- - Restart Home Assistant after adding the custom component.
- - Check the logs for any errors during startup.
-
-3. **No Suggestions Generated**
-
- - **Symptom**: The integration doesn't generate any suggestions.
- - **Solution**:
- - Ensure new entities have been added to trigger automatic suggestions.
- - Manually trigger the service `ai_automation_suggester.generate_suggestions`.
- - Check if you have provided the necessary service data.
- - Review logs for any errors during the analysis.
-
-4. **Dependency Issues**
-
- - **Symptom**: Errors related to missing dependencies or incorrect versions.
- - **Solution**:
- - Ensure all required libraries are installed.
- - Clear Home Assistant's cache by deleting the `deps` directory and restart.
-
-### **Logging and Debugging**
-
-- Enable debug logging for more detailed information:
-
- ```yaml
- logger:
- default: warning
- logs:
- custom_components.ai_automation_suggester: debug
- ```
-
-- View logs under **Settings** > **System** > **Logs**.
+- **No Suggestions?**
+ Check logs, verify API keys, try manually triggering the service.
+- **Prompt Too Long?**
+ Reduce `entity_limit`, filter domains, or shorten your prompt.
+- **Unintended Startup Suggestions?**
+ Ensure no automations or events call `generate_suggestions` on startup.
---
## Roadmap
-### **Future Enhancements**
-
-1. **Interactive Suggestion Management**
-
- - **User Feedback Mechanism**: Allow users to provide feedback on suggestions to improve future results.
- - **Detailed Implementation Guides**: Provide step-by-step instructions for implementing suggested automations.
-
-2. **Automated Automation Creation**
-
- - **One-Click Deployment**: Enable users to automatically implement suggested automations.
- - **Safety Measures**: Implement safeguards to ensure automations are created securely.
-
-3. **Enhanced Localization**
-
- - **Additional Language Support**: Expand language support beyond English and German.
- - **Community Translations**: Collaborate with the community for translations and localization efforts.
-
-4. **Community Integration Sharing**
-
- - **Platform for Sharing**: Allow users to share their automations and suggestions with the community.
- - **Moderation and Quality Control**: Implement mechanisms to ensure shared content is valuable and safe.
+- **More Interactive Suggestions**:
+ Potential feedback mechanisms to improve future recommendations.
+- **One-Click Automation Creation**:
+ Streamline from suggestions directly to implemented automations.
+- **Expanded Localization**:
+ Support for more languages and community-driven translations.
---
## License
-This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
+This project is licensed under the MIT License. See LICENSE for details.
---
## Acknowledgments
-- **Home Assistant Community**: For providing an amazing platform and community support.
-- **AI Providers**: OpenAI, Anthropic, Google, Groq, LocalAI, and Ollama for their AI models and APIs.
+- **Home Assistant Community**: For a flexible and powerful platform.
+- **AI Providers**: OpenAI, Anthropic, Google, Groq, LocalAI, Ollama for enabling these capabilities.
+- **Contributors and Users**: Providing feedback and helping guide improvements.
---
## Contributions
-Contributions are welcome! Please open an issue or submit a pull request on [GitHub](https://github.com/ITSpecialist111/ai_automation_suggester).
+We welcome pull requests, feature suggestions, and translations. Please open an issue or submit a PR on GitHub.
---
## Disclaimer
-This integration is a third-party custom component and is not affiliated with or endorsed by Home Assistant or any of the AI providers.
+This is a custom component, not affiliated with or endorsed by Home Assistant or the AI providers mentioned.
---
## Support the Project
-If you find this project helpful and would like to support its development, you can buy me a coffee!
+If you find this helpful, consider supporting development:
-
-
-
+[Buy Me A Coffee](https://www.buymeacoffee.com/ITSpecialist111)
-Your support is greatly appreciated and helps maintain and improve this project!
+Your support helps maintain and enhance this project!
---
## Additional Information
-For any questions or support, please open an issue on [GitHub](https://github.com/ITSpecialist111/ai_automation_suggester/issues).
+For questions or issues, open an issue on GitHub. We appreciate user feedback to guide future improvements.
---
-## Frequently Asked Questions (FAQ)
-
-### **1. How do I update the integration when a new version is released?**
-
-- If installed via HACS, you can update the integration through the HACS interface:
- - Navigate to **HACS** > **Integrations**.
- - Find **AI Automation Suggester** in the list.
- - If an update is available, click **Update**.
-
-### **2. Can I use this integration without an API key?**
+## FAQ
-- Yes, if you choose to use local AI models like LocalAI or Ollama, you do not need an external API key. However, you need to have the local servers set up and running.
+1. **How do I update the integration?**
+ If installed via HACS, update through the HACS interface. Otherwise, replace the files manually and restart.
-### **3. Is my data safe when using this integration?**
+2. **Can I use it without an API key?**
+ Yes, if you choose LocalAI or Ollama, no external API keys are required.
-- The integration sends entity information to the selected AI provider's API for analysis. If you use local models, your data remains within your local network. For cloud providers, you should review their privacy policies to understand how your data is handled.
+3. **Is my data safe?**
+ Using local models keeps data local. For cloud providers, refer to their privacy policies.
-### **4. I found a bug or have a feature request. How can I contribute?**
+4. **I found a bug or have a feature request.**
+ Open an issue on GitHub. Your feedback is valuable.
-- Please open an issue on the [GitHub repository](https://github.com/ITSpecialist111/ai_automation_suggester/issues) with details about the bug or your feature request.
-
-### **5. How can I add support for another language?**
-
-- We welcome community contributions for translations. Please submit a pull request with the new language files in the `translations` directory.
-
-### **6. How does the automatic suggestion generation work?**
-
-- The integration monitors for new entities added to your Home Assistant instance. When new entities are detected, it automatically generates automation suggestions using the configured AI provider.
+5. **Can I get suggestions in languages other than English?**
+ English and German are included. We welcome community translations!
---
-# End of README
-
-Feel free to reach out if you need further assistance or have any other questions!
\ No newline at end of file
+With the AI Automation Suggester, you gain an AI-powered ally to help you unlock your home’s full potential. Instead of being overwhelmed by possibilities, receive thoughtful, context-aware suggestions that make your Home Assistant automations more impactful, efficient, and enjoyable.
diff --git a/custom_components/ai_automation_suggester/__init__.py b/custom_components/ai_automation_suggester/__init__.py
index 3eaacd7..0565af9 100644
--- a/custom_components/ai_automation_suggester/__init__.py
+++ b/custom_components/ai_automation_suggester/__init__.py
@@ -1,7 +1,7 @@
"""The AI Automation Suggester integration."""
import logging
from homeassistant.config_entries import ConfigEntry
-from homeassistant.core import HomeAssistant, ServiceCall
+from homeassistant.core import HomeAssistant, ServiceCall, callback
from homeassistant.exceptions import ConfigEntryNotReady, ServiceValidationError
from homeassistant.helpers.typing import ConfigType
@@ -18,45 +18,19 @@
_LOGGER = logging.getLogger(__name__)
-
async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
- """Migrate old entry."""
+ """Migrate old config entry if necessary."""
_LOGGER.debug(f"async_migrate_entry {config_entry.version}")
- if config_entry.version > CONFIG_VERSION:
- # This means the user has downgraded from a future version
- # Need to add scheduling fields back in
- _LOGGER.debug("Downgrading config entry from version %s to version %s", config_entry.version, CONFIG_VERSION)
-
- new_data = {**config_entry.data}
- new_data['scan_frequency'] = config_entry.data.get('scan_frequency')
- new_data['initial_lag_time'] = config_entry.data.get('initial_lag_time')
-
- config_entry.version = 1
- hass.config_entries.async_update_entry(config_entry, data=new_data)
-
- _LOGGER.debug("Downgrade migration to version %s successful", config_entry.version)
- return False
-
- if config_entry.version == CONFIG_VERSION:
- # This means the major version still matches. We don't currently use minor versions for config.
- return True
-
+ # Currently, no migration logic beyond ensuring version matches CONFIG_VERSION
if config_entry.version < CONFIG_VERSION:
- _LOGGER.debug(f"Migrating config entry from version {config_entry.version} to version {CONFIG_VERSION}")
+ _LOGGER.debug(f"Migrating config entry from version {config_entry.version} to {CONFIG_VERSION}")
new_data = {**config_entry.data}
-
- # Remove old scheduling fields that are no longer used
new_data.pop('scan_frequency', None)
new_data.pop('initial_lag_time', None)
-
- # Update to current version
config_entry.version = CONFIG_VERSION
hass.config_entries.async_update_entry(config_entry, data=new_data)
-
- _LOGGER.debug("Migration to version %s successful", config_entry.version)
+ _LOGGER.debug("Migration successful")
return True
-
- _LOGGER.debug("No migration required for version %s", config_entry.version)
return True
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
@@ -67,11 +41,21 @@ async def handle_generate_suggestions(call: ServiceCall) -> None:
"""Handle the generate_suggestions service call."""
provider_config = call.data.get(ATTR_PROVIDER_CONFIG)
custom_prompt = call.data.get(ATTR_CUSTOM_PROMPT)
-
+ all_entities = call.data.get("all_entities", False)
+ domains = call.data.get("domains", {})
+ entity_limit = call.data.get("entity_limit", 200)
+
+ # Parse domains if it's provided as a string or dict
+ if isinstance(domains, str):
+ domains = [d.strip() for d in domains.split(',') if d.strip()]
+ elif isinstance(domains, dict):
+ # If user provided a dict, convert keys to a list of domains
+ domains = list(domains.keys())
+
try:
coordinator = None
if provider_config:
- coordinator = hass.data[DOMAIN][provider_config]
+ coordinator = hass.data[DOMAIN].get(provider_config)
else:
# Find first available coordinator if no specific one is specified
for entry_id, coord in hass.data[DOMAIN].items():
@@ -83,17 +67,29 @@ async def handle_generate_suggestions(call: ServiceCall) -> None:
raise ServiceValidationError("No AI Automation Suggester provider configured")
if custom_prompt:
+ # Append the custom prompt to the system prompt
original_prompt = coordinator.SYSTEM_PROMPT
- try:
- coordinator.SYSTEM_PROMPT = custom_prompt
- await coordinator.async_request_refresh()
- finally:
- coordinator.SYSTEM_PROMPT = original_prompt
+ coordinator.SYSTEM_PROMPT = f"{coordinator.SYSTEM_PROMPT}\n\nAdditional instructions:\n{custom_prompt}"
else:
+ original_prompt = None
+
+ # Set the scan_all and filtering options before calling async_request_refresh
+ coordinator.scan_all = all_entities
+ coordinator.selected_domains = domains
+ coordinator.entity_limit = entity_limit
+
+ try:
await coordinator.async_request_refresh()
+ finally:
+ # Restore original prompt and reset parameters
+ if original_prompt is not None:
+ coordinator.SYSTEM_PROMPT = original_prompt
+ coordinator.scan_all = False
+ coordinator.selected_domains = []
+ coordinator.entity_limit = 200
except KeyError:
- raise ServiceValidationError(f"Provider configuration not found")
+ raise ServiceValidationError("Provider configuration not found")
except Exception as err:
raise ServiceValidationError(f"Failed to generate suggestions: {err}")
@@ -123,13 +119,26 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
raise ConfigEntryNotReady from err
_LOGGER.debug(
- "Setup complete for %s with provider %s",
- entry.title,
+ "Setup complete for %s with provider %s",
+ entry.title,
entry.data.get(CONF_PROVIDER)
)
entry.async_on_unload(entry.add_update_listener(async_reload_entry))
-
+
+ # Example of using the event bus to trigger suggestions:
+ @callback
+ def handle_custom_event(event):
+ _LOGGER.debug("Received custom event '%s', triggering suggestions with all_entities=True", event.event_type)
+ hass.async_create_task(coordinator_request_all_suggestions())
+
+ async def coordinator_request_all_suggestions():
+ coordinator.scan_all = True
+ await coordinator.async_request_refresh()
+ coordinator.scan_all = False
+
+ entry.async_on_unload(hass.bus.async_listen("ai_automation_suggester_update", handle_custom_event))
+
return True
except Exception as err:
@@ -140,7 +149,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Unload a config entry."""
try:
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
-
+
if unload_ok:
coordinator = hass.data[DOMAIN].pop(entry.entry_id)
await coordinator.async_shutdown()
@@ -154,4 +163,4 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_reload_entry(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Reload config entry."""
await async_unload_entry(hass, entry)
- await async_setup_entry(hass, entry)
\ No newline at end of file
+ await async_setup_entry(hass, entry)
diff --git a/custom_components/ai_automation_suggester/automations/weekly-review-automation.yaml b/custom_components/ai_automation_suggester/automations/weekly-review-automation.yaml
index 918895a..636da64 100644
--- a/custom_components/ai_automation_suggester/automations/weekly-review-automation.yaml
+++ b/custom_components/ai_automation_suggester/automations/weekly-review-automation.yaml
@@ -26,14 +26,14 @@ condition:
- sun
action:
- # Generate suggestions using the configured provider(s)
+ # Generate suggestions using the configured provider(s), scanning all entities
- service: ai_automation_suggester.generate_suggestions
- target: {}
- data: {}
+ data:
+ all_entities: true
# Create a notification
- service: persistent_notification.create
data:
title: "Weekly Automation Review"
message: "The AI Automation Suggester has completed its weekly review. Check the suggestions sensor for new automation ideas!"
- notification_id: "weekly_automation_review"
\ No newline at end of file
+ notification_id: "weekly_automation_review"
diff --git a/custom_components/ai_automation_suggester/coordinator.py b/custom_components/ai_automation_suggester/coordinator.py
index bdf89a1..0358aa1 100644
--- a/custom_components/ai_automation_suggester/coordinator.py
+++ b/custom_components/ai_automation_suggester/coordinator.py
@@ -2,14 +2,15 @@
"""Coordinator for AI Automation Suggester."""
import logging
+import random
from datetime import datetime
-import aiohttp
-import json
from homeassistant.components import persistent_notification
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from homeassistant.helpers.aiohttp_client import async_get_clientsession
+from homeassistant.helpers import device_registry as dr, entity_registry as er, area_registry as ar
+
from .const import (
DOMAIN,
CONF_PROVIDER,
@@ -48,26 +49,21 @@
_LOGGER = logging.getLogger(__name__)
SYSTEM_PROMPT = """You are an AI assistant that generates Home Assistant automations
-based on the types of new entities discovered in the system. Your goal
-is to provide detailed and useful automation suggestions tailored to
-the specific types and functions of the entities, avoiding generic recommendations.
+based on the types of entities, their areas, and their associated devices, as well as
+improving or suggesting new automations based on existing ones.
For each entity:
-1. Understand its function (e.g., sensor, switch, light, climate control).
-2. Consider its current state (e.g., 'on', 'off', 'open', 'closed', 'temperature').
-3. Suggest automations based on common use cases for similar entities.
-4. Avoid generic suggestions. Instead, provide detailed scenarios such as:
- - 'If the front door sensor detects it is open for more than 5 minutes, send a notification.'
- - 'If no motion is detected for 10 minutes, turn off all lights.'
- - 'If the temperature sensor detects a rise above 25°C, turn on the air conditioner.'
-5. Consider combining multiple entities to create context-aware automations.
-6. Include appropriate conditions and triggers for time of day, presence, or other contextual factors.
-7. Format suggestions in clear, implementable steps.
-8. When suggesting scenes, include all relevant entities that should be controlled.
-9. Consider energy efficiency and user convenience in your suggestions.
-10. Include the actual entity IDs in your suggestions so they can be easily implemented.
-11. Suggest automations that make sense based on the entity's domain and capabilities.
-12. Consider security implications for sensitive automations (like doors or windows)."""
+1. Understand its function, area, and device context.
+2. Consider its current state and attributes.
+3. Suggest contextually aware automations and improvements to existing automations.
+4. Include actual entity IDs in your suggestions.
+
+When focusing on custom aspects (like energy-saving or presence-based lighting),
+integrate those themes into the automations. Provide triggers, conditions,
+and detailed actions to refine the automations according to the instructions given in the custom prompt.
+
+Also consider existing automations and how they can be improved or complemented.
+"""
class AIAutomationCoordinator(DataUpdateCoordinator):
"""Class to manage fetching data from AI model."""
@@ -79,8 +75,10 @@ def __init__(self, hass: HomeAssistant, entry) -> None:
self.previous_entities = {}
self.last_update = None
self.SYSTEM_PROMPT = SYSTEM_PROMPT
+ self.scan_all = False # Flag to consider all entities
+ self.selected_domains = [] # Filter to specified domains if provided
+ self.entity_limit = 200 # Limit number of entities considered
- # Initialize data
self.data = {
"suggestions": "No suggestions yet",
"last_update": None,
@@ -90,21 +88,23 @@ def __init__(self, hass: HomeAssistant, entry) -> None:
# Prevent automatic updates by setting update_interval to None
self.update_interval = None
-
self.session = async_get_clientsession(hass)
- super().__init__(
- hass,
- _LOGGER,
- name=DOMAIN,
- update_interval=self.update_interval,
- )
+ self.device_registry = None
+ self.entity_registry = None
+ self.area_registry = None
+
+ super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=self.update_interval)
+
+ async def async_added_to_hass(self):
+ await super().async_added_to_hass()
+ self.device_registry = dr.async_get(self.hass)
+ self.entity_registry = er.async_get(self.hass)
+ self.area_registry = ar.async_get(self.hass)
async def _async_update_data(self):
- """Fetch data from AI model."""
try:
current_time = datetime.now()
-
_LOGGER.debug("Starting manual update at %s", current_time)
self.last_update = current_time
@@ -114,6 +114,12 @@ async def _async_update_data(self):
try:
current_entities = {}
for entity_id in self.hass.states.async_entity_ids():
+ # If user provided domains to filter, only include those domains
+ if self.selected_domains:
+ domain = entity_id.split('.')[0]
+ if domain not in self.selected_domains:
+ continue
+
state = self.hass.states.get(entity_id)
if state is not None:
friendly_name = state.attributes.get('friendly_name', entity_id)
@@ -128,52 +134,52 @@ async def _async_update_data(self):
_LOGGER.error("Error fetching entities: %s", err)
return self.data
- # Detect newly added entities
- new_entities = {
- k: v for k, v in current_entities.items()
- if k not in self.previous_entities
- }
+ if self.scan_all:
+ selected_entities = current_entities
+ else:
+ # Only consider new entities if scan_all is False
+ selected_entities = {
+ k: v for k, v in current_entities.items()
+ if k not in self.previous_entities
+ }
- if not new_entities:
- _LOGGER.debug("No new entities detected")
+ if not selected_entities:
+ _LOGGER.debug("No entities selected for suggestions")
+ self.previous_entities = current_entities
return self.data
- # Limit processing to 10 entities if needed
- if len(new_entities) > 10:
- _LOGGER.debug("Limiting to 10 entities for processing")
- new_entities = dict(list(new_entities.items())[:10])
-
- # Prepare AI input
- ai_input_data = self.prepare_ai_input(new_entities)
-
- # Get suggestions from AI
+ ai_input_data = self.prepare_ai_input(selected_entities)
suggestions = await self.get_ai_suggestions(ai_input_data)
-
+
if suggestions:
_LOGGER.debug("Received suggestions: %s", suggestions)
try:
- # Create notification only if suggestions is not None
persistent_notification.async_create(
self.hass,
message=suggestions,
title="AI Automation Suggestions",
notification_id=f"ai_automation_suggestions_{current_time.timestamp()}"
)
-
- # Update data regardless of notification success
+
self.data = {
"suggestions": suggestions,
"last_update": current_time,
- "entities_processed": list(new_entities.keys()),
+ "entities_processed": list(selected_entities.keys()),
"provider": self.entry.data.get(CONF_PROVIDER, "unknown")
}
+
+ await self.hass.services.async_call(
+ "logbook",
+ "log",
+ {"name": "AI Automation Suggester", "message": "New suggestions generated"}
+ )
+
except Exception as err:
_LOGGER.error("Error creating notification: %s", err)
- # Still update data even if notification fails
self.data = {
"suggestions": suggestions,
"last_update": current_time,
- "entities_processed": list(new_entities.keys()),
+ "entities_processed": list(selected_entities.keys()),
"provider": self.entry.data.get(CONF_PROVIDER, "unknown")
}
else:
@@ -185,53 +191,127 @@ async def _async_update_data(self):
"provider": self.entry.data.get(CONF_PROVIDER, "unknown")
}
- # Always update previous entities list
self.previous_entities = current_entities
-
return self.data
except Exception as err:
_LOGGER.error("Unexpected error in update: %s", err)
return self.data
- def prepare_ai_input(self, new_entities):
- """Prepare the input data for AI processing."""
- _LOGGER.debug("Preparing AI input for %d entities", len(new_entities))
-
+ def prepare_ai_input(self, entities):
+ _LOGGER.debug("Preparing AI input for %d entities", len(entities))
+
+ MAX_ATTR_LENGTH = 500
+ MAX_AUTOMATIONS = 100
+
+ # Randomly pick entities up to entity_limit
+ entity_list = list(entities.items())
+ selected_entities = random.sample(entity_list, min(len(entity_list), self.entity_limit))
+
entities_description = []
- for entity_id, entity_data in new_entities.items():
+ for entity_id, entity_data in selected_entities:
state = entity_data.get('state', 'unknown')
attributes = entity_data.get('attributes', {})
friendly_name = entity_data.get('friendly_name', entity_id)
domain = entity_id.split('.')[0]
-
- # Enhanced entity description
+
+ attr_str = str(attributes)
+ if len(attr_str) > MAX_ATTR_LENGTH:
+ attr_str = attr_str[:MAX_ATTR_LENGTH] + "...(truncated)"
+
+ ent_reg_entry = self.entity_registry.async_get(entity_id) if self.entity_registry else None
+ device_info = None
+ area_name = "Unknown Area"
+ if ent_reg_entry:
+ if ent_reg_entry.device_id and self.device_registry:
+ dev_reg_entry = self.device_registry.async_get(ent_reg_entry.device_id)
+ if dev_reg_entry:
+ device_info = {
+ "manufacturer": dev_reg_entry.manufacturer,
+ "model": dev_reg_entry.model,
+ "name": dev_reg_entry.name_by_user or dev_reg_entry.name,
+ "id": dev_reg_entry.id
+ }
+
+ area_id = ent_reg_entry.area_id or (dev_reg_entry.area_id if dev_reg_entry and dev_reg_entry.area_id else None)
+ if area_id and self.area_registry:
+ area_entry = self.area_registry.async_get_area(area_id)
+ if area_entry:
+ area_name = area_entry.name
+
description = (
f"Entity: {entity_id}\n"
f"Friendly Name: {friendly_name}\n"
f"Domain: {domain}\n"
f"State: {state}\n"
- f"Attributes: {attributes}\n"
+ f"Attributes: {attr_str}\n"
+ f"Area: {area_name}\n"
+ )
+
+ if device_info:
+ description += (
+ f"Device Info:\n"
+ f" Manufacturer: {device_info['manufacturer']}\n"
+ f" Model: {device_info['model']}\n"
+ f" Device Name: {device_info['name']}\n"
+ f" Device ID: {device_info['id']}\n"
+ )
+
+ description += (
f"Last Changed: {entity_data.get('last_changed', 'unknown')}\n"
f"Last Updated: {entity_data.get('last_updated', 'unknown')}\n"
f"---\n"
)
entities_description.append(description)
+ # Gather existing automations, truncated
+ automation_entities = []
+ for auto_id in self.hass.states.async_entity_ids('automation'):
+ state = self.hass.states.get(auto_id)
+ if state is not None:
+ friendly_name = state.attributes.get('friendly_name', auto_id)
+ automation_entities.append({
+ 'entity_id': auto_id,
+ 'friendly_name': friendly_name,
+ 'state': state.state,
+ 'attributes': state.attributes
+ })
+
+ automation_entities = automation_entities[:MAX_AUTOMATIONS]
+
+ automation_description = "Existing Automations:\n"
+ if automation_entities:
+ for auto in automation_entities:
+ auto_attr_str = str(auto['attributes'])
+ if len(auto_attr_str) > MAX_ATTR_LENGTH:
+ auto_attr_str = auto_attr_str[:MAX_ATTR_LENGTH] + "...(truncated)"
+
+ automation_description += (
+ f"Entity: {auto['entity_id']}\n"
+ f"Friendly Name: {auto['friendly_name']}\n"
+ f"State: {auto['state']}\n"
+ f"Attributes: {auto_attr_str}\n"
+ f"---\n"
+ )
+ else:
+ automation_description += "None found.\n"
+
prompt = (
f"{self.SYSTEM_PROMPT}\n\n"
- f"New entities discovered:\n"
- f"{''.join(entities_description)}\n"
- f"Please suggest detailed and specific automations for these entities, "
- f"using their exact entity IDs in the suggestions."
+ f"Entities in your Home Assistant (randomly selected and possibly domain-filtered):\n"
+ f"{''.join(entities_description)}\n\n"
+ f"{automation_description}\n\n"
+ f"Please suggest detailed, specific automations and improvements, "
+ f"considering device and area context. Only reference the entities provided above. "
+ f"Adjust triggers, conditions, and actions to refine the automations according to the provided instructions."
)
+
return prompt
async def get_ai_suggestions(self, prompt):
- """Get suggestions from the configured AI provider."""
provider = self.entry.data.get(CONF_PROVIDER, "OpenAI")
_LOGGER.debug("Using AI provider: %s", provider)
-
+
try:
if provider == "OpenAI":
return await self.process_with_openai(prompt)
@@ -255,23 +335,22 @@ async def get_ai_suggestions(self, prompt):
return None
async def process_with_openai(self, prompt):
- """Process the prompt with OpenAI."""
try:
api_key = self.entry.data.get(CONF_OPENAI_API_KEY)
model = self.entry.data.get(CONF_OPENAI_MODEL, DEFAULT_MODELS["OpenAI"])
max_tokens = self.entry.data.get(CONF_MAX_TOKENS, DEFAULT_MAX_TOKENS)
-
+
if not api_key:
raise ValueError("OpenAI API key not configured")
- _LOGGER.debug("Making OpenAI API request with model %s and max_tokens %d",
- model, max_tokens)
-
+ _LOGGER.debug("Making OpenAI API request with model %s and max_tokens %d",
+ model, max_tokens)
+
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
-
+
data = {
"model": model,
"messages": [
@@ -280,7 +359,7 @@ async def process_with_openai(self, prompt):
"max_tokens": max_tokens,
"temperature": DEFAULT_TEMPERATURE
}
-
+
async with self.session.post(
ENDPOINT_OPENAI,
headers=headers,
@@ -290,7 +369,7 @@ async def process_with_openai(self, prompt):
error_text = await response.text()
_LOGGER.error("OpenAI API error: %s", error_text)
return None
-
+
result = await response.json()
return result["choices"][0]["message"]["content"]
@@ -299,24 +378,23 @@ async def process_with_openai(self, prompt):
return None
async def process_with_anthropic(self, prompt):
- """Process the prompt with Anthropic."""
try:
api_key = self.entry.data.get(CONF_ANTHROPIC_API_KEY)
model = self.entry.data.get(CONF_ANTHROPIC_MODEL, DEFAULT_MODELS["Anthropic"])
max_tokens = self.entry.data.get(CONF_MAX_TOKENS, DEFAULT_MAX_TOKENS)
-
+
if not api_key:
raise ValueError("Anthropic API key not configured")
- _LOGGER.debug("Making Anthropic API request with model %s and max_tokens %d",
- model, max_tokens)
-
+ _LOGGER.debug("Making Anthropic API request with model %s and max_tokens %d",
+ model, max_tokens)
+
headers = {
"Content-Type": "application/json",
"X-API-Key": api_key,
"anthropic-version": VERSION_ANTHROPIC
}
-
+
data = {
"model": model,
"messages": [
@@ -325,7 +403,7 @@ async def process_with_anthropic(self, prompt):
"max_tokens": max_tokens,
"temperature": DEFAULT_TEMPERATURE
}
-
+
async with self.session.post(
ENDPOINT_ANTHROPIC,
headers=headers,
@@ -335,7 +413,7 @@ async def process_with_anthropic(self, prompt):
error_text = await response.text()
_LOGGER.error("Anthropic API error: %s", error_text)
return None
-
+
result = await response.json()
return result["content"][0]["text"]
@@ -344,21 +422,20 @@ async def process_with_anthropic(self, prompt):
return None
async def process_with_google(self, prompt):
- """Process the prompt with Google."""
try:
api_key = self.entry.data.get(CONF_GOOGLE_API_KEY)
model = self.entry.data.get(CONF_GOOGLE_MODEL, DEFAULT_MODELS["Google"])
max_tokens = self.entry.data.get(CONF_MAX_TOKENS, DEFAULT_MAX_TOKENS)
-
+
if not api_key:
raise ValueError("Google API key not configured")
_LOGGER.debug("Making Google API request with model %s", model)
-
+
headers = {
"Content-Type": "application/json",
}
-
+
data = {
"contents": [
{
@@ -376,9 +453,9 @@ async def process_with_google(self, prompt):
"topP": 0.95,
}
}
-
+
endpoint = f"https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={api_key}"
-
+
async with self.session.post(
endpoint,
headers=headers,
@@ -388,7 +465,7 @@ async def process_with_google(self, prompt):
error_text = await response.text()
_LOGGER.error("Google API error: %s", error_text)
return None
-
+
result = await response.json()
try:
return result["candidates"][0]["content"]["parts"][0]["text"]
@@ -401,23 +478,22 @@ async def process_with_google(self, prompt):
return None
async def process_with_groq(self, prompt):
- """Process the prompt with Groq."""
try:
api_key = self.entry.data.get(CONF_GROQ_API_KEY)
model = self.entry.data.get(CONF_GROQ_MODEL, DEFAULT_MODELS["Groq"])
max_tokens = self.entry.data.get(CONF_MAX_TOKENS, DEFAULT_MAX_TOKENS)
-
+
if not api_key:
raise ValueError("Groq API key not configured")
- _LOGGER.debug("Making Groq API request with model %s and max_tokens %d",
- model, max_tokens)
-
+ _LOGGER.debug("Making Groq API request with model %s and max_tokens %d",
+ model, max_tokens)
+
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
-
+
data = {
"messages": [
{
@@ -431,7 +507,7 @@ async def process_with_groq(self, prompt):
"max_tokens": max_tokens,
"temperature": DEFAULT_TEMPERATURE
}
-
+
async with self.session.post(
ENDPOINT_GROQ,
headers=headers,
@@ -441,7 +517,7 @@ async def process_with_groq(self, prompt):
error_text = await response.text()
_LOGGER.error("Groq API error: %s", error_text)
return None
-
+
result = await response.json()
return result["choices"][0]["message"]["content"]
@@ -450,14 +526,13 @@ async def process_with_groq(self, prompt):
return None
async def process_with_localai(self, prompt):
- """Process the prompt with LocalAI."""
try:
ip_address = self.entry.data.get(CONF_LOCALAI_IP_ADDRESS)
port = self.entry.data.get(CONF_LOCALAI_PORT)
https = self.entry.data.get(CONF_LOCALAI_HTTPS, False)
model = self.entry.data.get(CONF_LOCALAI_MODEL, DEFAULT_MODELS["LocalAI"])
max_tokens = self.entry.data.get(CONF_MAX_TOKENS, DEFAULT_MAX_TOKENS)
-
+
if not ip_address or not port:
raise ValueError("LocalAI configuration incomplete")
@@ -467,10 +542,10 @@ async def process_with_localai(self, prompt):
ip_address=ip_address,
port=port
)
-
- _LOGGER.debug("Making LocalAI API request to %s with model %s and max_tokens %d",
- endpoint, model, max_tokens)
-
+
+ _LOGGER.debug("Making LocalAI API request to %s with model %s and max_tokens %d",
+ endpoint, model, max_tokens)
+
data = {
"model": model,
"messages": [
@@ -479,7 +554,7 @@ async def process_with_localai(self, prompt):
"max_tokens": max_tokens,
"temperature": DEFAULT_TEMPERATURE
}
-
+
async with self.session.post(
endpoint,
json=data
@@ -488,7 +563,7 @@ async def process_with_localai(self, prompt):
error_text = await response.text()
_LOGGER.error("LocalAI API error: %s", error_text)
return None
-
+
result = await response.json()
return result["choices"][0]["message"]["content"]
@@ -497,14 +572,13 @@ async def process_with_localai(self, prompt):
return None
async def process_with_ollama(self, prompt):
- """Process the prompt with Ollama."""
try:
ip_address = self.entry.data.get(CONF_OLLAMA_IP_ADDRESS)
port = self.entry.data.get(CONF_OLLAMA_PORT)
https = self.entry.data.get(CONF_OLLAMA_HTTPS, False)
model = self.entry.data.get(CONF_OLLAMA_MODEL, DEFAULT_MODELS["Ollama"])
max_tokens = self.entry.data.get(CONF_MAX_TOKENS, DEFAULT_MAX_TOKENS)
-
+
if not ip_address or not port:
raise ValueError("Ollama configuration incomplete")
@@ -514,10 +588,10 @@ async def process_with_ollama(self, prompt):
ip_address=ip_address,
port=port
)
-
- _LOGGER.debug("Making Ollama API request to %s with model %s and max_tokens %d",
- endpoint, model, max_tokens)
-
+
+ _LOGGER.debug("Making Ollama API request to %s with model %s and max_tokens %d",
+ endpoint, model, max_tokens)
+
data = {
"model": model,
"messages": [
@@ -529,7 +603,7 @@ async def process_with_ollama(self, prompt):
"num_predict": max_tokens
}
}
-
+
async with self.session.post(
endpoint,
json=data
@@ -538,7 +612,7 @@ async def process_with_ollama(self, prompt):
error_text = await response.text()
_LOGGER.error("Ollama API error: %s", error_text)
return None
-
+
result = await response.json()
return result["message"]["content"]
@@ -547,25 +621,24 @@ async def process_with_ollama(self, prompt):
return None
async def process_with_custom_openai(self, prompt):
- """Process the prompt with Custom OpenAI-compatible API."""
try:
endpoint = self.entry.data.get(CONF_CUSTOM_OPENAI_ENDPOINT)
api_key = self.entry.data.get(CONF_CUSTOM_OPENAI_API_KEY)
model = self.entry.data.get(CONF_CUSTOM_OPENAI_MODEL, DEFAULT_MODELS["Custom OpenAI"])
max_tokens = self.entry.data.get(CONF_MAX_TOKENS, DEFAULT_MAX_TOKENS)
-
+
if not endpoint:
raise ValueError("Custom OpenAI endpoint not configured")
- _LOGGER.debug("Making Custom OpenAI API request to %s with model %s and max_tokens %d",
- endpoint, model, max_tokens)
-
+ _LOGGER.debug("Making Custom OpenAI API request to %s with model %s and max_tokens %d",
+ endpoint, model, max_tokens)
+
headers = {
"Content-Type": "application/json",
}
if api_key:
headers["Authorization"] = f"Bearer {api_key}"
-
+
data = {
"model": model,
"messages": [
@@ -574,7 +647,7 @@ async def process_with_custom_openai(self, prompt):
"max_tokens": max_tokens,
"temperature": DEFAULT_TEMPERATURE
}
-
+
async with self.session.post(
endpoint,
headers=headers,
@@ -584,7 +657,7 @@ async def process_with_custom_openai(self, prompt):
error_text = await response.text()
_LOGGER.error("Custom OpenAI API error: %s", error_text)
return None
-
+
result = await response.json()
return result["choices"][0]["message"]["content"]
diff --git a/custom_components/ai_automation_suggester/manifest.json b/custom_components/ai_automation_suggester/manifest.json
index a9433df..e5f3d4d 100644
--- a/custom_components/ai_automation_suggester/manifest.json
+++ b/custom_components/ai_automation_suggester/manifest.json
@@ -14,5 +14,5 @@
"pyyaml>=6.0",
"voluptuous>=0.13.1"
],
- "version": "1.1.4"
+ "version": "1.2.0"
}
\ No newline at end of file
diff --git a/custom_components/ai_automation_suggester/sensor.py b/custom_components/ai_automation_suggester/sensor.py
index a6cfca4..5c054a7 100644
--- a/custom_components/ai_automation_suggester/sensor.py
+++ b/custom_components/ai_automation_suggester/sensor.py
@@ -76,7 +76,7 @@ def __init__(
"name": f"AI Automation Suggester ({entry.data.get(CONF_PROVIDER, 'unknown')})",
"manufacturer": "Community",
"model": entry.data.get(CONF_PROVIDER, "unknown"),
- "sw_version": "1.1.4",
+ "sw_version": "1.2.0",
}
self._entry = entry
self._previous_suggestions = None
@@ -168,7 +168,7 @@ def __init__(
"name": f"AI Automation Suggester ({entry.data.get(CONF_PROVIDER, 'unknown')})",
"manufacturer": "Community",
"model": entry.data.get(CONF_PROVIDER, "unknown"),
- "sw_version": "1.1.4",
+ "sw_version": "1.2.0",
}
self._entry = entry
self._attr_native_value = STATE_UNKNOWN
diff --git a/custom_components/ai_automation_suggester/services.yaml b/custom_components/ai_automation_suggester/services.yaml
index abcf1f6..47aa112 100644
--- a/custom_components/ai_automation_suggester/services.yaml
+++ b/custom_components/ai_automation_suggester/services.yaml
@@ -1,5 +1,3 @@
-# custom_components/ai_automation_suggester/services.yaml
-
generate_suggestions:
name: Generate Suggestions
description: "Manually trigger AI automation suggestions."
@@ -13,9 +11,33 @@ generate_suggestions:
integration: ai_automation_suggester
custom_prompt:
name: Custom Prompt
- description: Optional custom prompt to override the default system prompt
+ description: Optional custom prompt to override or enhance the default system prompt.
required: false
- example: "Generate automations focusing on energy savings and security"
+ example: "Focus on energy-saving automations"
selector:
text:
multiline: true
+ all_entities:
+ name: Consider All Entities
+ description: "If true, consider all entities instead of just new entities."
+ required: false
+ default: false
+ selector:
+ boolean: {}
+ domains:
+ name: Domains
+ description: "List of domains to consider. If empty, consider all domains."
+ required: false
+ selector:
+ object: {}
+ default: {}
+ entity_limit:
+ name: Entity Limit
+ description: "Maximum number of entities to consider (randomly selected from the chosen domains)."
+ required: false
+ default: 200
+ selector:
+ number:
+ min: 50
+ max: 1000
+ mode: slider
diff --git a/custom_components/ai_automation_suggester/translations/de.json b/custom_components/ai_automation_suggester/translations/de.json
index 6c0130d..c03e28d 100644
--- a/custom_components/ai_automation_suggester/translations/de.json
+++ b/custom_components/ai_automation_suggester/translations/de.json
@@ -1,65 +1,94 @@
{
"config": {
- "step": {
- "user": {
- "title": "AI Automation Suggester konfigurieren",
- "description": "Wählen Sie Ihren KI-Anbieter und konfigurieren Sie die Einstellungen",
- "data": {
- "provider": "KI-Anbieter",
- "scan_frequency": "Scan-Häufigkeit (Stunden)",
- "initial_lag_time": "Anfangsverzögerung (Minuten)",
- "max_tokens": "Maximale Ausgabe-Token"
- }
- },
- "openai": {
- "title": "OpenAI Konfiguration",
- "data": {
- "api_key": "API-Schlüssel",
- "model": "Modell",
- "max_tokens": "Maximale Ausgabe-Token"
- },
- "description": "Die maximale Anzahl von Token bestimmt die Länge der Antwort der KI. Standard ist 500. Erhöhen Sie diesen Wert, wenn Sie längere Antworten benötigen."
- },
- "anthropic": {
- "title": "Anthropic Konfiguration",
- "data": {
- "api_key": "API-Schlüssel",
- "model": "Modell",
- "max_tokens": "Maximale Ausgabe-Token"
- },
- "description": "Die maximale Anzahl von Token bestimmt die Länge der Antwort der KI. Standard ist 500. Erhöhen Sie diesen Wert, wenn Sie längere Antworten benötigen."
- },
- "localai": {
- "title": "LocalAI Konfiguration",
- "data": {
- "ip_address": "IP-Adresse",
- "port": "Port",
- "https": "HTTPS verwenden",
- "model": "Modellname",
- "max_tokens": "Maximale Ausgabe-Token"
- },
- "description": "Die maximale Anzahl von Token bestimmt die Länge der Antwort der KI. Standard ist 500. Erhöhen Sie diesen Wert, wenn Sie längere Antworten benötigen."
- },
- "ollama": {
- "title": "Ollama Konfiguration",
- "data": {
- "ip_address": "IP-Adresse",
- "port": "Port",
- "https": "HTTPS verwenden",
- "model": "Modellname",
- "max_tokens": "Maximale Ausgabe-Token"
- },
- "description": "Die maximale Anzahl von Token bestimmt die Länge der Antwort der KI. Standard ist 500. Erhöhen Sie diesen Wert, wenn Sie längere Antworten benötigen."
- }
+ "step": {
+ "user": {
+ "title": "AI Automation Suggester konfigurieren",
+ "description": "Wählen Sie Ihren KI-Anbieter und konfigurieren Sie die Einstellungen",
+ "data": {
+ "provider": "KI-Anbieter",
+ "scan_frequency": "Scan-Häufigkeit (Stunden)",
+ "initial_lag_time": "Anfangsverzögerung (Minuten)",
+ "max_tokens": "Maximale Ausgabe-Token"
+ }
},
- "error": {
- "cannot_connect": "Verbindung zum Dienst fehlgeschlagen",
- "invalid_auth": "Ungültige Authentifizierung",
- "invalid_config": "Ungültige Konfiguration",
- "unknown": "Unerwarteter Fehler",
- "no_entities": "Keine neuen Entitäten gefunden",
- "api_error": "API-Fehler aufgetreten",
- "required_field": "Dieses Feld ist erforderlich"
+ "openai": {
+ "title": "OpenAI Konfiguration",
+ "data": {
+ "api_key": "API-Schlüssel",
+ "model": "Modell",
+ "max_tokens": "Maximale Ausgabe-Token"
+ },
+ "description": "Die maximale Anzahl von Token bestimmt die Länge der Antwort der KI. Standard ist 500. Erhöhen Sie diesen Wert, wenn Sie längere Antworten benötigen."
+ },
+ "anthropic": {
+ "title": "Anthropic Konfiguration",
+ "data": {
+ "api_key": "API-Schlüssel",
+ "model": "Modell",
+ "max_tokens": "Maximale Ausgabe-Token"
+ },
+ "description": "Die maximale Anzahl von Token bestimmt die Länge der Antwort der KI. Standard ist 500. Erhöhen Sie diesen Wert, wenn Sie längere Antworten benötigen."
+ },
+ "localai": {
+ "title": "LocalAI Konfiguration",
+ "data": {
+ "ip_address": "IP-Adresse",
+ "port": "Port",
+ "https": "HTTPS verwenden",
+ "model": "Modellname",
+ "max_tokens": "Maximale Ausgabe-Token"
+ },
+ "description": "Die maximale Anzahl von Token bestimmt die Länge der Antwort der KI. Standard ist 500. Erhöhen Sie diesen Wert, wenn Sie längere Antworten benötigen."
+ },
+ "ollama": {
+ "title": "Ollama Konfiguration",
+ "data": {
+ "ip_address": "IP-Adresse",
+ "port": "Port",
+ "https": "HTTPS verwenden",
+ "model": "Modellname",
+ "max_tokens": "Maximale Ausgabe-Token"
+ },
+ "description": "Die maximale Anzahl von Token bestimmt die Länge der Antwort der KI. Standard ist 500. Erhöhen Sie diesen Wert, wenn Sie längere Antworten benötigen."
+ }
+ },
+ "error": {
+ "cannot_connect": "Verbindung zum Dienst fehlgeschlagen",
+ "invalid_auth": "Ungültige Authentifizierung",
+ "invalid_config": "Ungültige Konfiguration",
+ "unknown": "Unerwarteter Fehler",
+ "no_entities": "Keine neuen Entitäten gefunden",
+ "api_error": "API-Fehler aufgetreten",
+ "required_field": "Dieses Feld ist erforderlich"
+ }
+ },
+ "services": {
+ "generate_suggestions": {
+ "name": "Generiere Vorschläge",
+ "description": "Löst manuell AI Automationsvorschläge aus",
+ "fields": {
+ "provider_config": {
+ "name": "Anbieterkonfiguration",
+ "description": "Welche Anbieterkonfiguration soll verwendet werden (falls mehrere vorhanden)?"
+ },
+ "custom_prompt": {
+ "name": "Benutzerdefinierter Prompt",
+ "description": "Optionaler benutzerdefinierter Prompt, um den Standard-System-Prompt zu überschreiben oder die Vorschläge auf bestimmte Themen auszurichten"
+ },
+ "all_entities": {
+ "name": "Alle Entitäten berücksichtigen",
+ "description": "Wenn wahr, werden alle Entitäten berücksichtigt, anstatt nur neue."
+ },
+ "domains": {
+ "name": "Domänen",
+ "description": "Liste der zu berücksichtigenden Domänen. Wenn leer, werden alle Domänen berücksichtigt."
+ },
+ "entity_limit": {
+ "name": "Entitäten-Limit",
+ "description": "Maximale Anzahl von Entitäten, die berücksichtigt werden (zufällig ausgewählt)."
+ }
}
+ }
}
-}
+ }
+
\ No newline at end of file
diff --git a/custom_components/ai_automation_suggester/translations/en.json b/custom_components/ai_automation_suggester/translations/en.json
index 8d44323..14bcc25 100644
--- a/custom_components/ai_automation_suggester/translations/en.json
+++ b/custom_components/ai_automation_suggester/translations/en.json
@@ -46,7 +46,19 @@
},
"custom_prompt": {
"name": "Custom Prompt",
- "description": "Optional custom prompt to override the default system prompt"
+ "description": "Optional custom prompt to override the default system prompt or guide the suggestions towards specific themes"
+ },
+ "all_entities": {
+ "name": "Consider All Entities",
+ "description": "If true, consider all entities instead of just new entities."
+ },
+ "domains": {
+ "name": "Domains",
+ "description": "List of domains to consider. If empty, consider all domains."
+ },
+ "entity_limit": {
+ "name": "Entity Limit",
+ "description": "Maximum number of entities to consider (randomly selected)."
}
}
}
diff --git a/custom_components/ai_automation_suggester/translations/it.json b/custom_components/ai_automation_suggester/translations/it.json
index 534897e..bf74eb5 100644
--- a/custom_components/ai_automation_suggester/translations/it.json
+++ b/custom_components/ai_automation_suggester/translations/it.json
@@ -1,52 +1,28 @@
{
- "config": {
- "step": {
- "user": {
- "title": "Configurazione AI Automation Suggester",
- "data": {
- "provider": "AI Provider",
- "max_tokens": "Numero Massimo di Richieste"
- }
- },
- "provider_config": {
- "title": "Impostazioni Provider",
- "data": {
- "model": "Modello",
- "api_key": "API Key",
- "max_tokens": "Numero Massimo di Richieste",
- "ip_address": "Indirizzo IP",
- "port": "Porta",
- "use_https": "Utilizza HTTPS"
- },
- "description": "Il numero massimo di richieste controlla la lunghezza delle risposta di AI. Di default è 500. Incrementalo se hai bisogno di risposte più lunghe."
- }
- },
- "error": {
- "cannot_connect": "Impossibile connettersi al servizio",
- "invalid_auth": "Autenticazione non valida",
- "invalid_config": "Configurazione non valida",
- "unknown": "Errore sconosciuto",
- "no_entities": "Nessuna nuova entità trovata",
- "api_error": "Errore API",
- "required_field": "Questo campo è obbligatorio"
- },
- "abort": {
- "already_configured": "Provider già configurato",
- "provider_not_supported": "Questo provider non è attualmente supportato"
- }
- },
"services": {
"generate_suggestions": {
"name": "Genera Suggerimenti",
- "description": "Lancia manualmente AI automation suggestions",
+ "description": "Lancia manualmente suggerimenti di automazione AI",
"fields": {
"provider_config": {
"name": "Configurazione Provider",
- "description": "Quale configurazione provider utilizzare (se ne hai più di una)"
+ "description": "Quale configurazione provider utilizzare (se ne hai più di una)?"
},
"custom_prompt": {
- "name": "Prompt personalizzato",
- "description": "Prompt personalizzato facoltativo per sovrascrivere il prompt di default del sistema"
+ "name": "Prompt Personalizzato",
+ "description": "Prompt personalizzato opzionale per sovrascrivere il prompt di sistema predefinito o per focalizzare i suggerimenti su temi specifici (ad es. risparmio energetico)"
+ },
+ "all_entities": {
+ "name": "Considera Tutte le Entità",
+ "description": "Se vero, considera tutte le entità invece di solo quelle nuove."
+ },
+ "domains": {
+ "name": "Domini",
+ "description": "Elenco dei domini da considerare. Se vuoto, considera tutti i domini."
+ },
+ "entity_limit": {
+ "name": "Limite di Entità",
+ "description": "Numero massimo di entità da considerare (scelte casualmente)."
}
}
}
diff --git a/custom_components/ai_automation_suggester/translations/nl.json b/custom_components/ai_automation_suggester/translations/nl.json
index 1301a9b..3411d3c 100644
--- a/custom_components/ai_automation_suggester/translations/nl.json
+++ b/custom_components/ai_automation_suggester/translations/nl.json
@@ -1,52 +1,28 @@
{
- "config": {
- "step": {
- "user": {
- "title": "Configureer AI Automation Suggester",
- "data": {
- "provider": "AI Aanbieder",
- "max_tokens": "Maximaal aantal uitvoertokens"
- }
- },
- "provider_config": {
- "title": "Aanbiederconfiguratie",
- "data": {
- "model": "Modelnaam",
- "api_key": "API-sleutel",
- "max_tokens": "Maximaal aantal uitvoertokens",
- "ip_address": "IP Adres",
- "port": "Poort",
- "use_https": "Gebruik HTTPS"
- },
- "description": "Het maximaal aantal uitvoertokens beperkt de lengte van de door A.I.-gegenereerde uitvoer. De standaardlimiet is 500 tokens. Hoog het limiet op om een langere uitvoer mogelijk te maken."
- }
- },
- "error": {
- "cannot_connect": "Kon geen verbinding maken met de service",
- "invalid_auth": "Ongeldige authenticatie",
- "invalid_config": "Ongeldige configuratie",
- "unknown": "Onverwachte fout",
- "no_entities": "Geen nieuwe entiteiten gevonden",
- "api_error": "API-fout opgetreden",
- "required_field": "Dit veld is verplicht"
- },
- "abort": {
- "already_configured": "Aanbieder is al geconfigureerd",
- "provider_not_supported": "Deze aanbieder wordt momenteel niet ondersteund"
- }
- },
"services": {
"generate_suggestions": {
"name": "Genereer Suggesties",
- "description": "Handmatig AI Automation Suggester oproepen",
+ "description": "Handmatig AI-automatiseringssuggesties oproepen",
"fields": {
"provider_config": {
"name": "Aanbiederconfiguratie",
- "description": "Welke aanbiederconfiguratie te gebruiken (indien er meerdere zijn)"
+ "description": "Welke aanbiederconfiguratie moet worden gebruikt (indien er meerdere zijn)?"
},
"custom_prompt": {
"name": "Aangepaste Prompt",
- "description": "Optioneel: aangepaste prompt om de standaard systeemprompt mee te overschrijven"
+ "description": "Optioneel een aangepaste prompt om de standaard systeemprompt te overschrijven of om de suggesties op specifieke thema's te richten (bijv. energiebesparing)"
+ },
+ "all_entities": {
+ "name": "Alle Entiteiten Beschouwen",
+ "description": "Indien waar, worden alle entiteiten in overweging genomen in plaats van alleen nieuwe entiteiten."
+ },
+ "domains": {
+ "name": "Domeinen",
+ "description": "Lijst met te beschouwen domeinen. Als deze leeg is, worden alle domeinen beschouwd."
+ },
+ "entity_limit": {
+ "name": "Entiteitenlimiet",
+ "description": "Maximaal aantal te beschouwen entiteiten (willekeurig geselecteerd)."
}
}
}
diff --git a/custom_components/ai_automation_suggester/translations/zh.json b/custom_components/ai_automation_suggester/translations/zh.json
index c75ead9..c7a5813 100644
--- a/custom_components/ai_automation_suggester/translations/zh.json
+++ b/custom_components/ai_automation_suggester/translations/zh.json
@@ -1,55 +1,30 @@
{
- "config": {
- "step": {
- "user": {
- "title": "配置 AI 自动化建议器",
- "data": {
- "provider": "AI 提供商",
- "max_tokens": "最大输出令牌"
- }
- },
+ "services": {
+ "generate_suggestions": {
+ "name": "生成建议",
+ "description": "手动触发 AI 自动化建议",
+ "fields": {
"provider_config": {
- "title": "提供商设置",
- "data": {
- "model": "模型名称",
- "api_key": "API 密钥",
- "max_tokens": "最大输出令牌",
- "ip_address": "IP 地址",
- "port": "端口",
- "use_https": "使用 HTTPS"
- },
- "description": "最大令牌数量控制 AI 响应的长度。默认值为 500。如需更长响应,请增加此值。"
- }
- },
- "error": {
- "cannot_connect": "无法连接到服务",
- "invalid_auth": "身份验证无效",
- "invalid_config": "配置无效",
- "unknown": "意外错误",
- "no_entities": "未发现新实体",
- "api_error": "发生 API 错误",
- "required_field": "此字段为必填项"
- },
- "abort": {
- "already_configured": "提供商已配置",
- "provider_not_supported": "目前不支持此提供商"
- }
- },
- "services": {
- "generate_suggestions": {
- "name": "生成建议",
- "description": "手动触发 AI 自动化建议",
- "fields": {
- "provider_config": {
- "name": "提供商配置",
- "description": "选择使用哪个提供商配置(如果有多个)"
- },
- "custom_prompt": {
- "name": "自定义提示",
- "description": "可选自定义提示,覆盖默认系统提示"
- }
+ "name": "提供商配置",
+ "description": "选择要使用的提供商配置(如果有多个)"
+ },
+ "custom_prompt": {
+ "name": "自定义提示",
+ "description": "可选的自定义提示,可覆盖默认系统提示或将建议引导至特定主题(例如节能自动化)"
+ },
+ "all_entities": {
+ "name": "考虑所有实体",
+ "description": "若为 true,则考虑所有实体而不仅仅是新实体。"
+ },
+ "domains": {
+ "name": "领域",
+ "description": "要考虑的领域列表。如果为空,则考虑所有领域。"
+ },
+ "entity_limit": {
+ "name": "实体限制",
+ "description": "要考虑的实体最大数量(随机选择)。"
}
}
}
}
-
\ No newline at end of file
+}