Commit graph

341 commits

Author SHA1 Message Date
Julian Pawlowski
aa58c6718f refactor(period_utils): implement per-day relaxation with 4×4 matrix strategy
Restructured relaxation mechanism to process each day independently instead
of globally, enabling different days to relax at different levels.

Key changes:
- Added hierarchical logging with INDENT_L0-L5 constants
- Replaced global relaxation loop with per-day relaxation (_relax_single_day)
- Implemented 4×4 matrix strategy (4 flex levels × 4 filter combinations)
- Enhanced _resolve_period_overlaps with replacement and extension logic
- Added helper functions: _group_periods_by_day, _group_prices_by_day,
  _check_min_periods_per_day

Relaxation strategy:
- Each flex level tries 4 filter combinations before increasing flex
- Early exit after EACH successful combination (minimal relaxation)
- Extensions preserve baseline metadata, replacements use relaxed metadata
- Only standalone periods count toward min_periods requirement

Impact: Users get more accurate period detection per day. Days with clear
cheap/expensive patterns use strict filters while difficult days relax as
needed. Reduces over-relaxation - finds 'good enough' solutions faster.
2025-11-11 21:21:56 +00:00
Julian Pawlowski
b191238df4 docs(agents): add logging and documentation writing guidelines
Extended AGENTS.md with comprehensive patterns learned from period
calculation development and documentation rewrite.

Logging Guidelines:
- Added hierarchical indentation pattern (INDENT_L0-L5)
- Defined log level strategy (INFO=compact/scannable,
  DEBUG=detailed/hierarchical, WARNING=top-level)
- Added configuration context headers for complex calculations
- Documented per-day processing patterns
- Added note about logs as documentation foundation

User Documentation Quality:
- Added principles: clarity over completeness, visual examples,
  use-case driven structure, practical troubleshooting, progressive
  disclosure
- Added validation rules for code-documentation sync

Documentation Writing Strategy (new section):
- Live understanding vs. cold code analysis
- User feedback loop importance
- Log-driven documentation approach
- Concrete examples over abstract descriptions
- Context accumulation in long sessions
- Document the "why", not just the "what"

Impact: Future AI sessions can produce better logs (traceable logic
with visual hierarchy) and better documentation (user-focused with
concrete examples from live development).
2025-11-11 21:20:06 +00:00
Julian Pawlowski
95758ec40a docs(user): rewrite period calculation documentation for clarity
Completely rewrote period-calculation.md based on user feedback and
live development understanding.

Changes:
- Replaced outdated 3-phase relaxation description with correct 4×4
  matrix approach (4 flex levels × 4 filter combinations)
- Added per-day independence explanation (each day relaxes independently)
- Documented replacement logic (larger periods replace smaller ones)
- Added extension logic (baseline periods get expanded, not replaced)
- Updated metadata format examples (price_diff_27.3%+level_any)
- Restructured for clarity: Quick Start → How It Works → Config →
  Relaxation → Scenarios → Troubleshooting
- Added 4 real-world scenarios with automation examples (dishwasher,
  heat pump, EV charging, peak avoidance)
- Added visual timeline examples
- Reduced technical complexity, focused on user understanding
- Added practical troubleshooting with specific solutions

