mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix statistic bug in Tibber sensor (#116112)
* Handle keyError in Tibber sensor Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net> * Constant Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net> --------- Signed-off-by: Daniel Hjelseth Høyer <github@dahoiv.net>
This commit is contained in:
parent
67021be274
commit
830e8d7b94
@ -53,6 +53,8 @@ from homeassistant.util import Throttle, dt as dt_util
|
|||||||
|
|
||||||
from .const import DOMAIN as TIBBER_DOMAIN, MANUFACTURER
|
from .const import DOMAIN as TIBBER_DOMAIN, MANUFACTURER
|
||||||
|
|
||||||
|
FIVE_YEARS = 5 * 365 * 24
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ICON = "mdi:currency-usd"
|
ICON = "mdi:currency-usd"
|
||||||
@ -724,9 +726,16 @@ class TibberDataCoordinator(DataUpdateCoordinator[None]): # pylint: disable=has
|
|||||||
None,
|
None,
|
||||||
{"sum"},
|
{"sum"},
|
||||||
)
|
)
|
||||||
first_stat = stat[statistic_id][0]
|
if statistic_id in stat:
|
||||||
_sum = cast(float, first_stat["sum"])
|
first_stat = stat[statistic_id][0]
|
||||||
last_stats_time = first_stat["start"]
|
_sum = cast(float, first_stat["sum"])
|
||||||
|
last_stats_time = first_stat["start"]
|
||||||
|
else:
|
||||||
|
hourly_data = await home.get_historic_data(
|
||||||
|
FIVE_YEARS, production=is_production
|
||||||
|
)
|
||||||
|
_sum = 0.0
|
||||||
|
last_stats_time = None
|
||||||
|
|
||||||
statistics = []
|
statistics = []
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user