hass.tibber_prices/custom_components/tibber_prices
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
..
custom_translations fix(translations): restore corrupted Norwegian and Dutch translations 2025-11-09 15:31:56 +00:00
translations feat(periods): add gap tolerance for price level filters with intelligent period splitting 2025-11-10 04:38:44 +00:00
__init__.py fix: handle unknown integration version in setup entry 2025-11-09 16:04:04 +00:00
api.py fix: update return type annotation for API request method and ensure exceptions are raised 2025-11-09 16:04:12 +00:00
average_utils.py feat: Add function to calculate average price for the next N hours 2025-11-06 22:35:53 +00:00
binary_sensor.py feat(periods): add adaptive filter relaxation for minimum period guarantee 2025-11-10 03:34:09 +00:00
config_flow.py feat(periods): add gap tolerance for price level filters with intelligent period splitting 2025-11-10 04:38:44 +00:00
const.py feat(periods): add gap tolerance for price level filters with intelligent period splitting 2025-11-10 04:38:44 +00:00
coordinator.py feat(periods): add gap tolerance for price level filters with intelligent period splitting 2025-11-10 04:38:44 +00:00
data.py refactoring 2025-04-23 16:42:31 +00:00
diagnostics.py update dev environment 2025-11-03 15:54:01 +00:00
entity.py fix: Remove unused model_id attribute from TibberPricesEntity 2025-11-07 14:45:33 +00:00
manifest.json chore(release): bump version to 0.3.0 2025-11-09 16:06:34 +00:00
period_utils.py feat(periods): add adaptive filter relaxation for minimum period guarantee 2025-11-10 03:34:09 +00:00
price_utils.py refactor(periods): move all period logic to coordinator and refactor period_utils 2025-11-09 23:46:48 +00:00
sensor.py refactor(periods): move all period logic to coordinator and refactor period_utils 2025-11-09 23:46:48 +00:00
services.py refactor(periods): move all period logic to coordinator and refactor period_utils 2025-11-09 23:46:48 +00:00
services.yaml update 2025-05-25 22:15:25 +00:00