Open edwin-bergstedt opened 1 year ago
That’s correct. We do use median to calculate the mean. I have no idea why I ended up calling that attribute mean…
When both the daily average and the current spot price is negative, _price_percent_to_average is not calulated correctly. An even lower negative spot price will make _price_percent_to_average larger.
I bumped into using mean incorrect due to its naming.
To avoid confusion for users, I kindly request that the attribute name be updated from “mean” to “median” to accurately reflect its function. Additionally, I recommend providing a clear notification about this change in the update notes to inform users who rely on the “mean” attribute, ensuring a smooth transition.
Thank you for your attention to this matter.
Kind regards, Erwin
Version of the custom_component
0.0.14
Homeassistant version
2023.9.3
Configuration
Describe the bug
The value calculated under "Mean" is not the mean value, mean and average are almost always the same. The value calculated is probably the Median, the center of all values.
If i run the values for today (24/8) in python:
state_class: total average: 1.2279166666666668 off_peak_1: 0.30575 off_peak_2: 2.0285 peak: 1.5758333333333332 min: 0.276 max: 3.851 mean: 0.435 unit: kWh currency: SEK country: Sweden region: SE3 low_price: true price_percent_to_average: 0.3583305055989141 today:
Output from Pandas DataFrame: count 24.000000 mean 1.227917 std 1.141570 min 0.276000 25% 0.321500 50% 0.435000 75% 2.309500 max 3.851000 median 0.435
The average is equal to the mean at 1.2279, but the mean is probably mislabelled and should be called median instead.
Debug log