hass.tibber_prices/custom_components/tibber_prices/sensor
Julian Pawlowski ea21b229ee refactor(calculators): consolidate duplicate data access patterns
Refactored Trend, Timing, and Lifecycle calculators to use BaseCalculator
helper methods instead of duplicating data access logic.

Changes:
- TrendCalculator: Simplified 12 lines of repeated price_info access to
  3-4 clean property calls (intervals_today/tomorrow, get_all_intervals)
- TimingCalculator: Replaced direct coordinator.data checks with has_data()
- LifecycleCalculator: Replaced 5 lines of nested gets with 2 helper calls

Benefits:
- Eliminated 10+ duplicate data access patterns
- Consistent None-handling across all calculators
- Single source of truth for coordinator data access
- Easier to maintain (changes propagate automatically)

BaseCalculator helpers used:
- has_data(): Replaces 'if not self.coordinator.data:' checks
- intervals_today/tomorrow: Direct property access to day intervals
- get_intervals(day): Safe day-specific interval retrieval
- get_all_intervals(): Combined yesterday+today+tomorrow
- coordinator_data: Property for coordinator.data access

Validation:
- Type checker: 0 errors, 0 warnings
- Tests: 347 passed, 2 skipped (no behavior change)
- Net: 19 deletions, 14 insertions (5 lines removed, patterns simplified)

Impact: Cleaner code, reduced duplication, consistent error handling.
Future calculator additions will automatically benefit from centralized
data access patterns.
2025-11-22 14:54:06 +00:00
..
attributes feat(types): add TypedDict documentation and BaseCalculator helpers 2025-11-22 14:32:24 +00:00
calculators refactor(calculators): consolidate duplicate data access patterns 2025-11-22 14:54:06 +00:00
__init__.py fix(imports): update imports after utils package reorganization 2025-11-18 20:07:28 +00:00
chart_data.py feat(chart_export): migrate sensor config from UI to configuration.yaml 2025-11-20 13:41:26 +00:00
core.py refactor(coordinator): remove redundant lifecycle callback system 2025-11-22 13:01:17 +00:00
definitions.py feat(sensor): add data lifecycle diagnostic sensor with push updates 2025-11-20 15:12:41 +00:00
helpers.py refactor(naming): complete class naming convention alignment 2025-11-20 11:22:53 +00:00
types.py feat(types): add TypedDict documentation and BaseCalculator helpers 2025-11-22 14:32:24 +00:00
value_getters.py feat(sensor): add data lifecycle diagnostic sensor with push updates 2025-11-20 15:12:41 +00:00