Major restructuring of the scripts/ directory with consistent output
formatting, improved organization, and stricter error handling.
Breaking Changes:
- Updated development environment to Home Assistant 2025.7+
- Removed Python 3.12 compatibility (HA 2025.7+ requires Python 3.13)
- Updated all HA core requirements from 2025.7 requirement files
- Added new dependencies: python-multipart, uv (for faster package management)
- Updated GitHub Actions workflows to use Python 3.13
Changes:
- Created centralized output library (scripts/.lib/output.sh)
- Unified color codes and Unicode symbols
- Consistent formatting functions (log_header, log_success, log_error, etc.)
- Support for embedded formatting codes (${BOLD}, ${GREEN}, etc.)
- Reorganized into logical subdirectories:
- scripts/setup/ - Setup and maintenance scripts
- bootstrap: Install/update dependencies (used in CI/CD)
- setup: Full DevContainer setup (pyright, copilot, HACS)
- reset: Reset config/ directory to fresh state (NEW)
- sync-hacs: Sync HACS integrations
- scripts/release/ - Release management scripts
- prepare: Version bump and tagging
- suggest-version: Semantic version suggestion
- generate-notes: Release notes generation
- check-if-released: Check release status
- hassfest: Local integration validation
- Updated all scripts with:
- set -euo pipefail for stricter error handling
- Consistent SCRIPT_DIR pattern for reliable sourcing
- Professional output with colors and emojis
- Unified styling across all 17 scripts
- Removed redundant scripts:
- scripts/update (was just wrapper around bootstrap)
- scripts/json_schemas/ (moved to schemas/json/)
- Enhanced clean script:
- Improved artifact cleanup
- Better handling of accidental package installations
- Hints for reset and deep clean options
- New reset script features:
- Standard mode: Keep configuration.yaml
- Full mode (--full): Reset configuration.yaml from git
- Automatic re-setup after reset
- Updated documentation:
- AGENTS.md: Updated script references and workflow guidance
- docs/development/: Updated all references to new script structure
Impact: Development environment now requires Python 3.13 and Home Assistant
2025.7+. Developers get consistent, professional script output with better
error handling and logical organization. Single source of truth for styling
makes future updates trivial.
|
||
|---|---|---|
| .. | ||
| architecture.md | ||
| caching-strategy.md | ||
| coding-guidelines.md | ||
| critical-patterns.md | ||
| period-calculation-theory.md | ||
| README.md | ||
| refactoring-guide.md | ||
| release-management.md | ||
| setup.md | ||
| testing.md | ||
| timer-architecture.md | ||
Developer Documentation
This section contains documentation for contributors and maintainers of the Tibber Prices integration.
📚 Developer Guides
- Setup - DevContainer, environment setup, and dependencies
- Architecture - Code structure, patterns, and conventions
- Period Calculation Theory - Mathematical foundations, Flex/Distance interaction, Relaxation strategy
- Timer Architecture - Timer system, scheduling, coordination (3 independent timers)
- Caching Strategy - Cache layers, invalidation, debugging
- Testing - How to run tests and write new test cases
- Release Management - Release workflow and versioning process
- Coding Guidelines - Style guide, linting, and best practices
- Refactoring Guide - How to plan and execute major refactorings
🤖 AI Documentation
The main AI/Copilot documentation is in AGENTS.md. This file serves as long-term memory for AI assistants and contains:
- Detailed architectural patterns
- Code quality rules and conventions
- Development workflow guidance
- Common pitfalls and anti-patterns
- Project-specific patterns and utilities
Important: When proposing changes to patterns or conventions, always update AGENTS.md to keep AI guidance consistent.
AI-Assisted Development
This integration is developed with extensive AI assistance (GitHub Copilot, Claude, and other AI tools). The AI handles:
- Pattern Recognition: Understanding and applying Home Assistant best practices
- Code Generation: Implementing features with proper type hints, error handling, and documentation
- Refactoring: Maintaining consistency across the codebase during structural changes
- Translation Management: Keeping 5 language files synchronized
- Documentation: Generating and maintaining comprehensive documentation
Quality Assurance:
- Automated linting with Ruff (120-char line length, max complexity 25)
- Home Assistant's type checking and validation
- Real-world testing in development environment
- Code review by maintainer before merging
Benefits:
- Rapid feature development while maintaining quality
- Consistent code patterns across all modules
- Comprehensive documentation maintained alongside code
- Quick bug fixes with proper understanding of context
Limitations:
- AI may occasionally miss edge cases or subtle bugs
- Some complex Home Assistant patterns may need human review
- Translation quality depends on AI's understanding of target language
- User feedback is crucial for discovering real-world issues
If you're working with AI tools on this project, the AGENTS.md file provides the context and patterns that ensure consistency.
🚀 Quick Start for Contributors
- Fork and clone the repository
- Open in DevContainer (VS Code: "Reopen in Container")
- Run setup:
./scripts/setup/setup(happens automatically viapostCreateCommand) - Start development environment:
./scripts/develop - Make your changes following the Coding Guidelines
- Run linting:
./scripts/lint - Validate integration:
./scripts/release/hassfest - Test your changes in the running Home Assistant instance
- Commit using Conventional Commits format
- Open a Pull Request with clear description
🛠️ Development Tools
The project includes several helper scripts in ./scripts/:
bootstrap- Initial setup of dependenciesdevelop- Start Home Assistant in debug mode (auto-cleans .egg-info)clean- Remove build artifacts and cacheslint- Auto-fix code issues with rufflint-check- Check code without modifications (CI mode)hassfest- Validate integration structure (JSON, Python syntax, required files)setup- Install development tools (git-cliff, @github/copilot)prepare-release- Prepare a new release (bump version, create tag)generate-release-notes- Generate release notes from commits
📦 Project Structure
custom_components/tibber_prices/
├── __init__.py # Integration setup
├── coordinator.py # Data update coordinator with caching
├── api.py # Tibber GraphQL API client
├── price_utils.py # Price enrichment functions
├── average_utils.py # Average calculation utilities
├── sensor/ # Sensor platform (package)
│ ├── __init__.py # Platform setup
│ ├── core.py # TibberPricesSensor class
│ ├── definitions.py # Entity descriptions
│ ├── helpers.py # Pure helper functions
│ └── attributes.py # Attribute builders
├── binary_sensor.py # Binary sensor platform
├── entity_utils/ # Shared entity helpers
│ ├── icons.py # Icon mapping logic
│ ├── colors.py # Color mapping logic
│ └── attributes.py # Common attribute builders
├── services.py # Custom services
├── config_flow.py # UI configuration flow
├── const.py # Constants and helpers
├── translations/ # Standard HA translations
└── custom_translations/ # Extended translations (descriptions)
🔍 Key Concepts
DataUpdateCoordinator Pattern:
- Centralized data fetching and caching
- Automatic entity updates on data changes
- Persistent storage via
Store - Quarter-hour boundary refresh scheduling
Price Data Enrichment:
- Raw API data is enriched with statistical analysis
- Trailing/leading 24h averages calculated per interval
- Price differences and ratings added
- All via pure functions in
price_utils.py
Translation System:
- Dual system:
/translations/(HA schema) +/custom_translations/(extended) - Both must stay in sync across all languages (de, en, nb, nl, sv)
- Async loading at integration setup
🧪 Testing
# Validate integration structure
./scripts/release/hassfest
# Run all tests
pytest tests/
# Run specific test file
pytest tests/test_coordinator.py
# Run with coverage
pytest --cov=custom_components.tibber_prices tests/
📝 Documentation Standards
- User-facing docs go in
docs/user/ - Developer docs go in
docs/development/ - AI guidance goes in
AGENTS.md - Use clear examples and code snippets
- Keep docs up-to-date with code changes
🤝 Contributing
See CONTRIBUTING.md for detailed contribution guidelines, code of conduct, and pull request process.
📄 License
This project is licensed under LICENSE.
Note: This documentation is for developers. End users should refer to the User Documentation.