Impact: Users can now understand how period calculation actually works,
with correct information matching the implemented 4×4 relaxation
strategy. Documentation evolved from cold code reading to live
development insights with user feedback.
2025-11-11 21:19:57 +00:00
Julian Pawlowski
b4a1775968
Merge pull request #21 from jpawlowski/dependabot/pip/pre-commit-gte-4.3.0-and-lt-4.5.0
chore(deps): update pre-commit requirement from <4.4.0,>=4.3.0 to >=4.3.0,<4.5.0
2025-11-11 15:10:06 +01:00
Julian Pawlowski
d0301e07a2
Merge pull request #20 from jpawlowski/dependabot/github_actions/astral-sh/setup-uv-7.1.3
chore(deps): bump astral-sh/setup-uv from 7.1.2 to 7.1.3
2025-11-11 15:09:44 +01:00
dependabot[bot]
efeb3f9df6
chore(deps): update pre-commit requirement
Updates the requirements on [pre-commit](https://github.com/pre-commit/pre-commit) to permit the latest version.
- [Release notes](https://github.com/pre-commit/pre-commit/releases)
- [Changelog](https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pre-commit/pre-commit/compare/v4.3.0...v4.4.0)

---
updated-dependencies:
- dependency-name: pre-commit
  dependency-version: 4.4.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-10 20:24:22 +00:00
dependabot[bot]
4478a8f797
chore(deps): bump astral-sh/setup-uv from 7.1.2 to 7.1.3
Bumps [astral-sh/setup-uv](https://github.com/astral-sh/setup-uv) from 7.1.2 to 7.1.3.
- [Release notes](https://github.com/astral-sh/setup-uv/releases)
- [Commits](85856786d1...5a7eac68fb)

---
updated-dependencies:
- dependency-name: astral-sh/setup-uv
  dependency-version: 7.1.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-10 20:23:34 +00:00
Julian Pawlowski
7605e88b96 refactor(period_utils): simplify period qualification logic by removing average boundary check 2025-11-10 14:58:16 +00:00
Julian Pawlowski
e0b8cdc072 fix(docs): correct link formatting for AGENTS.md in coding guidelines 2025-11-10 14:12:01 +00:00
Julian Pawlowski
6a77572f4e refactor(docs): update references from copilot-instructions.md to AGENTS.md across documentation 2025-11-10 14:09:40 +00:00
Julian Pawlowski
6e1a3e37c5 chore(release): bump version to 0.4.0 2025-11-10 12:15:58 +00:00
Julian Pawlowski
ab73d02ec1 chore(copilot): Add AGENTS.md 2025-11-10 12:13:53 +00:00
Julian Pawlowski
c9923d9475 chore(copilot): Remove reference to CLAUDE.md as it is no longer needed in the repository. 2025-11-10 12:11:42 +00:00
Julian Pawlowski
6dcaca9f11 chore(copilot): remove obsolete configuration file for Copilot instructions 2025-11-10 12:00:17 +00:00
Julian Pawlowski
3dc1a49465 feat(docs): enhance period calculation documentation and add detailed guides for best/peak price periods 2025-11-10 11:54:06 +00:00
Julian Pawlowski
817658f230 feat(periods): add gap tolerance for price level filters with intelligent period splitting
Implemented configurable gap tolerance (0-8 intervals) for best price and peak price
level filters to prevent periods from being split by occasional level deviations.

Key features:
- Gap tolerance only applies to periods ≥ MIN_INTERVALS_FOR_GAP_TOLERANCE (1.5h)
- Short periods (< 1.5h) use strict filtering (zero tolerance)
- Dynamic minimum distance between gaps: max(2, (interval_count // max_gap_count) // 2)
- 25% maximum cap on total gaps to prevent excessive outliers in long periods
- Intelligent period splitting at gap clusters (2+ consecutive non-qualifying intervals)
- Each sub-period independently validated with same gap tolerance rules

Technical implementation:
- Added CONF_BEST_PRICE_MAX_LEVEL_GAP_COUNT and CONF_PEAK_PRICE_MAX_LEVEL_GAP_COUNT constants
- Added MIN_INTERVALS_FOR_GAP_TOLERANCE = 6 (1.5h minimum for gap tolerance)
- Implemented _split_at_gap_clusters() for period recovery
- Implemented _check_short_period_strict() for strict short-period filtering
- Implemented _check_level_filter_with_gaps() with fallback splitting logic
- Extracted _check_sequence_with_gap_tolerance() for reusable core validation
- Enhanced _check_level_filter() to use gap-tolerant validation

Configuration UI:
- Added NumberSelector (0-8, slider mode) for gap count in config flow
- Added translations for all 5 languages (de, en, nb, nl, sv)
- Default: 0 (strict filtering, backwards compatible)

Impact: Users can now configure how many occasional level deviations are acceptable
within qualifying price periods. This reduces period fragmentation while maintaining
meaningful price-based filtering. Long periods are protected by the 25% cap, and
gap clusters trigger intelligent splitting to recover usable sub-periods.
2025-11-10 04:38:44 +00:00
Julian Pawlowski
40a335dabe feat(periods): add adaptive filter relaxation for minimum period guarantee
Implemented multi-phase filter relaxation system to ensure minimum number
of best-price and peak-price periods are found, even on days with unusual
price patterns.

New configuration options per period type (best/peak):
- enable_min_periods_{best|peak}: Toggle feature on/off
- min_periods_{best|peak}: Target number of periods (default: 2)
- relaxation_step_{best|peak}: Step size for threshold increase (default: 25%)

Relaxation phases (applied sequentially until target reached):
1. Flex threshold increase (up to 4 steps, e.g., 15% → 18.75% → 22.5% → ...)
2. Volatility filter bypass + continued flex increase
3. All filters off + continued flex increase

Changes to period calculation:
- New calculate_periods_with_relaxation() wrapper function
- filter_periods_by_volatility() now applies post-calculation filtering
- _resolve_period_overlaps() merges baseline + relaxed periods intelligently
- Relaxed periods marked with relaxation_level, relaxation_threshold_* attributes
- Overlap detection prevents double-counting same intervals

Binary sensor attribute ordering improvements:
- Added helper methods for consistent attribute priority
- Relaxation info grouped in priority 6 (after detail attributes)
- Only shown when period was actually relaxed (relaxation_active=true)

Translation updates:
- Added UI labels + descriptions for 6 new config options (all 5 languages)
- Explained relaxation concept with examples in data_description fields
- Clarified volatility filter now applies per-period, not per-day

Impact: Users can configure integration to guarantee minimum number of
periods per day. System automatically relaxes filters when needed while
preserving baseline periods found with strict filters. Particularly useful
for automation reliability on days with flat pricing or unusual patterns.

Fixes edge case where no periods were found despite prices varying enough
for meaningful optimization decisions.
2025-11-10 03:34:09 +00:00
Julian Pawlowski
9640b041e0 refactor(periods): move all period logic to coordinator and refactor period_utils
Moved filter logic and all period attribute calculations from binary_sensor.py
to coordinator.py and period_utils.py, following Home Assistant best practices
for data flow architecture.

ARCHITECTURE CHANGES:

Binary Sensor Simplification (~225 lines removed):
- Removed _build_periods_summary, _add_price_diff_for_period (calculation logic)
- Removed _get_period_intervals_from_price_info (107 lines, interval reconstruction)
- Removed _should_show_periods, _check_volatility_filter, _check_level_filter
- Removed _build_empty_periods_result (filtering result builder)
- Removed _get_price_hours_attributes (24 lines, dead code)
- Removed datetime import (unused after cleanup)
- New: _build_final_attributes_simple (~20 lines, timestamp-only)
- Result: Pure display-only logic, reads pre-calculated data from coordinator

Coordinator Enhancement (+160 lines):
- Added _should_show_periods(): UND-Verknüpfung of volatility and level filters
- Added _check_volatility_filter(): Checks min_volatility threshold
- Added _check_level_filter(): Checks min/max level bounds
- Enhanced _calculate_periods_for_price_info(): Applies filters before period calculation
- Returns empty periods when filters don't match (instead of calculating unnecessarily)
- Passes volatility thresholds (moderate/high/very_high) to PeriodConfig

Period Utils Refactoring (+110 lines):
- Extended PeriodConfig with threshold_volatility_moderate/high/very_high
- Added PeriodData NamedTuple: Groups timing data (start, end, length, position)
- Added PeriodStatistics NamedTuple: Groups calculated stats (prices, volatility, ratings)
- Added ThresholdConfig NamedTuple: Groups all thresholds + reverse_sort flag
- New _calculate_period_price_statistics(): Extracts price_avg/min/max/spread calculation
- New _build_period_summary_dict(): Builds final dict with correct attribute ordering
- Enhanced _extract_period_summaries(): Now calculates ALL attributes (no longer lightweight):
  * price_avg, price_min, price_max, price_spread (in minor units: ct/øre)
  * volatility (low/moderate/high/very_high based on absolute thresholds)
  * rating_difference_% (average of interval differences)
  * period_price_diff_from_daily_min/max (period avg vs daily reference)
  * aggregated level and rating_level
  * period_interval_count (renamed from interval_count for clarity)
- Removed interval_starts array (redundant - start/end/count sufficient)
- Function signature refactored from 9→4 parameters using NamedTuples

Code Organization (HA Best Practice):
- Moved calculate_volatility_level() from const.py to price_utils.py
- Rule: const.py should contain only constants, no functions
- Removed duplicate VOLATILITY_THRESHOLD_* constants from const.py
- Updated imports in sensor.py, services.py, period_utils.py

DATA FLOW:

Before:
API → Coordinator (basic enrichment) → Binary Sensor (calculate everything on each access)

After:
API → Coordinator (enrichment + filtering + period calculation with ALL attributes) →
      Cached Data → Binary Sensor (display + timestamp only)

ATTRIBUTE STRUCTURE:

Period summaries now contain (following copilot-instructions.md ordering):
1. Time: start, end, duration_minutes
2. Decision: level, rating_level, rating_difference_%
3. Prices: price_avg, price_min, price_max, price_spread, volatility
4. Differences: period_price_diff_from_daily_min/max (conditional)
5. Details: period_interval_count, period_position
6. Meta: periods_total, periods_remaining

BREAKING CHANGES: None
- Period data structure enhanced but backwards compatible
- Binary sensor API unchanged (state + attributes)

Impact: Binary sensors now display pre-calculated data from coordinator instead
of calculating on every access. Reduces complexity, improves performance, and
centralizes business logic following Home Assistant coordinator pattern. All
period filtering (volatility + level) now happens in coordinator before caching.
2025-11-09 23:46:48 +00:00
Julian Pawlowski
b36a94d53b feat(translations): update language style and tone for user instructions across multiple languages 2025-11-09 19:27:42 +00:00
Julian Pawlowski
45b26dbf8a docs: update installation instructions and add configuration steps for HACS integration 2025-11-09 18:37:18 +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
0832c5c071 feat(release): add dynamic release title generation
Release titles now automatically reflect the type of changes:
- 'vX.Y.Z - New Features & Bug Fixes' (both present)
- 'vX.Y.Z - New Features' (only features)
- 'vX.Y.Z - Bug Fixes' (only fixes)
- 'vX.Y.Z' (fallback for other changes)

Determined by analyzing commit messages between previous tag and current tag.

Impact: Release titles are more descriptive and immediately show what
changed, making it easier for users to understand the release at a glance.
2025-11-09 16:33:46 +00:00
Julian Pawlowski
256caab2ff feat(workflows): add concurrency control to prevent duplicate runs
Added concurrency groups with cancel-in-progress to validate.yml, lint.yml,
and auto-tag.yml workflows.

This ensures that when multiple commits are pushed quickly:
- Only the latest validation/lint run continues
- Older runs are automatically cancelled
- Saves CI minutes and provides faster feedback

Release workflow intentionally excluded (each tag is unique).

Impact: More efficient CI usage, faster feedback on rapid commits.
2025-11-09 16:30:34 +00:00
Julian Pawlowski
605e05ea95 fix(workflows): remove duplicate validation runs in release workflow
Release workflow now trusts that validate.yml and lint.yml have already
run on the main branch commit before tag creation. This prevents duplicate
workflow executions.

Workflow execution flow:
1. Push to main → validate.yml + lint.yml run (quality gate)
2. prepare-release or auto-tag creates version tag
3. release.yml runs (generates release notes, no validation)

This ensures:
- Every main commit is validated/linted before tag creation
- No duplicate workflow runs (validate/lint run once per commit)
- Release workflow is faster (no redundant checks)
- Simple, predictable workflow chain

Impact: Release process is more efficient and workflows don't run twice.
2025-11-09 16:26:16 +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
900e77203a chore(release): bump version to 0.3.0 2025-11-09 16:06:34 +00:00
Julian Pawlowski
ae82e4637c fix: handle missing entry_id in reauth flow and ensure integration version is a string 2025-11-09 16:04:18 +00:00
Julian Pawlowski
da5a723777 fix: update return type annotation for API request method and ensure exceptions are raised 2025-11-09 16:04:12 +00:00
Julian Pawlowski
12fbe33bb9 fix: handle unknown integration version in setup entry 2025-11-09 16:04:04 +00:00
Julian Pawlowski
6a2b7037c9 chore(markdownlint): add initial configuration file 2025-11-09 16:02:19 +00:00
Julian Pawlowski
d81ba5e977 chore(devcontainer): consolidate VS Code settings and remove deprecated options
Migrated all settings from .vscode/settings.json to devcontainer.json
for team-wide consistency. Removed .vscode/settings.json entirely.

Changes:
- Added python.analysis.exclude to prevent Pylance from analyzing
  .venv, .github, docs and other non-code directories (eliminates
  2000+ false errors)
- Added python.analysis.diagnosticMode: workspace for comprehensive
  analysis of integration code
- Added source.organizeImports.ruff for automatic import sorting
- Added markdown.wordWrap and disabled markdown link validation
- Removed deprecated python.linting.* settings (deprecated since 2023)
- Removed editor.formatOnPaste (conflicts with Copilot)
- Changed source.organizeImports to source.organizeImports.ruff
  (Ruff-specific, prevents conflicts with Pylance)
- Changed source.fixAll to source.fixAll.ruff (explicit Ruff action)

Impact: All developers get identical Copilot-friendly environment
without local overrides. No Pylance errors from .venv directories,
no markdown validation warnings, no conflicts between Copilot and
auto-formatting.
2025-11-09 16:01:54 +00:00
Julian Pawlowski
6ebcdc90c0 docs(workflow): document release automation and validation patterns
Updated copilot-instructions.md with comprehensive documentation for
new release workflows and validation requirements.

Added sections:
- Selector validation rules for hassfest compliance
  - Pattern requirement: [a-z0-9-_]+ (lowercase only)
  - Common pitfalls with SelectOptionDict and translation_key
  - Validation examples (correct vs incorrect)

- Legacy/Backwards compatibility guidelines
  - When to add migration code vs breaking changes
  - check-if-released script usage
  - Rule: Only migrate for released changes
  - Prefer documentation over complexity

- Semantic versioning workflow
  - Pre-1.0 vs Post-1.0 versioning rules
  - suggest-version script usage and output
  - prepare-release integration
  - Version check in CI/CD

- Release notes generation
  - Updated with auto-sync and version check features
  - Backend comparison (AI vs git-cliff vs manual)
  - Complete workflow examples

Impact: AI assistant and developers have clear guidance on hassfest
requirements, legacy migration decisions, and the complete release
automation workflow. Reduces errors and maintains consistency across
sessions.
2025-11-09 15:33:26 +00:00
Julian Pawlowski
d7a145d678 feat(ci): add manifest sync and version validation to release workflow
Implemented automatic manifest.json synchronization and semantic
versioning validation in the release workflow.

Auto-Sync Manifest (sync-manifest job):
- Extracts version from Git tag (v*.*.*)
- Compares with manifest.json version
- Auto-updates manifest.json if mismatch detected
- Commits changes back to main branch
- Sets outputs (updated, version) for downstream jobs
- Prevents HACS version mismatches and conflicts with auto-tag.yml

Version Check Warning System (version_check step):
- Analyzes commits between tags for breaking changes, features, fixes
- Applies semantic versioning rules (pre-1.0 and post-1.0)
- Detects inappropriate version bumps:
  - Features with only PATCH bump → suggests MINOR
  - Breaking changes with only MINOR bump → suggests MAJOR (post-1.0)
  - Breaking changes with only PATCH bump → suggests MINOR (pre-1.0)
- Shows warnings in GitHub Step Summary (prominent)
- Appends warnings to release notes body
- Provides fix instructions but doesn't fail workflow
- Updates final summary with version check status

Workflow changes:
- release-notes job now depends on sync-manifest
- Checks out main branch to get updated manifest if synced
- Summary shows manifest sync status and version check result

Impact: Prevents manual version tag issues, maintains manifest
consistency, and warns about semantic versioning violations without
blocking releases. Fully transparent workflow with clear guidance.
2025-11-09 15:33: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
7e57facf50 fix(translations): restore corrupted Norwegian and Dutch translations
Restored valid Norwegian (nb) and Dutch (nl) translations from git
commit 5e0a297 after corruption caused JSON parsing errors.

Added 4 missing volatility sensor translations to both languages:
- today_volatility
- tomorrow_volatility
- next_24h_volatility
- today_tomorrow_volatility

All translations include complete description, long_description, and
usage_tips fields.

Impact: Norwegian and Dutch users now see complete, properly translated
sensor descriptions. JSON validation passes without errors.
2025-11-09 15:31:56 +00:00
Julian Pawlowski
532a91be58 fix(translations): resolve hassfest selector key validation errors
Changed all selector option keys from uppercase to lowercase to comply
with Home Assistant's hassfest validation pattern [a-z0-9-_]+.

Fixed inconsistency in PEAK_PRICE_MIN_LEVEL_OPTIONS where some values
were uppercase while others were lowercase.

Changes:
- translations/*.json: All selector keys now lowercase (volatility, price_level)
- const.py: Added .lower() to all PEAK_PRICE_MIN_LEVEL_OPTIONS values
- binary_sensor.py: Added .upper() conversion when looking up price levels
  in PRICE_LEVEL_MAPPING to handle lowercase config values

Impact: Config flow now works correctly with translated selector options.
Hassfest validation passes without selector key errors.
2025-11-09 15:31:37 +00:00
Julian Pawlowski
df79afc87e docs: restructure documentation and add AI development disclosure
Created professional documentation structure:

**User Documentation (docs/user/):**
- README.md: Documentation hub with quick start guide
- Placeholder files for future content migration:
  * installation.md, configuration.md, sensors.md
  * services.md, automation-examples.md, troubleshooting.md

**Developer Documentation (docs/development/):**
- README.md: Comprehensive contributor guide with AI section
- setup.md: DevContainer and environment setup
- architecture.md: Code structure overview
- testing.md: Testing guidelines
- coding-guidelines.md: Style guide and critical patterns
- release-management.md: Complete release workflow documentation

**AI Development Disclosure:**
- README.md: "🤖 Development Note" section before license
  * Honest disclosure about extensive AI assistance
  * Quality assurance measures mentioned
  * Invitation for bug reports with positive tone
- docs/development/README.md: Detailed AI section
  * What AI handles (patterns, generation, refactoring)
  * Benefits (rapid development, consistency)
  * Limitations (edge cases, complex patterns)
  * Quality assurance process
- CONTRIBUTING.md: Brief AI note with practical tip

**Updated:**
- README.md: Simplified to landing page with documentation links
- CONTRIBUTING.md: Modernized with new docs structure
- copilot-instructions.md: Added documentation organization section

Impact: Clear separation of user vs. developer documentation following
open-source best practices. Transparent about AI-assisted development
approach without being defensive. Scalable structure for future growth.
2025-11-09 14:25:27 +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
8880df1bee chore(devcontainer): update extensions and add Rust feature
- Added ghcr.io/devcontainers/features/rust:1 (minimal profile)
- Reorganized extension IDs into categories (Python, GitHub, Tools)
- Sorted extensions alphabetically within categories

Impact: DevContainer now includes Rust toolchain for building git-cliff
(release notes backend). No user-visible changes.
2025-11-09 14:24:55 +00:00
Julian Pawlowski
f4568be34e feat(sensors): add price volatility analysis and period filters
Added comprehensive volatility analysis system:
- 4 new volatility sensors (today, tomorrow, next_24h, today+tomorrow)
- Volatility classification (LOW/MODERATE/HIGH/VERY HIGH) based on price spread
- Configurable thresholds in options flow (step 6 of 6)
- Best/Peak price period filters using volatility and price level
- Price spread calculation in get_price service

Volatility sensors help users decide if price-based optimization is worthwhile.
For example, battery optimization only makes sense when volatility ≥ MODERATE.

Period filters allow AND-logic combinations:
- best_price_min_volatility: Only show cheap periods on volatile days
- best_price_max_level: Only show periods when prices reach desired level
- peak_price_min_volatility: Only show peaks on volatile days
- peak_price_min_level: Only show peaks when expensive levels occur

All 5 language files updated (de, en, nb, nl, sv) with:
- Volatility sensor translations (name, states, descriptions)
- Config flow step 6 "Volatility" with threshold settings
- Step progress indicators added to all config steps
- Period filter translations with usage tips

Impact: Users can now assess daily price volatility and configure period
sensors to only activate when conditions justify battery cycling or load
shifting. Reduces unnecessary battery wear on low-volatility days.
2025-11-09 14:24:34 +00:00
Julian Pawlowski
165bbd4d88 docs(workflow): enhance copilot-instructions with detailed documentation update process
Expanded the documentation to include a comprehensive update process for maintaining consistency between code and documentation. Added sections on automatic inconsistency detection, documentation update proposals, and guidelines for testing changes and git workflow.

Impact: Ensures accurate documentation and streamlined workflows for future development sessions.
2025-11-09 12:49:41 +00:00
Julian Pawlowski
cecffed4db refactor: Update Python interpreter path and enhance environment configuration for better development setup 2025-11-09 12:49:22 +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
32e429624e refactor: Adjust suggested display precision for future average price sensors and add timestamp attributes for next average calculations 2025-11-08 17:06:19 +00:00
Julian Pawlowski
ac100216ee refactor: Update attribute naming and ordering for clarity and consistency 2025-11-08 16:50:55 +00:00
Julian Pawlowski
db0d65a939 feat: Add price trend thresholds configuration and update related calculations 2025-11-08 16:02:21 +00:00
Julian Pawlowski
5ba0633d15 refactor: Store trend attributes in a sensor-specific dictionary for better organization 2025-11-08 15:30:55 +00:00
Julian Pawlowski
f9f4908748 refactor: Enhance period calculations with aggregated levels and ratings 2025-11-08 15:01:25 +00:00
Julian Pawlowski
db3299b7a7 Add period calculation for best and peak prices
- Introduced a new utility module `period_utils.py` for calculating price periods.
- Implemented `_get_period_config` method to retrieve configuration for best and peak price calculations.
- Added `_calculate_periods_for_price_info` method to compute best and peak price periods based on price data.
- Enhanced `TibberPricesDataUpdateCoordinator` to include calculated periods in the data transformation methods.
- Updated configuration constants for best and peak price settings.
2025-11-08 14:26:46 +00:00
Julian Pawlowski
3f3edd8a28 refactor: Update price level and rating options to inline definitions for sensor initialization 2025-11-08 09:24:28 +00:00