Commit graph

23 commits

Author SHA1 Message Date
Julian Pawlowski
f60b5990ae test: add pytest framework and midnight-crossing tests
Set up pytest with Home Assistant support and created 6 tests for
midnight-crossing period logic (5 unit tests + 1 integration test).

Added pytest configuration, test dependencies, test runner script
(./scripts/test), and comprehensive tests for group_periods_by_day()
and midnight turnover consistency.

All tests pass in 0.12s.

Impact: Provides regression testing for midnight-crossing period bugs.
Tests validate periods remain visible across midnight turnover.
2025-11-21 23:47:01 +00:00
Julian Pawlowski
b461e89f08 fix(setup): improve conditional checks for optional package installations 2025-11-21 11:14:00 +00:00
Julian Pawlowski
5ff61b6d5c feat(setup): add optional pyright installation and create type-check script 2025-11-20 10:10:33 +00:00
Julian Pawlowski
329f96f2f4 chore(dev): enhance sync-hac script to clean up broken symlinks and report changes 2025-11-16 18:13:29 +00:00
Julian Pawlowski
60c3b72932 chore(dev): add HACS installation and sync scripts for testing
Added scripts to install HACS in DevContainer for testing the
integration alongside other HACS components.

Changes:
- scripts/setup: Automatically install HACS and create symlink
- scripts/sync-hacs: Sync HACS-installed integrations via symlinks
- .gitignore: Ignore custom_components/* except tibber_prices

HACS installs to config/custom_components/, symlinks in
custom_components/ make integrations visible to Home Assistant.

Impact: Developers can test with other integrations. No user changes.
2025-11-16 18:05:14 +00:00
Julian Pawlowski
3c69ca6f75 feat(release): remove version tag prefix from release titles
HACS automatically displays the version number before release titles,
causing duplication when version tags are included in the title.

Changes:
- scripts/generate-release-notes: All backends now generate intelligent
  titles without version prefix (git-cliff, manual, and copilot)
- scripts/generate-release-notes: Added smart title generation based on
  commit analysis (feat/fix counts) for git-cliff and manual backends
- scripts/generate-release-notes: Unified section headers to use ### (H3)
  instead of ## (H2) for consistency across all backends
- scripts/generate-release-notes: Auto-update feature now uses extracted
  title without prepending version tag
- .github/workflows/release.yml: Extract title directly from generated
  release notes (first line with "# ") instead of manual construction
- .github/workflows/release.yml: Removed redundant "Generate release title"
  step

Before (HACS): v0.9.0: v0.9.0 - New Features
After (HACS):  v0.9.0: Multi-Home Support & Diagnostic Sensors

Impact: Release titles in HACS are now cleaner with single version display
and more descriptive titles generated intelligently from commit content.
All three backends (copilot, git-cliff, manual) produce consistent output
with H1 title followed by H3 sections.
2025-11-16 00:26:34 +00:00
Julian Pawlowski
503075c443 refactor(config_flow): restructure package to satisfy hassfest validation
Home Assistant's hassfest validation requires config flows to be defined
in a file named config_flow.py (not a package directory).

Changes:
- Renamed custom_components/tibber_prices/config_flow/ → config_flow_handlers/
- Created config_flow.py as bridge file re-exporting from config_flow_handlers/
- Updated all import paths across 5 files (user_flow, options_flow, subentry_flow, etc.)
- Added ./scripts/hassfest for local validation (JSON/Python syntax, required files)
- Added ./scripts/clean with three modes (--minimal, normal, --deep)
- Refactored develop/lint/lint-check to use centralized cleanup (DRY principle)
- Updated documentation in AGENTS.md and docs/development/

Technical details:
- Bridge file uses __all__ exports to maintain clean public API
- hassfest script uses ast.parse() for syntax validation (no disk artifacts)
- clean --minimal removes .egg-info only (silent, for automated scripts)
- Dual pip/uv pip compatibility for package uninstallation

Impact: Integration now passes hassfest validation. Local validation available
via ./scripts/hassfest before pushing to GitHub. Cleanup logic centralized and
DRY across all development scripts.
2025-11-15 17:40:53 +00:00
Julian Pawlowski
fa40c00f67 refactor(sensors): Transform sensor platform into package 2025-11-15 11:46:54 +00:00
Julian Pawlowski
850e985ef8 feat(release): enhance generate-release-notes with AI optimization and auto-update
Major improvements to release note generation system:

**AI Model Optimization:**
- Switch from Claude Sonnet 4.5 to Haiku 4.5 (67% cheaper, 50% faster)
- Cost reduced from 1.0 to 0.33 Premium requests per generation
- Generation time reduced from ~30s to ~15s
- Quality maintained through improved prompt engineering

**Improved Prompt Structure:**
- Restructured prompt: instructions first, commit data last
- Added explicit user-feature prioritization rules (sensors > config > developer tools)
- Integrated file change statistics with each commit
- Added file path guidance (custom_components/ = HIGH, scripts/ = LOW)
- Added 3-step decision process with walkthrough example
- Added explicit output constraints to prevent meta-commentary

**Auto-Update Feature:**
- Consolidated improve-release-notes functionality into generate-release-notes
- Automatic detection of existing GitHub releases
- Interactive prompt to update both title and body
- Shows comparison: current title vs. new AI-generated title

**File Statistics Integration:**
- Added --stat --compact-summary to git log
- Shows which files changed in each commit with line counts
- Helps AI quantitatively assess change importance (100+ lines = significant)
- Enables better prioritization of user-facing features

**Testing Results:**
- Generated title: "Price Volatility Analysis & Configuration" (user-focused!)
- Successfully prioritizes user features over developer/CI changes
- No more generic "New Features & Bug Fixes" titles
- Thematic titles that capture main release highlights

Impact: Release note generation is now faster, cheaper, and produces
higher-quality user-focused titles. Single consolidated script handles
both generation and updating existing releases.
2025-11-09 17:51:15 +00:00
Julian Pawlowski
6614d225e3 fix(release): add validation/lint checks before release and clean output
Added mandatory validation steps to release workflow:
- Job 1: validate (hassfest + HACS) - runs before release
- Job 2: lint (Ruff check + format) - runs before release
- Job 3: sync-manifest - only runs if validation passes
- Job 4: release-notes - only runs if all previous jobs pass

This ensures no release is created if code doesn't pass validation.

Fixed generate-release-notes script to suppress colored output in CI:
- Added log_info() wrapper that sends output to stderr in CI
- Keeps release notes clean (only markdown, no ANSI codes)
- Local execution still shows colored output for better UX

Impact: Release workflow now fails fast if validation fails. Release
notes are clean without shell output artifacts.
2025-11-09 16:14:07 +00:00
Julian Pawlowski
ddc718aabd feat(release): add semantic versioning workflow automation
Added intelligent version suggestion system based on Conventional Commits
analysis to support proper semantic versioning.

New scripts:
- check-if-released: Verify if commit exists in any version tag
  - Helps decide if legacy migration code is needed
  - Shows guidance for breaking changes vs simple migrations

- suggest-version: Analyze commits and suggest next version
  - Counts breaking changes, features, and bug fixes
  - Applies pre-1.0 rules: breaking→MINOR, feat→MINOR, fix→PATCH
  - Applies post-1.0 rules: breaking→MAJOR, feat→MINOR, fix→PATCH
  - Checks manifest.json and suggests alternatives (MAJOR/MINOR/PATCH)
  - Provides preview and release commands

Updated scripts:
- prepare-release: Now calls suggest-version when no argument provided
  - Shows suggested version before prompting
  - Maintains manual override capability

Impact: Developers get intelligent version suggestions based on actual
commit content, reducing versioning mistakes and following semver correctly.
2025-11-09 15:32:44 +00:00
Julian Pawlowski
e08fd60070 feat(release): add automated release notes generation system
Implemented multi-backend release notes generation:

**Scripts:**
- prepare-release: Bump manifest.json + create tag (foolproof workflow)
- generate-release-notes: Parse conventional commits with 3 backends
  * GitHub Copilot CLI (AI-powered, smart grouping)
  * git-cliff (template-based, fast and reliable)
  * Manual grep/awk (fallback, always works)
- setup: Auto-install git-cliff via cargo in DevContainer

**GitHub Actions:**
- auto-tag.yml: Automatically create tag on manifest.json version bump
- release.yml: Generate release notes and create GitHub release on tag push
- release.yml: Button config for GitHub UI release notes generator

**Configuration:**
- cliff.toml: Smart filtering rules
  * Excludes: manifest bumps, dev-env changes, CI/CD changes
  * Includes: Dependency updates (relevant for users)
  * Groups by conventional commit type with emoji

**Workflow:**
1. Run `./scripts/prepare-release 0.3.0`
2. Push commit + tag: `git push origin main v0.3.0`
3. CI/CD automatically generates release notes and creates GitHub release

Impact: Maintainers can prepare professional releases with one command.
Release notes are automatically generated from conventional commits with
intelligent filtering and categorization.
2025-11-09 14:25:15 +00:00
Julian Pawlowski
232a090c67 refactor: Revise translation schema to enhance structure and add detailed properties for configuration flows 2025-11-09 12:49:06 +00:00
Julian Pawlowski
03f09818d1 add shellcheck directive for bootstrap script 2025-11-06 11:43:10 +00:00
Julian Pawlowski
8790ac8a41 fix 2025-11-03 21:13:50 +00:00
Julian Pawlowski
aaa66227d4 fix linter issues 2025-11-03 20:52:10 +00:00
Julian Pawlowski
0a245a0e12 fix linter 2025-11-03 17:33:01 +00:00
Julian Pawlowski
6d4669c8e7 fix bootstrap 2025-11-03 17:32:49 +00:00
Julian Pawlowski
c6eed9329b update dev environment 2025-11-03 17:00:08 +00:00
Julian Pawlowski
6040a19136 update dev environment 2025-11-03 15:54:01 +00:00
Julian Pawlowski
dd94351278 refactoring 2025-04-23 16:42:31 +00:00
Julian Pawlowski
dea7cfee43 Rename component 2025-04-18 12:51:32 +00:00
Julian Pawlowski
131a4eb148
Initial commit 2025-04-18 14:32:54 +02:00