mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-03-29 21:03:40 +00:00
feat(sensor): add icon color determination based on price trend state
This commit is contained in:
parent
6521aa7bdd
commit
fe5af68f8e
1 changed files with 8 additions and 0 deletions
|
|
@ -1307,6 +1307,13 @@ class TibberPricesSensor(TibberPricesEntity, SensorEntity):
|
|||
current_price, future_avg, threshold_rising=threshold_rising, threshold_falling=threshold_falling
|
||||
)
|
||||
|
||||
# Determine icon color based on trend state
|
||||
icon_color = {
|
||||
"rising": "var(--error-color)", # Red/Orange for rising prices (expensive)
|
||||
"falling": "var(--success-color)", # Green for falling prices (cheaper)
|
||||
"stable": "var(--state-icon-color)", # Default gray for stable prices
|
||||
}.get(trend_state, "var(--state-icon-color)")
|
||||
|
||||
# Store attributes in sensor-specific dictionary AND cache the trend value
|
||||
self._trend_attributes = {
|
||||
"timestamp": next_interval_start.isoformat(),
|
||||
|
|
@ -1315,6 +1322,7 @@ class TibberPricesSensor(TibberPricesEntity, SensorEntity):
|
|||
"interval_count": hours * 4,
|
||||
"threshold_rising": threshold_rising,
|
||||
"threshold_falling": threshold_falling,
|
||||
"icon_color": icon_color,
|
||||
}
|
||||
|
||||
# Calculate additional attributes for better granularity
|
||||
|
|
|
|||
Loading…
Reference in a new issue