mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-05-28 18:43:40 +00:00
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.
This commit is contained in:
parent
ff08df24e7
commit
9efa7809d0
2 changed files with 6 additions and 2 deletions
|
|
@ -65,10 +65,14 @@ def get_icon_color(
|
||||||
return BINARY_SENSOR_COLOR_MAPPING[key].get(state_key)
|
return BINARY_SENSOR_COLOR_MAPPING[key].get(state_key)
|
||||||
|
|
||||||
# Trend sensor colors (based on trend state)
|
# 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 = {
|
trend_colors = {
|
||||||
|
"strongly_rising": "var(--error-color)",
|
||||||
"rising": "var(--error-color)", # Red/Orange for rising prices
|
"rising": "var(--error-color)", # Red/Orange for rising prices
|
||||||
"falling": "var(--success-color)", # Green for falling prices
|
"falling": "var(--success-color)", # Green for falling prices
|
||||||
|
"strongly_falling": "var(--success-color)",
|
||||||
"stable": "var(--state-icon-color)", # Default gray for stable
|
"stable": "var(--state-icon-color)", # Default gray for stable
|
||||||
}
|
}
|
||||||
return trend_colors.get(state_value)
|
return trend_colors.get(state_value)
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ def get_trend_icon(key: str, value: Any) -> str | None:
|
||||||
if key == "next_price_trend_change":
|
if key == "next_price_trend_change":
|
||||||
return None # Will be handled by sensor's icon property using attributes
|
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
|
return None
|
||||||
|
|
||||||
if not isinstance(value, str):
|
if not isinstance(value, str):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue