This Python script leverages OpenAI's GPT models to generate and update titles and descriptions for home automation tasks. It processes an automations.yaml file, which contains your home automation configurations, and updates it with newly generated titles and descriptions that are more informative and human-friendly.
Before running the script, ensure you have the following prerequisites installed:
- Python 3.8 or newer
openaiPython packagepyyamlPython package
You can install the required packages using pip:
pip install openai pyyaml- Set up your OpenAI API key : The script requires an OpenAI API key to interact with GPT models. You can set your API key as an environment variable:
export OPENAI_API_KEY='your_api_key_here'- ** file** : The script expects a YAML file named
automations.yamlcontaining your home automation configurations. Ensure this file is in the same directory as the script or provide the path to the file when calling the function.
- Run the Script : To run the script, navigate to the directory containing the script and your
automations.yamlfile, then execute:
python main.pyReplace main.py with the name of your Python script file.
- Review Updates : The script will process each automation in your YAML file, generating new titles and descriptions, and updating the file in place. Review the changes to ensure they meet your expectations.
- The script reads your
automations.yamlfile to get the current configurations of your home automations. - It uses OpenAI's GPT models to generate a new title and description for each automation based on its triggers and actions.
- The new titles and descriptions are formatted to provide clear and concise information about what each automation does and where it is applied.
- Finally, the script updates the
automations.yamlfile with the new titles and descriptions.
Contributions are welcome! If you have suggestions for improvements or encounter any issues, please open an issue or submit a pull request.