From 9efa7809d02ea274727f49acff88df765d7fc83a Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Tue, 14 Apr 2026 09:22:34 +0000 Subject: [PATCH] refactor(colors, icons): enhance trend-related color and icon handling Updated color and icon logic to include additional keys for price trends, outlooks, and trajectories. This improves the visual representation of price changes in the UI. Impact: Users will see more accurate color coding and icons for price trends and forecasts. --- custom_components/tibber_prices/entity_utils/colors.py | 6 +++++- custom_components/tibber_prices/entity_utils/icons.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/custom_components/tibber_prices/entity_utils/colors.py b/custom_components/tibber_prices/entity_utils/colors.py index 848b697..70408ee 100644 --- a/custom_components/tibber_prices/entity_utils/colors.py +++ b/custom_components/tibber_prices/entity_utils/colors.py @@ -65,10 +65,14 @@ def get_icon_color( return BINARY_SENSOR_COLOR_MAPPING[key].get(state_key) # Trend sensor colors (based on trend state) - if key.startswith("price_trend_") and isinstance(state_value, str): + if ( + key.startswith(("price_trend_", "price_outlook_", "price_trajectory_")) or key == "current_price_trend" + ) and isinstance(state_value, str): trend_colors = { + "strongly_rising": "var(--error-color)", "rising": "var(--error-color)", # Red/Orange for rising prices "falling": "var(--success-color)", # Green for falling prices + "strongly_falling": "var(--success-color)", "stable": "var(--state-icon-color)", # Default gray for stable } return trend_colors.get(state_value) diff --git a/custom_components/tibber_prices/entity_utils/icons.py b/custom_components/tibber_prices/entity_utils/icons.py index 9bec4d7..a04390c 100644 --- a/custom_components/tibber_prices/entity_utils/icons.py +++ b/custom_components/tibber_prices/entity_utils/icons.py @@ -91,7 +91,7 @@ def get_trend_icon(key: str, value: Any) -> str | None: if key == "next_price_trend_change": return None # Will be handled by sensor's icon property using attributes - if not key.startswith("price_trend_") and key != "current_price_trend": + if not key.startswith(("price_trend_", "price_outlook_", "price_trajectory_")) and key != "current_price_trend": return None if not isinstance(value, str):