mirror of
https://github.com/jpawlowski/hass.tibber_prices.git
synced 2026-07-27 17:26:48 +00:00
_calculate_metadata()'s inline calc_stats() computed the median as a naive sorted(data)[len(data) // 2], which returns the upper-middle value for even-length datasets instead of averaging the two middle values. A full day is always an even interval count (96 quarter-hours or 24 hours), so this silently overstated "median" and "median_position" in nearly every price_stats block of the get_chartdata response. The rest of the codebase already has a correct calculate_median() in utils/average.py; this was an isolated inline duplicate with the bug. Impact: get_chartdata's price_stats.combined/dayN.median and median_position now report the statistically correct median for chart annotations and metadata-driven dashboards. |
||
|---|---|---|
| .. | ||
| tibber_prices | ||