Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions homeassistant/components/sensor/tibber.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def _update_current_price(self):
state = None
max_price = 0
min_price = 10000
sum_price = 0
num = 0
now = dt_util.now()
for key, price_total in self._tibber_home.price_total.items():
price_time = dt_util.as_local(dt_util.parse_datetime(key))
Expand All @@ -146,8 +148,11 @@ def _update_current_price(self):
if now.date() == price_time.date():
max_price = max(max_price, price_total)
min_price = min(min_price, price_total)
num += 1
sum_price += price_total
self._state = state
self._device_state_attributes['max_price'] = max_price
self._device_state_attributes['avg_price'] = sum_price / num
self._device_state_attributes['min_price'] = min_price
return state is not None

Expand Down