mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-30 05:13:40 +00:00
Enhanced current_price_trend and next_price_trend_change sensors with consistent temporal information and fixed trend calculation logic. Changes: - Fixed trend calculation order: Calculate final trend state (momentum + future outlook) BEFORE scanning for next change, ensuring consistency between current_price_trend state and next_price_trend_change from_direction - Added TIME_SENSITIVE_ENTITY_KEYS registration for both trend sensors to enable automatic 15-minute boundary updates (Timer #2) - Removed redundant timestamp field from _trend_change_attributes (was duplicate of sensor state) - Added timestamp attribute (current interval) to both sensors as first attribute for temporal reference - Implemented _find_trend_start_time() to scan backward and determine when current trend began - Added trend_duration_minutes to current_price_trend showing how long current trend has been active - Added from_direction to current_price_trend showing previous trend state (enables detection of valleys/plateaus) - Added minutes_until_change to next_price_trend_change showing time until trend changes - Removed redundant attributes: valid_until, duration_hours, duration_minutes from current_price_trend (can be derived from next_price_trend_change sensor) - Removed redundant next_direction from current_price_trend (available in next_price_trend_change sensor) current_price_trend attributes: - timestamp: Current interval (calculation basis) - from_direction: Previous trend state (e.g., "stable" → "falling" = starting decline) - trend_duration_minutes: How long current trend has been active next_price_trend_change attributes: - timestamp: Current interval (calculation basis) - from_direction: Current trend state (should match current_price_trend state) - direction: Target trend state - minutes_until_change: Time until change occurs - current_price_now, price_at_change, avg_after_change, trend_diff_% Impact: Users can now detect important transitions (valleys: falling→stable, plateaus: rising→stable) and understand trend context. Both sensors update automatically every 15 minutes with consistent information. |
||
|---|---|---|
| .. | ||
| tibber_prices | ||