Commit graph

88 commits

Author SHA1 Message Date
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
b36a94d53b feat(translations): update language style and tone for user instructions across multiple languages 2025-11-09 19:27:42 +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
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
db0d65a939 feat: Add price trend thresholds configuration and update related calculations 2025-11-08 16:02:21 +00:00
Julian Pawlowski
1ed2c08f34 feat: Add minimum period length configuration for best and peak price sensors 2025-11-07 15:16:16 +00:00
Julian Pawlowski
40852b7d84 fix: Update reauthentication titles for Tibber Price integration in multiple languages 2025-11-07 11:13:42 +00:00
Julian Pawlowski
5e0a297a8f Update Dutch and Swedish translations for Tibber Prices integration
- Revised various phrases for clarity and consistency in Dutch (nl.json) and Swedish (sv.json) translations.
- Changed terms from "woning" to "huis" in Dutch for better contextual accuracy.
- Improved readability and grammatical correctness in both languages.
- Ensured all user-facing strings are updated to reflect the latest terminology and phrasing.
2025-11-06 22:53:20 +00:00
Julian Pawlowski
ef1a81ccc1 Refactor translations for electricity prices in multiple languages
- Updated keys from "cents" to more user-friendly terms for current, next, and previous prices.
- Added state descriptions for price levels and ratings, including categories like "very cheap," "cheap," "normal," "expensive," and "very expensive."
- Introduced new average price sensors for the next 1 to 12 hours.
- Added price trend sensors for 1 to 12 hours with states indicating rising, falling, or stable trends.
- Ensured consistency in naming conventions across English, Norwegian, Dutch, and Swedish translations.
2025-11-06 22:36:12 +00:00
Julian Pawlowski
433558f60b feat: Implement reauthentication flow 2025-11-06 16:59:41 +00:00
Julian Pawlowski
3ef588b1f4 fix: Update German translations for peak and best price period labels 2025-11-06 16:01:41 +00:00
Julian Pawlowski
96df4882e0 Add Norwegian, Dutch, and Swedish translations for Tibber Prices integration 2025-11-06 12:03:03 +00:00
Julian Pawlowski
63904fff39 feat: Enhance Tibber Prices integration with new configuration options and improved data handling
- Added new configuration options for minimum distance from average price for best and peak prices.
- Updated default values for best and peak price flexibility.
- Improved coordinator to handle midnight turnover and data rotation more effectively.
- Refactored entity initialization to streamline device information retrieval.
- Updated sensor attributes to use more descriptive names for price values.
- Enhanced translations for new configuration options in English and German.
- Improved unit tests for coordinator functionality, ensuring proper cleanup and async handling.
2025-11-06 11:43:22 +00:00
Julian Pawlowski
af3e112c99 update translations 2025-11-03 22:11:19 +00:00
Julian Pawlowski
bba5f180b0 add lots of new sensors 2025-11-03 20:55:28 +00:00
Julian Pawlowski
5ee780da87 update translations 2025-11-03 09:53:19 +00:00
Julian Pawlowski
02adf47faf fix translations 2025-11-03 00:47:50 +00:00
Julian Pawlowski
d3c91e162a fix 2025-11-03 00:15:03 +00:00
Julian Pawlowski
1f5c8fead8 fix 2025-11-03 00:07:46 +00:00
Julian Pawlowski
8c61292acf refactoring for QUARTER_HOURLY prices 2025-11-02 19:33:19 +00:00
Julian Pawlowski
6b3d299d3d fix options flow 2025-11-02 17:27:37 +00:00
Julian Pawlowski
e02630440a fix options flow 2025-11-02 16:58:47 +00:00
Julian Pawlowski
0ffa17679b fix config flow 2025-11-02 15:46:13 +00:00
Julian Pawlowski
f57fdfde6b update 2025-05-25 22:15:25 +00:00
Julian Pawlowski
b5c278920c refactoring config flow 2025-05-24 20:50:07 +00:00
Julian Pawlowski
1f8158ecea fix 2025-05-19 09:51:52 +00:00
Julian Pawlowski
71b81a9812 refactoring 2025-05-18 14:11:27 +00:00
Julian Pawlowski
0116d5ad62 refactoring 2025-05-17 21:59:04 +00:00
Julian Pawlowski
52cfc4a87f refactoring 2025-05-17 17:39:06 +00:00
Julian Pawlowski
a4859a9d2e
refactoring 2025-05-11 13:21:22 +02:00
Julian Pawlowski
02a226819a refactoring 2025-04-23 23:07:30 +00:00
Julian Pawlowski
3d33d8d6bc add descriptions 2025-04-23 21:13:57 +00:00
Julian Pawlowski
51b028e9b7 add descriptions 2025-04-23 20:18:35 +00:00
Julian Pawlowski
ed779f03f0 refactoring 2025-04-23 20:00:17 +00:00
Julian Pawlowski
dd94351278 refactoring 2025-04-23 16:42:31 +00:00
Julian Pawlowski
23a46faecc add some entities 2025-04-21 19:36:32 +00:00
Julian Pawlowski
73fa6c18a7 add authentication 2025-04-18 16:10:14 +00:00
Julian Pawlowski
8123285489 rename directory 2025-04-18 13:16:59 +00:00