hass.tibber_prices/custom_components/tibber_prices/sensor/calculators
Julian Pawlowski 5fc1f4db33 feat(sensors): add 5-level price trend scale with configurable thresholds
Extends trend sensors from 3-level (rising/stable/falling) to 5-level scale
(strongly_rising/rising/stable/falling/strongly_falling) for finer granularity.

Changes:
- Add PRICE_TREND_MAPPING with integer values (-2, -1, 0, +1, +2) matching
  PRICE_LEVEL_MAPPING pattern for consistent automation comparisons
- Add configurable thresholds for strongly_rising (default: 6%) and
  strongly_falling (default: -6%) independent from base thresholds
- Update calculate_price_trend() to return 3-tuple: (trend_state, diff_pct, trend_value)
- Add trend_value attribute to all trend sensors for numeric comparisons
- Update sensor entity descriptions with 5-level options
- Add validation with cross-checks (strongly_rising > rising, etc.)
- Update icons: chevron-double-up/down for strong trends, trending-up/down for normal

Files changed:
- const.py: PRICE_TREND_* constants, PRICE_TREND_MAPPING, config constants
- utils/price.py: Extended calculate_price_trend() signature and return value
- sensor/calculators/trend.py: Pass new thresholds, handle 3-tuple return
- sensor/definitions.py: 5-level options for all 9 trend sensors
- sensor/core.py: 5-level icon mapping
- entity_utils/icons.py: 5-level trend icons
- config_flow_handlers/: validators, schemas, options_flow for new settings
- translations/*.json: Labels and error messages (en, de, nb, sv, nl)
- tests/test_percentage_calculations.py: Updated for 3-tuple return

Impact: Users get more nuanced trend information for automation decisions.
New trend_value attribute enables numeric comparisons (e.g., > 0 for any rise).
Existing automations using "rising"/"falling"/"stable" continue to work.
2026-01-20 13:36:01 +00:00
..
__init__.py feat(sensor): add data lifecycle diagnostic sensor with push updates 2025-11-20 15:12:41 +00:00
base.py refactor(price_info): price data handling to use unified interval retrieval 2025-11-24 10:49:34 +00:00
daily_stat.py refactor(currency)!: rename major/minor to base/subunit currency terminology 2025-12-11 08:26:30 +00:00
interval.py refactor(currency)!: rename major/minor to base/subunit currency terminology 2025-12-11 08:26:30 +00:00
lifecycle.py fix(sensor): streamline lifecycle attrs and next poll visibility 2025-12-26 12:13:36 +00:00
metadata.py refactor(naming): complete class naming convention alignment 2025-11-20 11:22:53 +00:00
rolling_hour.py feat(sensors): always show both mean and median in average sensor attributes 2025-12-18 15:12:30 +00:00
timing.py refactor: migrate from multi-home to single-home-per-coordinator architecture 2025-11-24 16:24:37 +00:00
trend.py feat(sensors): add 5-level price trend scale with configurable thresholds 2026-01-20 13:36:01 +00:00
volatility.py fix(volatility): expose price coefficient variation attribute 2025-12-25 19:10:42 +00:00
window_24h.py feat(sensors): always show both mean and median in average sensor attributes 2025-12-18 15:12:30 +00:00