hass.tibber_prices/custom_components/tibber_prices
Julian Pawlowski 0a4af0de2f feat(sensor): convert timing sensors to hour-based display with minute attributes
Convert best_price and peak_price timing sensors to display in hours (UI-friendly)
while retaining minute values in attributes (automation-friendly). This improves
readability in dashboards by using Home Assistant's automatic duration formatting
"1 h 35 min" instead of decimal "1.58 h".

BREAKING CHANGE: State unit changed from minutes to hours for 6 timing sensors.

Affected sensors:
  * best_price_period_duration, best_price_remaining_minutes, best_price_next_in_minutes
  * peak_price_period_duration, peak_price_remaining_minutes, peak_price_next_in_minutes

Migration guide for users:
  - If your automations use {{ state_attr(..., 'remaining_time') }} or similar:
    No action needed - attribute values remain in minutes
  - If your automations use {{ states('sensor.best_price_remaining_minutes') }} directly:
    Update to use the minute attribute instead: {{ state_attr('sensor.best_price_remaining_minutes', 'remaining_minutes') }}
  - If your dashboards display the state value:
    Values now show as "1 h 35 min" instead of "95" - this is the intended improvement
  - If your templates do math with the state: multiply by 60 to convert hours back to minutes
    Before: remaining * 60
    After: remaining_minutes (use attribute directly)

Implementation details:
- Timing sensors now use device_class=DURATION, unit=HOURS, precision=2
- State values converted from minutes to hours via _minutes_to_hours()
- New minute-precision attributes added for automation compatibility:
  * period_duration_minutes (for checking if period is long enough)
  * remaining_minutes (for countdown-based automation logic)
  * next_in_minutes (for time-to-event automation triggers)
- Translation improvements across all 5 languages (en, de, nb, nl, sv):
  * Descriptions now clarify state in hours vs attributes in minutes
  * Long descriptions explain dual-format architecture
  * Usage tips updated to reference minute attributes for automations
  * All translation files synchronized (fixed order, removed duplicates)
- Type safety: Added type assertions (cast) for timing calculator results to
  satisfy Pyright type checking (handles both float and datetime return types)

Home Assistant now automatically formats these durations as "1 h 35 min" for improved
UX, matching the behavior of battery.remaining_time and other duration sensors.

Rationale for breaking change:
The previous minute-based state was unintuitive for users ("95 minutes" doesn't
immediately convey "1.5 hours") and didn't match Home Assistant's standard duration
formatting. The new hour-based state with minute attributes provides:
- Better UX: Automatic "1 h 35 min" formatting in UI
- Full automation compatibility: Minute attributes for all calculation needs
- Consistency: Matches HA's duration sensor pattern (battery, timer, etc.)

Impact: Timing sensors now display in human-readable hours with full backward
compatibility via minute attributes. Users relying on direct state access must
migrate to minute attributes (simple change, documented above).
2025-12-26 16:03:00 +00:00
..
api fix(api): handle None values in API responses to prevent AttributeError 2025-12-13 14:02:30 +00:00
binary_sensor fix(volatility): expose price coefficient variation attribute 2025-12-25 19:10:42 +00:00
config_flow_handlers feat(config_flow): add price level gap tolerance for Tibber API level field 2025-12-22 20:25:30 +00:00
coordinator fix(sensor): streamline lifecycle attrs and next poll visibility 2025-12-26 12:13:36 +00:00
custom_translations feat(sensor): convert timing sensors to hour-based display with minute attributes 2025-12-26 16:03:00 +00:00
entity_utils refactor(currency)!: rename major/minor to base/subunit currency terminology 2025-12-11 08:26:30 +00:00
interval_pool fix(coordinator): track API calls separately from cached data usage 2025-12-25 18:53:29 +00:00
sensor feat(sensor): convert timing sensors to hour-based display with minute attributes 2025-12-26 16:03:00 +00:00
services feat(services): add peak price overlay toggle to ApexCharts YAML 2025-12-26 00:07:28 +00:00
translations fix(volatility): expose price coefficient variation attribute 2025-12-25 19:10:42 +00:00
utils feat(utils): add coefficient of variation (CV) calculation 2025-12-22 23:21:38 +00:00
__init__.py refactor(interval_pool): improve reliability and test coverage 2025-12-23 10:10:35 +00:00
config_flow.py feat(config_flow): add price level gap tolerance for Tibber API level field 2025-12-22 20:25:30 +00:00
const.py feat(config_flow): add price level gap tolerance for Tibber API level field 2025-12-22 20:25:30 +00:00
data.py feat(interval-pool): add intelligent interval caching and memory optimization 2025-11-25 20:44:39 +00:00
diagnostics.py refactor(lifecycle): integrate with Pool for sensor metrics 2025-12-23 14:13:34 +00:00
entity.py fix(api): handle None values in API responses to prevent AttributeError 2025-12-13 14:02:30 +00:00
icons.json feat(services): add new services and icons for enhanced functionality and user experience 2025-12-02 18:46:15 +00:00
manifest.json chore(release): bump version to 0.25.0b0 2025-12-25 22:48:07 +00:00
services.yaml feat(services): add peak price overlay toggle to ApexCharts YAML 2025-12-26 00:07:28 +00:00