{"id":27714809,"url":"https://github.com/huafu/hayamlpreprocessor","last_synced_at":"2026-05-04T12:34:40.824Z","repository":{"id":288906434,"uuid":"965017431","full_name":"huafu/HaYamlPreprocessor","owner":"huafu","description":"Home Assistant YAML pre-processor","archived":false,"fork":false,"pushed_at":"2025-05-14T07:11:20.000Z","size":521,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-14T08:25:30.093Z","etag":null,"topics":["custom-component","hacs","home-assistant","integration","yaml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/huafu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-12T08:20:33.000Z","updated_at":"2025-05-14T07:11:22.000Z","dependencies_parsed_at":"2025-04-27T00:58:39.917Z","dependency_job_id":null,"html_url":"https://github.com/huafu/HaYamlPreprocessor","commit_stats":null,"previous_names":["huafu/hayamlpreprocessor"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/huafu/HaYamlPreprocessor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huafu%2FHaYamlPreprocessor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huafu%2FHaYamlPreprocessor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huafu%2FHaYamlPreprocessor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huafu%2FHaYamlPreprocessor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/huafu","download_url":"https://codeload.github.com/huafu/HaYamlPreprocessor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/huafu%2FHaYamlPreprocessor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259444954,"owners_count":22858548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom-component","hacs","home-assistant","integration","yaml"],"created_at":"2025-04-27T00:58:37.781Z","updated_at":"2026-05-04T12:34:40.793Z","avatar_url":"https://github.com/huafu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![GitHub Stars](https://img.shields.io/github/stars/huafu/HaYamlPreprocessor?style=social)](https://github.com/huafu/HaYamlPreprocessor/stargazers)\n[![GitHub Issues](https://img.shields.io/github/issues/huafu/HaYamlPreprocessor)](https://github.com/huafu/HaYamlPreprocessor/issues)\n[![Validate Status](https://img.shields.io/github/actions/workflow/status/huafu/HaYamlPreprocessor/validate.yml?branch=main)](https://github.com/huafu/HaYamlPreprocessor/actions)\n[![License](https://img.shields.io/github/license/huafu/HaYamlPreprocessor)](https://github.com/huafu/HaYamlPreprocessor/blob/main/LICENSE)\n[![HACS](https://img.shields.io/badge/HACS-Custom-blue.svg)](https://hacs.xyz/)\n\n# YAML Preprocessor for Home Assistant\nThe YAML Preprocessor is a tool designed to enhance the YAML configuration experience in Home Assistant. It allows you to preprocess your YAML files, enabling features like variable substitution, making your configurations cleaner and more maintainable.\n\n## Warning\nThis is an experimental project and should be used with caution. It is not officially supported by Home Assistant, and there may be bugs or issues that arise during use. Always back up your configuration files before using the preprocessor.\nPre-processing the core configuration file is not handled by this preprocessor. It is recommended to use the preprocessor only for included files, such as packages or custom components. The preprocessor will not work with the main configuration file (`configuration.yaml`) directly.\n\n## Installation\nYou can install the YAML Preprocessor in two ways:\n1. **Using HACS (Home Assistant Community Store)**:\n    - Open HACS in your Home Assistant instance.\n    - Go to the \"Integrations\" section.\n    - Search for \"YAML Preprocessor\".\n    - Click on \"Install\".\n    - Restart Home Assistant to apply the changes.\n2. **Manual Installation**:\n    - Download the latest release from the [GitHub repository](https://github.com/huafu/HaYamlPreprocessor/releases).\n    - Extract the contents of the downloaded file.\n    - Copy the `custom_components/yaml_preprocessor` folder into your Home Assistant `custom_components` directory.\n    - Restart Home Assistant to apply the changes.\n\n## Configuration\nTo configure the YAML Preprocessor, you need to add the following lines to your `configuration.yaml` file:\n\n```yaml\nyaml_preprocessor:\n  # Dot-files in the input directory will be ignored but can be used as reusable snippets\n  input_dir: packages/input\n  # be careful, this directory will be deleted each time you run the preprocessor\n  output_dir: packages/output\n\n# Example for using the preprocessor in your configuration\nhomeassistant:\n  packages: !include_dir_named packages/output\n```\n\n## Usage\nThe YAML Preprocessor allows you to create reusable YAML snippets and include them in your main configuration. Here is an example of how to use it following the previous configuration:\n\n1. Create a file named `packages/input/.light.yaml` with the following content:\n   ```yaml\n    unique_id: light_${id}_has_red\n    name: ${name} Light has some red\n    state: \u003e\n      {% if is_state('light.light_${id}', 'on') %}\n        {% set rgb = state_attr('light.light_${id}', 'rgb_color') %}\n        {{ rgb and rgb[0] \u003e 0 }}\n      {% else %}\n        false\n      {% endif %}\n    ```\n2. Create a file named `packages/input/lights.yaml` with the following content:\n    ```yaml\n    template:\n      - binary_sensor:\n          - !include\n              file: ./.light.yaml\n              vars:\n                id: living_room\n                name: Living Room\n          - !include\n              file: ./.light.yaml\n              vars:\n                id: kitchen\n                name: Kitchen\n    ```\n3. Call the preprocessor to generate the output: in Home Assistant, go to Developer Tools \u003e Services and call the `yaml_preprocessor.preprocess` service. This will generate `packages/output/lights.yaml` with the following content:\n    ```yaml\n    template:\n      - binary_sensor:\n          - unique_id: light_living_room_has_red\n            name: Living Room Light has some red\n            state: \u003e\n              {% if is_state('light.light_living_room', 'on') %}\n                {% set rgb = state_attr('light.light_living_room', 'rgb_color') %}\n                {{ rgb and rgb[0] \u003e 0 }}\n              {% else %}\n                false\n              {% endif %}\n          - unique_id: light_kitchen_has_red\n            name: Kitchen Light has some red\n            state: \u003e\n              {% if is_state('light.light_kitchen', 'on') %}\n                {% set rgb = state_attr('light.light_kitchen', 'rgb_color') %}\n                {{ rgb and rgb[0] \u003e 0 }}\n              {% else %}\n                false\n              {% endif %}\n    ```\n\n## Contributing\nWe welcome contributions to the YAML Preprocessor project! If you have suggestions, bug reports, or would like to contribute code, please follow these steps:\n1. Fork the repository.\n2. Create a new branch for your feature or bug fix.\n3. Make your changes and commit them with clear messages.\n4. Push your changes to your forked repository.\n5. Create a pull request to the main repository.\n6. Ensure your code adheres to the project's coding standards and passes all tests.\n\n## License\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n## Credits\nThis project is maintained by [huafu](https://github.com/huafu) and contributors. Special thanks to the Home Assistant community for their support and feedback.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuafu%2Fhayamlpreprocessor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhuafu%2Fhayamlpreprocessor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhuafu%2Fhayamlpreprocessor/lists"}