This guide will help you add support for new regions to the integration.
- Prerequisites
- Development Setup
- Adding a New DTEK Region
- Testing
- Code Style
- Example: Adding Uzhhorod Region
- uv installed
- Git installed
- GitHub account for creating PRs
- Understanding of Home Assistant integration development
-
Clone the repository:
git clone https://github.com/ALERTua/ha-svitlo-yeah.git cd ha-svitlo-yeah -
Install dependencies using uv:
uv sync
-
Run pre-commit setup:
uv run pre-commit install
-
Verify tests pass:
uv run pytest
To add a new DTEK region, you need to modify several files following the established patterns. This typically involves:
- Adding URL mappings in
DTEK_PROVIDER_URLS - Updating translations in
en.jsonanduk.json - Updating documentation in
README.md - Testing your changes
To add a new DTEK region, follow this process by examining PR #25 as a reference example:
Reference Example: #25
-
custom_components/svitlo_yeah/const.py- Add URL mapping for your region in
DTEK_PROVIDER_URLS
- Add URL mapping for your region in
-
custom_components/svitlo_yeah/translations/en.json- Add provider translation key in
selector.provider.options - Add region translation key in
selector.region.options
- Add provider translation key in
-
custom_components/svitlo_yeah/translations/uk.json- Add Ukrainian translations for the same keys as in en.json
-
README.md- Add a new row to the supported regions table
Refer to PR #25 to see the exact pattern for:
- Lowercase region names as keys in
DTEK_PROVIDER_URLS - URL structure and data source links
- Translation key format (
dtekjsonprovider_{region_name}) - Table formatting in README
Each change should follow the existing patterns established by previous regions.
uv run pytestuv run pre-commit run --all-filesVerify in Home Assistant:
- Restart Home Assistant
- Try to add your new region through the integration UI
- Check if sensors are created and data loads correctly
- Follow PEP 8 style guidelines
- Use type hints where possible
- Use descriptive variable and function names
- Keep functions small and focused
- Add docstrings for complex functions
- Use consistent indentation (2 spaces)
- Maintain alphabetical order when possible
- Keep translations meaningful and accurate
Use clear, descriptive commit messages:
Add Ternopil and Oblast (#25)
- Added Ternopil region support to DTEK_PROVIDER_URLS
- Updated English and Ukrainian translations
- Updated README documentation
For a complete working example of adding a DTEK region, see: #25
This PR demonstrates the exact changes needed to add Ternopil region support and can serve as a template for adding new regions.
- Tests failing: Check if your region keys in
DTEK_PROVIDER_URLSmatch the expected lowercase patterns - Translation not showing: Ensure keys match exactly between en.json and uk.json
- Integration not loading: Verify all required files are modified consistently
- Data source not working: Test the URL manually and ensure JSON format is valid
- Check existing issues on GitHub
- Review similar PRs for patterns
- Run tests and pre-commit locally before submitting
- Ask questions in GitHub discussions
- Always verify data sources are legitimate
- Don't commit sensitive information
- Test URLs before adding them
- Keep dependencies updated