Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predbat shows jumps in actual cost figure despite also showing no increase in consumption #1663

Open
cyberkryten opened this issue Nov 26, 2024 · 5 comments
Assignees

Comments

@cyberkryten
Copy link

Describe the bug
At various points during the day, the actual cost recorded by Predbat increases significantly. It has been doing this for ages, and I've been unable to figure out why - only just updated everything to full versions and got back to it, hence raising now.

Expected behaviour
At these times, there is no increase in the energy usage on any metric or recorded by Predbat - the actual cost reported just jumps up for no apparent reason. Debug doesn't show the calculation (that I can see) so I cannot tell what Predbat thinks is costing this large amount extra.

I'm on IOG, so rates do change throughout the day, but that's 26p peak and 7p off-peak, all that changes are some future slots become 7p, so I can't see it is related to that.

Predbat version
8.7.2
HAOS, HACS etc all updated to latest versions yesterday

Environment details
SolarEdge 8kW Inverter, 24 panels, Three 9.7kWh Solaredge batteries
Appdaemon install

Screenshots
Here you can see a plot of the Predbat values showing the actual reported cost above the readings from Smart Meter/Solar showing energy usage. When the Predbat costs line jumps vertically up, there is no increase in any of the consumption graphs.

HA Predbat Cost Increase

Log file

Yesterday afternoon - change from £2.91 to £5.41 despite energy import remaining at 43.32kWh (and exporting!)

2024-11-25 15:50:05.079517 INFO pred_bat: Today's energy import 41.59 kWh export 19.36 kWh total 22.24 kWh cost 295.64 p import 487.4 p export -253.99 p carbon 0.0 kg
2024-11-25 15:55:05.100751 INFO pred_bat: Today's energy import 42.35 kWh export 19.36 kWh total 22.99 kWh cost 300.95 p import 492.71 p export -253.99 p carbon 0.0 kg
2024-11-25 16:00:05.170348 INFO pred_bat: Today's energy import 43.09 kWh export 19.36 kWh total 23.74 kWh cost 306.16 p import 497.92 p export -253.99 p carbon 0.0 kg
2024-11-25 16:05:04.824493 INFO pred_bat: Today's energy import 43.32 kWh export 19.55 kWh total 23.77 kWh cost 306.92 p import 503.83 p export -259.13 p carbon 0.0 kg
2024-11-25 16:10:05.145151 INFO pred_bat: Today's energy import 43.32 kWh export 19.84 kWh total 23.48 kWh cost 299.35 p import 503.83 p export -266.7 p carbon 0.0 kg
2024-11-25 16:15:05.021988 INFO pred_bat: Today's energy import 43.32 kWh export 20.14 kWh total 23.18 kWh cost 291.64 p import 503.83 p export -274.41 p carbon 0.0 kg
2024-11-25 16:20:18.989122 INFO pred_bat: Today's energy import 43.32 kWh export 20.42 kWh total 22.9 kWh cost 541.83 p import 761.4 p export -281.8 p carbon 0.0 kg
2024-11-25 16:25:09.537761 INFO pred_bat: Today's energy import 43.32 kWh export 20.69 kWh total 22.63 kWh cost 534.64 p import 761.4 p export -288.99 p carbon 0.0 kg
2024-11-25 16:30:18.501248 INFO pred_bat: Today's energy import 43.32 kWh export 20.98 kWh total 22.34 kWh cost 527.15 p import 761.4 p export -296.48 p carbon 0.0 kg
2024-11-25 16:35:13.350500 INFO pred_bat: Today's energy import 43.32 kWh export 21.27 kWh total 22.05 kWh cost 519.41 p import 761.4 p export -304.21 p carbon 0.0 kg

Today:

Change from £1.82 to £3.52 - again energy import value remains constant.
Since midnight, my Smart Meter (read directly using Hildebrand Glow) shows import of 17.09kWh at off-peak (£1.19) and 0.09kWh at peak (£0.02) with a standing charge of 62p so the actual cost is £1.83 so the original £1.82 reported at 09:00 was the correct figure showing actual electricity cost and I've absolutely no idea where the additional £1.70 came from?

2024-11-26 08:50:04.716560 INFO pred_bat: Today's energy import 16.99 kWh export 0.04 kWh total 16.95 kWh cost 182.69 p import 120.9 p export -0.44 p carbon 0.0 kg
2024-11-26 08:55:05.260553 INFO pred_bat: Today's energy import 17.0 kWh export 0.05 kWh total 16.95 kWh cost 182.75 p import 121.03 p export -0.5 p carbon 0.0 kg
2024-11-26 09:00:05.057403 INFO pred_bat: Today's energy import 17.0 kWh export 0.05 kWh total 16.95 kWh cost 182.79 p import 121.11 p export -0.54 p carbon 0.0 kg
2024-11-26 09:05:05.018871 INFO pred_bat: Today's energy import 17.01 kWh export 0.05 kWh total 16.95 kWh cost 352.69 p import 291.02 p export -0.55 p carbon 0.0 kg
2024-11-26 09:10:04.790311 INFO pred_bat: Today's energy import 17.01 kWh export 0.05 kWh total 16.96 kWh cost 352.77 p import 291.12 p export -0.58 p carbon 0.0 kg
2024-11-26 09:15:04.738289 INFO pred_bat: Today's energy import 17.01 kWh export 0.06 kWh total 16.95 kWh cost 352.73 p import 291.18 p export -0.67 p carbon 0.0 kg
2024-11-26 09:20:04.767144 INFO pred_bat: Today's energy import 17.01 kWh export 0.06 kWh total 16.95 kWh cost 352.69 p import 291.18 p export -0.71 p carbon 0.0 kg

I assume I'm missing something obvious or have something misconfigured somewhere but despite looking at this many times over the last few months it seems mostly random and I cannot figure out why the daily costs are so far out.

@cyberkryten
Copy link
Author

Here's the entire appdaemon.log file from 09:00 to 09:15 this morning as I assume there answer will be in here somewhere but I've looked through and I can't figure out how the cost figure was reached

PredBad Log 26Nov24.txt

@cyberkryten
Copy link
Author

Maybe it isn't quite as random as I thought, same time as yesterday (16:20) and the import cost jumped, yesterday £5.03 to £7.61 and today £5.33 to £8.08

2024-11-26 16:00:04.901361 INFO pred_bat: Today's energy import 36.66 kWh export 8.7 kWh total 27.95 kWh cost 475.02 p import 526.91 p export -114.12 p carbon 0.0 kg
2024-11-26 16:05:04.764680 INFO pred_bat: Today's energy import 36.9 kWh export 8.9 kWh total 28.0 kWh cost 476.13 p import 533.28 p export -119.37 p carbon 0.0 kg
2024-11-26 16:10:05.078413 INFO pred_bat: Today's energy import 36.9 kWh export 9.19 kWh total 27.71 kWh cost 468.66 p import 533.28 p export -126.85 p carbon 0.0 kg
2024-11-26 16:15:05.401415 INFO pred_bat: Today's energy import 36.9 kWh export 9.47 kWh total 27.43 kWh cost 461.17 p import 533.28 p export -134.34 p carbon 0.0 kg
2024-11-26 16:20:05.110012 INFO pred_bat: Today's energy import 36.9 kWh export 9.76 kWh total 27.15 kWh cost 729.13 p import 808.64 p export -141.73 p carbon 0.0 kg
2024-11-26 16:25:05.073130 INFO pred_bat: Today's energy import 36.9 kWh export 10.03 kWh total 26.87 kWh cost 721.92 p import 808.64 p export -148.94 p carbon 0.0 kg

Cost in p/kWh changes massively around these times too:

HA Predbat Cost per kWh 26Nov24 1638

Trying to pick my way through the code, it seems there's three LOG outputs from the today_cost function:

2024-11-26 16:15:05.343675 INFO pred_bat: Battery level now 26.19 -1hr 19.79 midnight 18.04 battery value change hour 48.11 day 61.27 rate_forward 7.52
2024-11-26 16:15:05.344767 INFO pred_bat: Hour energy 6.92 import 7.69 export 0.77 car 0.0 load 1.25 cost 41.46 import 61.68 export -20.21 car 0.0 carbon 0.0 kG
2024-11-26 16:15:05.401415 INFO pred_bat: Today's energy import 36.9 kWh export 9.47 kWh total 27.43 kWh cost 461.17 p import 533.28 p export -134.34 p carbon 0.0 kg
2024-11-26 16:20:05.051045 INFO pred_bat: Battery level now 25.61 -1hr 20.66 midnight 18.04 battery value change hour 37.21 day 56.91 rate_forward 7.52
2024-11-26 16:20:05.052176 INFO pred_bat: Hour energy 5.81 import 6.87 export 1.05 car 0.0 load 1.38 cost 151.06 import 178.66 export -27.6 car 0.0 carbon 0.0 kG
2024-11-26 16:20:05.110012 INFO pred_bat: Today's energy import 36.9 kWh export 9.76 kWh total 27.15 kWh cost 729.13 p import 808.64 p export -141.73 p carbon 0.0 kg
2024-11-26 16:25:05.013939 INFO pred_bat: Battery level now 25.32 -1hr 21.24 midnight 18.04 battery value change hour 30.67 day 54.73 rate_forward 7.52
2024-11-26 16:25:05.015029 INFO pred_bat: Hour energy 4.73 import 6.06 export 1.33 car 0.0 load 1.55 cost 122.75 import 157.56 export -34.81 car 0.0 carbon 0.0 kG
2024-11-26 16:25:05.073130 INFO pred_bat: Today's energy import 36.9 kWh export 10.03 kWh total 26.87 kWh cost 721.92 p import 808.64 p export -148.94 p carbon 0.0 kg

I can't see anything really wrong in the code so I've added some more logging to grab the values as it cycles through each minute's data to calculate the values, will update when it next hits the issue.

@cyberkryten
Copy link
Author

Got another one, with the extra logging enabled which is the following to output the minute, import, load, rate and cost for every individual minute in the previous hour:

        for minute_back in range(60):                                                 
            minute = self.minutes_now - minute_back
            energy_import = self.get_from_incrementing(import_today, minute_back)
            load_energy = self.get_from_incrementing(load_today, minute_back)
                        
            self.log(   
                "MJI minute {} energy_import {} load_energy {} rate_import {} hour_cost_import {} ".format(
                    self.dp2(minute),
                    self.dp2(energy_import),
                    self.dp2(load_energy),
                    self.dp2(self.rate_import[minute]),
                    self.dp2(hour_cost_import),
                )
            )     
                  
            if car_today:
                energy_car = self.get_from_incrementing(car_today, minute_back)
            else:               
                energy_car = 0           
                          
            if export_today:
                energy_export = self.get_from_incrementing(export_today, minute_back)
            else:       
                energy_export = 0

So, during the run at 21:30 Predbat recorded the rate for all minutes from 1231 (20:31) to 1290 (21:31) as 7 pence:

2024-11-26 21:25:05.049247 INFO pred_bat: Hour energy 6.21 import 6.21 export 0.0 car 0.0 load 0.59 cost 43.5 import 43.5 export -0.0 car 0.0 carbon 0.0 kG
2024-11-26 21:25:05.109176 INFO pred_bat: Today's energy import 56.73 kWh export 18.47 kWh total 38.26 kWh cost 642.85 p import 949.52 p export -368.9 p carbon 0.0 kg
2024-11-26 21:30:05.037759 INFO pred_bat: Battery level now 17.17 -1hr 13.39 midnight 18.04 battery value change hour 28.41 day -6.54 rate_forward 7.52
2024-11-26 21:30:05.038741 INFO pred_bat: MJI minute 1290 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 0 
2024-11-26 21:30:05.039596 INFO pred_bat: MJI minute 1289 energy_import 0.15 load_energy 0.03 rate_import 7.0 hour_cost_import 1.08 
2024-11-26 21:30:05.040448 INFO pred_bat: MJI minute 1288 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 2.14 
2024-11-26 21:30:05.041289 INFO pred_bat: MJI minute 1287 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 3.22 
2024-11-26 21:30:05.042358 INFO pred_bat: MJI minute 1286 energy_import 0.16 load_energy 0.01 rate_import 7.0 hour_cost_import 4.34 
2024-11-26 21:30:05.043280 INFO pred_bat: MJI minute 1285 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 5.45 
2024-11-26 21:30:05.044124 INFO pred_bat: MJI minute 1284 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 6.55 
2024-11-26 21:30:05.044974 INFO pred_bat: MJI minute 1283 energy_import 0.16 load_energy 0.03 rate_import 7.0 hour_cost_import 7.65 
2024-11-26 21:30:05.045817 INFO pred_bat: MJI minute 1282 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 8.74 
2024-11-26 21:30:05.046659 INFO pred_bat: MJI minute 1281 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 9.87 
2024-11-26 21:30:05.047480 INFO pred_bat: MJI minute 1280 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 10.97 
2024-11-26 21:30:05.048348 INFO pred_bat: MJI minute 1279 energy_import 0.16 load_energy 0.03 rate_import 7.0 hour_cost_import 12.07 
2024-11-26 21:30:05.049173 INFO pred_bat: MJI minute 1278 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 13.16 
2024-11-26 21:30:05.049994 INFO pred_bat: MJI minute 1277 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 14.26 
2024-11-26 21:30:05.050821 INFO pred_bat: MJI minute 1276 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 15.34 
2024-11-26 21:30:05.051630 INFO pred_bat: MJI minute 1275 energy_import 0.15 load_energy 0.02 rate_import 7.0 hour_cost_import 16.46 
2024-11-26 21:30:05.052448 INFO pred_bat: MJI minute 1274 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 17.53 
2024-11-26 21:30:05.053278 INFO pred_bat: MJI minute 1273 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 18.63 
2024-11-26 21:30:05.054097 INFO pred_bat: MJI minute 1272 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 19.73 
2024-11-26 21:30:05.054916 INFO pred_bat: MJI minute 1271 energy_import 0.15 load_energy 0.03 rate_import 7.0 hour_cost_import 20.83 
2024-11-26 21:30:05.055742 INFO pred_bat: MJI minute 1270 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 21.91 
2024-11-26 21:30:05.056559 INFO pred_bat: MJI minute 1269 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 23.01 
2024-11-26 21:30:05.057692 INFO pred_bat: MJI minute 1268 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 24.13 
2024-11-26 21:30:05.058532 INFO pred_bat: MJI minute 1267 energy_import 0.16 load_energy 0.03 rate_import 7.0 hour_cost_import 25.21 
2024-11-26 21:30:05.059368 INFO pred_bat: MJI minute 1266 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 26.34 
2024-11-26 21:30:05.060249 INFO pred_bat: MJI minute 1265 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 27.45 
2024-11-26 21:30:05.061102 INFO pred_bat: MJI minute 1264 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 28.53 
2024-11-26 21:30:05.061948 INFO pred_bat: MJI minute 1263 energy_import 0.15 load_energy 0.04 rate_import 7.0 hour_cost_import 29.65 
2024-11-26 21:30:05.062771 INFO pred_bat: MJI minute 1262 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 30.74 
2024-11-26 21:30:05.063589 INFO pred_bat: MJI minute 1261 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 31.87 
2024-11-26 21:30:05.064437 INFO pred_bat: MJI minute 1260 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 32.98 
2024-11-26 21:30:05.065332 INFO pred_bat: MJI minute 1259 energy_import 0.15 load_energy 0.01 rate_import 7.0 hour_cost_import 34.07 
2024-11-26 21:30:05.066169 INFO pred_bat: MJI minute 1258 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 35.11 
2024-11-26 21:30:05.066993 INFO pred_bat: MJI minute 1257 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 36.17 
2024-11-26 21:30:05.067830 INFO pred_bat: MJI minute 1256 energy_import 0.03 load_energy 0.02 rate_import 7.0 hour_cost_import 37.25 
2024-11-26 21:30:05.068643 INFO pred_bat: MJI minute 1255 energy_import 0.0 load_energy 0.01 rate_import 7.0 hour_cost_import 37.43 
2024-11-26 21:30:05.069455 INFO pred_bat: MJI minute 1254 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.45 
2024-11-26 21:30:05.070273 INFO pred_bat: MJI minute 1253 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.46 
2024-11-26 21:30:05.071096 INFO pred_bat: MJI minute 1252 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.48 
2024-11-26 21:30:05.072013 INFO pred_bat: MJI minute 1251 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.49 
2024-11-26 21:30:05.072855 INFO pred_bat: MJI minute 1250 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.49 
2024-11-26 21:30:05.073670 INFO pred_bat: MJI minute 1249 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.49 
2024-11-26 21:30:05.074479 INFO pred_bat: MJI minute 1248 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.5 
2024-11-26 21:30:05.075310 INFO pred_bat: MJI minute 1247 energy_import 0.0 load_energy 0.01 rate_import 7.0 hour_cost_import 37.5 
2024-11-26 21:30:05.076156 INFO pred_bat: MJI minute 1246 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.5 
2024-11-26 21:30:05.077022 INFO pred_bat: MJI minute 1245 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.5 
2024-11-26 21:30:05.077853 INFO pred_bat: MJI minute 1244 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.5 
2024-11-26 21:30:05.078667 INFO pred_bat: MJI minute 1243 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.5 
2024-11-26 21:30:05.079467 INFO pred_bat: MJI minute 1242 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.5 
2024-11-26 21:30:05.080295 INFO pred_bat: MJI minute 1241 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.5 
2024-11-26 21:30:05.081117 INFO pred_bat: MJI minute 1240 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.51 
2024-11-26 21:30:05.081963 INFO pred_bat: MJI minute 1239 energy_import 0.0 load_energy 0.01 rate_import 7.0 hour_cost_import 37.51 
2024-11-26 21:30:05.082786 INFO pred_bat: MJI minute 1238 energy_import 0.0 load_energy 0.02 rate_import 7.0 hour_cost_import 37.51 
2024-11-26 21:30:05.083587 INFO pred_bat: MJI minute 1237 energy_import 0.0 load_energy 0.01 rate_import 7.0 hour_cost_import 37.51 
2024-11-26 21:30:05.084411 INFO pred_bat: MJI minute 1236 energy_import 0.12 load_energy 0.0 rate_import 7.0 hour_cost_import 37.52 
2024-11-26 21:30:05.085240 INFO pred_bat: MJI minute 1235 energy_import 0.15 load_energy 0.01 rate_import 7.0 hour_cost_import 38.34 
2024-11-26 21:30:05.086168 INFO pred_bat: MJI minute 1234 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 39.42 
2024-11-26 21:30:05.087443 INFO pred_bat: MJI minute 1233 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 40.48 
2024-11-26 21:30:05.088318 INFO pred_bat: MJI minute 1232 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 41.55 
2024-11-26 21:30:05.089170 INFO pred_bat: MJI minute 1231 energy_import 0.15 load_energy 0.01 rate_import 7.0 hour_cost_import 42.6 
2024-11-26 21:30:05.090048 INFO pred_bat: Hour energy 6.23 import 6.23 export 0.0 car 0.0 load 0.62 cost 43.64 import 43.64 export -0.0 car 0.0 carbon 0.0 kG
2024-11-26 21:30:05.151899 INFO pred_bat: Today's energy import 57.51 kWh export 18.47 kWh total 39.04 kWh cost 648.29 p import 954.97 p export -368.9 p carbon 0.0 kg

However, in the 22:05 run, it now shows some of those same historic minutes as having a price of 26p - this is 'in the past' and so should be totally unchanged.

My car was plugged in at 19:23 and Intelligent Dispatching started at 19:24 and remained on the whole time with the actual price being 7 pence

Something has clearly overwritten the values in between the 22:00 and 22:05 runs which has then totally messed up the cost calculation.

2024-11-26 22:00:05.197766 INFO pred_bat: Hour energy 9.33 import 9.33 export 0.0 car 0.0 load 0.36 cost 65.33 import 65.33 export 0.0 car 0.0 carbon 0.0 kG
2024-11-26 22:00:05.262357 INFO pred_bat: Today's energy import 62.13 kWh export 18.47 kWh total 43.66 kWh cost 680.64 p import 987.32 p export -368.9 p carbon 0.0 kg
2024-11-26 22:05:05.057322 INFO pred_bat: Battery level now 21.53 -1hr 14.84 midnight 18.04 battery value change hour 50.29 day 26.23 rate_forward 7.52
2024-11-26 22:05:05.058262 INFO pred_bat: MJI minute 1325 energy_import 0.15 load_energy 0.01 rate_import 7.0 hour_cost_import 0 
2024-11-26 22:05:05.059128 INFO pred_bat: MJI minute 1324 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 1.07 
2024-11-26 22:05:05.060057 INFO pred_bat: MJI minute 1323 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 2.13 
2024-11-26 22:05:05.060907 INFO pred_bat: MJI minute 1322 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 3.23 
2024-11-26 22:05:05.061992 INFO pred_bat: MJI minute 1321 energy_import 0.16 load_energy 0.01 rate_import 7.0 hour_cost_import 4.28 
2024-11-26 22:05:05.062850 INFO pred_bat: MJI minute 1320 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 5.37 
2024-11-26 22:05:05.063673 INFO pred_bat: MJI minute 1319 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 6.4 
2024-11-26 22:05:05.064523 INFO pred_bat: MJI minute 1318 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 7.46 
2024-11-26 22:05:05.065382 INFO pred_bat: MJI minute 1317 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 8.53 
2024-11-26 22:05:05.066208 INFO pred_bat: MJI minute 1316 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 9.57 
2024-11-26 22:05:05.067033 INFO pred_bat: MJI minute 1315 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 10.65 
2024-11-26 22:05:05.067860 INFO pred_bat: MJI minute 1314 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 11.73 
2024-11-26 22:05:05.068678 INFO pred_bat: MJI minute 1313 energy_import 0.15 load_energy 0.01 rate_import 7.0 hour_cost_import 12.76 
2024-11-26 22:05:05.069490 INFO pred_bat: MJI minute 1312 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 13.83 
2024-11-26 22:05:05.070310 INFO pred_bat: MJI minute 1311 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 14.89 
2024-11-26 22:05:05.071141 INFO pred_bat: MJI minute 1310 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 15.95 
2024-11-26 22:05:05.071963 INFO pred_bat: MJI minute 1309 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 17.0 
2024-11-26 22:05:05.072780 INFO pred_bat: MJI minute 1308 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 18.05 
2024-11-26 22:05:05.073587 INFO pred_bat: MJI minute 1307 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 19.1 
2024-11-26 22:05:05.074440 INFO pred_bat: MJI minute 1306 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 20.18 
2024-11-26 22:05:05.075256 INFO pred_bat: MJI minute 1305 energy_import 0.16 load_energy 0.01 rate_import 7.0 hour_cost_import 21.22 
2024-11-26 22:05:05.076200 INFO pred_bat: MJI minute 1304 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 22.31 
2024-11-26 22:05:05.077036 INFO pred_bat: MJI minute 1303 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 23.35 
2024-11-26 22:05:05.077858 INFO pred_bat: MJI minute 1302 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 24.42 
2024-11-26 22:05:05.078672 INFO pred_bat: MJI minute 1301 energy_import 0.16 load_energy 0.03 rate_import 7.0 hour_cost_import 25.48 
2024-11-26 22:05:05.079494 INFO pred_bat: MJI minute 1300 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 26.59 
2024-11-26 22:05:05.080322 INFO pred_bat: MJI minute 1299 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 27.71 
2024-11-26 22:05:05.081181 INFO pred_bat: MJI minute 1298 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 28.81 
2024-11-26 22:05:05.082005 INFO pred_bat: MJI minute 1297 energy_import 0.16 load_energy 0.03 rate_import 7.0 hour_cost_import 29.91 
2024-11-26 22:05:05.082832 INFO pred_bat: MJI minute 1296 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 31.02 
2024-11-26 22:05:05.083639 INFO pred_bat: MJI minute 1295 energy_import 0.17 load_energy 0.01 rate_import 7.0 hour_cost_import 32.14 
2024-11-26 22:05:05.084447 INFO pred_bat: MJI minute 1294 energy_import 0.17 load_energy 0.01 rate_import 7.0 hour_cost_import 33.31 
2024-11-26 22:05:05.085285 INFO pred_bat: MJI minute 1293 energy_import 0.15 load_energy 0.02 rate_import 7.0 hour_cost_import 34.48 
2024-11-26 22:05:05.086108 INFO pred_bat: MJI minute 1292 energy_import 0.16 load_energy 0.0 rate_import 7.0 hour_cost_import 35.54 
2024-11-26 22:05:05.086922 INFO pred_bat: MJI minute 1291 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 36.67 
2024-11-26 22:05:05.087732 INFO pred_bat: MJI minute 1290 energy_import 0.15 load_energy 0.0 rate_import 7.0 hour_cost_import 37.72 
2024-11-26 22:05:05.088541 INFO pred_bat: MJI minute 1289 energy_import 0.15 load_energy 0.03 rate_import 26.02 hour_cost_import 38.8 
2024-11-26 22:05:05.089348 INFO pred_bat: MJI minute 1288 energy_import 0.15 load_energy 0.0 rate_import 26.02 hour_cost_import 42.75 
2024-11-26 22:05:05.090162 INFO pred_bat: MJI minute 1287 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 46.76 
2024-11-26 22:05:05.091053 INFO pred_bat: MJI minute 1286 energy_import 0.16 load_energy 0.01 rate_import 26.02 hour_cost_import 50.92 
2024-11-26 22:05:05.091880 INFO pred_bat: MJI minute 1285 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 55.03 
2024-11-26 22:05:05.092724 INFO pred_bat: MJI minute 1284 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 59.12 
2024-11-26 22:05:05.093540 INFO pred_bat: MJI minute 1283 energy_import 0.16 load_energy 0.03 rate_import 26.02 hour_cost_import 63.23 
2024-11-26 22:05:05.094348 INFO pred_bat: MJI minute 1282 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 67.28 
2024-11-26 22:05:05.095168 INFO pred_bat: MJI minute 1281 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 71.47 
2024-11-26 22:05:05.096023 INFO pred_bat: MJI minute 1280 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 75.56 
2024-11-26 22:05:05.096850 INFO pred_bat: MJI minute 1279 energy_import 0.16 load_energy 0.03 rate_import 26.02 hour_cost_import 79.64 
2024-11-26 22:05:05.097701 INFO pred_bat: MJI minute 1278 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 83.7 
2024-11-26 22:05:05.098515 INFO pred_bat: MJI minute 1277 energy_import 0.15 load_energy 0.0 rate_import 26.02 hour_cost_import 87.79 
2024-11-26 22:05:05.099328 INFO pred_bat: MJI minute 1276 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 91.79 
2024-11-26 22:05:05.100146 INFO pred_bat: MJI minute 1275 energy_import 0.15 load_energy 0.02 rate_import 26.02 hour_cost_import 95.96 
2024-11-26 22:05:05.100973 INFO pred_bat: MJI minute 1274 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 99.94 
2024-11-26 22:05:05.101808 INFO pred_bat: MJI minute 1273 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 104.02 
2024-11-26 22:05:05.102607 INFO pred_bat: MJI minute 1272 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 108.13 
2024-11-26 22:05:05.103412 INFO pred_bat: MJI minute 1271 energy_import 0.15 load_energy 0.03 rate_import 26.02 hour_cost_import 112.22 
2024-11-26 22:05:05.104233 INFO pred_bat: MJI minute 1270 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 116.22 
2024-11-26 22:05:05.105134 INFO pred_bat: MJI minute 1269 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 120.31 
2024-11-26 22:05:05.105976 INFO pred_bat: MJI minute 1268 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 124.47 
2024-11-26 22:05:05.106809 INFO pred_bat: MJI minute 1267 energy_import 0.16 load_energy 0.03 rate_import 26.02 hour_cost_import 128.5 
2024-11-26 22:05:05.107636 INFO pred_bat: MJI minute 1266 energy_import 0.16 load_energy 0.0 rate_import 26.02 hour_cost_import 132.69 
2024-11-26 22:05:05.108510 INFO pred_bat: Hour energy 9.31 import 9.31 export 0.0 car 0.0 load 0.35 cost 136.8 import 136.8 export 0.0 car 0.0 carbon 0.0 kG
2024-11-26 22:05:05.166893 INFO pred_bat: Today's energy import 62.9 kWh export 18.47 kWh total 44.42 kWh cost 804.57 p import 1111.24 p export -368.9 p carbon 0.0 kg

HA Predbat Cost with Current Rate

If anyone can point me where to start looking to find how those rates are getting changed, it'll save me a load of digging as there's a lot more .py files with rate_import in than with cost_import!

@cyberkryten
Copy link
Author

Happened again, and I can see that the 9am scan today dropped out a previous 'smart-charge' slot from IOG which ran from 6am to 8am:

2024-11-27 08:55:04.629302 INFO pred_bat: Car 0 using Octopus Intelligent, not charging is planned
2024-11-27 08:55:04.640776 INFO pred_bat: Octopus Intelligent slot at 11-25 23:30:00-11-26 00:00:00 assumed price 7.0 amount 2.65 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 08:55:04.642237 INFO pred_bat: Octopus Intelligent slot at 11-25 23:00:00-11-25 23:30:00 assumed price 7.0 amount 0.09 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 08:55:04.643518 INFO pred_bat: Octopus Intelligent slot at 11-26 19:00:00-11-26 19:30:00 assumed price 7.0 amount 1.02 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 08:55:04.644707 INFO pred_bat: Octopus Intelligent slot at 11-26 20:00:00-11-26 20:30:00 assumed price 7.0 amount 2.21 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 08:55:04.645525 INFO pred_bat: Octopus Intelligent slot at 11-26 19:30:00-11-26 20:00:00 assumed price 7.0 amount 3.26 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 08:55:04.646811 INFO pred_bat: Octopus Intelligent slot at 11-26 23:00:00-11-26 23:30:00 assumed price 7.0 amount 0.11 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 08:55:04.647967 INFO pred_bat: Octopus Intelligent slot at 11-26 22:30:00-11-26 23:00:00 assumed price 7.0 amount 0.05 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 08:55:04.649245 INFO pred_bat: Octopus Intelligent slot at 11-26 22:00:00-11-26 22:30:00 assumed price 7.0 amount 0.05 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 08:55:04.650519 INFO pred_bat: Octopus Intelligent slot at 11-26 23:30:00-11-27 00:00:00 assumed price 7.0 amount 1.05 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 08:55:04.651463 INFO pred_bat: Octopus Intelligent slot at 11-27 06:00:00-11-27 08:00:00 assumed price 7.0 amount 13.86 kWh location None source smart-charge octopus_slot_low_rate True
2024-11-27 08:55:04.810227 INFO pred_bat: Car 0 on Octopus Intelligent, no active plan

2024-11-27 09:00:04.673595 INFO pred_bat: Car 0 using Octopus Intelligent, not charging is planned
2024-11-27 09:00:04.683990 INFO pred_bat: Octopus Intelligent slot at 11-25 23:30:00-11-26 00:00:00 assumed price 7.0 amount 2.65 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 09:00:04.684857 INFO pred_bat: Octopus Intelligent slot at 11-25 23:00:00-11-25 23:30:00 assumed price 7.0 amount 0.09 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 09:00:04.685689 INFO pred_bat: Octopus Intelligent slot at 11-26 19:00:00-11-26 19:30:00 assumed price 7.0 amount 1.02 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 09:00:04.686502 INFO pred_bat: Octopus Intelligent slot at 11-26 20:00:00-11-26 20:30:00 assumed price 7.0 amount 2.21 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 09:00:04.688012 INFO pred_bat: Octopus Intelligent slot at 11-26 19:30:00-11-26 20:00:00 assumed price 7.0 amount 3.26 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 09:00:04.689319 INFO pred_bat: Octopus Intelligent slot at 11-26 23:00:00-11-26 23:30:00 assumed price 7.0 amount 0.11 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 09:00:04.690565 INFO pred_bat: Octopus Intelligent slot at 11-26 22:30:00-11-26 23:00:00 assumed price 7.0 amount 0.05 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 09:00:04.691812 INFO pred_bat: Octopus Intelligent slot at 11-26 22:00:00-11-26 22:30:00 assumed price 7.0 amount 0.05 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 09:00:04.693210 INFO pred_bat: Octopus Intelligent slot at 11-26 23:30:00-11-27 00:00:00 assumed price 7.0 amount 1.05 kWh location AT_HOME source None octopus_slot_low_rate True
2024-11-27 09:00:04.854426 INFO pred_bat: Car 0 on Octopus Intelligent, no active plan

That makes sense from an Octopus point of view, there's no need to maintain previous slots once the time they were active has ended (though I'm not sure why the source 'None' ones persist for a day or two but the source 'smart-charge' do not).

In any case, it doesn't seem unrealistic for that to be happening as they've got to stop being advertised at some point.

So, the issue is that Predbat is retrospectively recalculating previous usage, which is incorrect because those transient low-rate slots are not longer being returned by the Octopus integration.

@cyberkryten
Copy link
Author

Don't know how to solve this but can't believe I'm the only one it is affecting.

From what I can tell, today_cost actually goes through every minute of today each time it runs to recalculate the costs (day_cost and day_cost_import) based on whatever data is has 'now':

        for minute in range(self.minutes_now):              

This means at 23:55 it will rerun the entire day's costs, despite having already calculated them (correctly) throughout the day.

I'm sure there's a reason (restarts?) but this means the actual costs calculated can only be accurate if Intelligent slots are maintained until the following day - any ad-hoc slots created during the day, if they aren't persisted until midnight in the Intelligent data will cause huge cost errors to be introduced. I don't know if this is a change in behaviour for IOG APIs - there's definitely a difference in how charge slots are displayed in the Octopus App now, so maybe it used to persist slots for long enough after the event for this recalculation to work.

At 16:15, Predbat recalculated the 13:00 charge slot incorrectly - I added debug into the loop I listed above - here's the results for the 16:10 and 16:15 runs:

2024-11-27 16:10:05.418455 INFO pred_bat: MJI2 minute 779 minute_back 190 energy 0.0 load_energy 0.01 day_energy 10.66 rate_import 26.02 day_cost_import 263.87 day_cost 211.35
2024-11-27 16:10:05.419373 INFO pred_bat: MJI2 minute 780 minute_back 189 energy 0.1 load_energy 0.02 day_energy 10.76 rate_import 7.0 day_cost_import 264.55 day_cost 212.03
2024-11-27 16:10:05.420291 INFO pred_bat: MJI2 minute 781 minute_back 188 energy 0.15 load_energy 0.0 day_energy 10.91 rate_import 7.0 day_cost_import 265.59 day_cost 213.06
2024-11-27 16:10:05.421183 INFO pred_bat: MJI2 minute 782 minute_back 187 energy 0.15 load_energy 0.0 day_energy 11.05 rate_import 7.0 day_cost_import 266.62 day_cost 214.1
2024-11-27 16:10:05.422072 INFO pred_bat: MJI2 minute 783 minute_back 186 energy 0.15 load_energy 0.0 day_energy 11.2 rate_import 7.0 day_cost_import 267.67 day_cost 215.15
2024-11-27 16:10:05.422966 INFO pred_bat: MJI2 minute 784 minute_back 185 energy 0.15 load_energy 0.0 day_energy 11.35 rate_import 7.0 day_cost_import 268.69 day_cost 216.17
2024-11-27 16:10:05.423858 INFO pred_bat: MJI2 minute 785 minute_back 184 energy 0.15 load_energy 0.0 day_energy 11.5 rate_import 7.0 day_cost_import 269.77 day_cost 217.24
2024-11-27 16:10:05.424762 INFO pred_bat: MJI2 minute 786 minute_back 183 energy 0.15 load_energy 0.0 day_energy 11.65 rate_import 7.0 day_cost_import 270.81 day_cost 218.29
2024-11-27 16:10:05.425632 INFO pred_bat: MJI2 minute 787 minute_back 182 energy 0.15 load_energy 0.0 day_energy 11.8 rate_import 7.0 day_cost_import 271.85 day_cost 219.33
2024-11-27 16:10:05.426598 INFO pred_bat: MJI2 minute 788 minute_back 181 energy 0.15 load_energy 0.0 day_energy 11.95 rate_import 7.0 day_cost_import 272.9 day_cost 220.38
2024-11-27 16:10:05.427529 INFO pred_bat: MJI2 minute 789 minute_back 180 energy 0.15 load_energy 0.0 day_energy 12.1 rate_import 7.0 day_cost_import 273.97 day_cost 221.44



2024-11-27 16:15:05.709403 INFO pred_bat: MJI2 minute 779 minute_back 195 energy 0.0 load_energy 0.01 day_energy 10.66 rate_import 26.02 day_cost_import 263.87 day_cost 211.3
2024-11-27 16:15:05.710345 INFO pred_bat: MJI2 minute 780 minute_back 194 energy 0.1 load_energy 0.02 day_energy 10.76 rate_import 26.02 day_cost_import 266.39 day_cost 213.86
2024-11-27 16:15:05.711274 INFO pred_bat: MJI2 minute 781 minute_back 193 energy 0.15 load_energy 0.0 day_energy 10.91 rate_import 26.02 day_cost_import 270.24 day_cost 217.71
2024-11-27 16:15:05.712191 INFO pred_bat: MJI2 minute 782 minute_back 192 energy 0.15 load_energy 0.0 day_energy 11.05 rate_import 26.02 day_cost_import 274.09 day_cost 221.56
2024-11-27 16:15:05.713166 INFO pred_bat: MJI2 minute 783 minute_back 191 energy 0.15 load_energy 0.0 day_energy 11.2 rate_import 26.02 day_cost_import 277.99 day_cost 225.47
2024-11-27 16:15:05.714075 INFO pred_bat: MJI2 minute 784 minute_back 190 energy 0.15 load_energy 0.0 day_energy 11.35 rate_import 26.02 day_cost_import 281.79 day_cost 229.27
2024-11-27 16:15:05.714994 INFO pred_bat: MJI2 minute 785 minute_back 189 energy 0.15 load_energy 0.0 day_energy 11.5 rate_import 26.02 day_cost_import 285.77 day_cost 233.25
2024-11-27 16:15:05.715911 INFO pred_bat: MJI2 minute 786 minute_back 188 energy 0.15 load_energy 0.0 day_energy 11.65 rate_import 26.02 day_cost_import 289.65 day_cost 237.12
2024-11-27 16:15:05.716828 INFO pred_bat: MJI2 minute 787 minute_back 187 energy 0.15 load_energy 0.0 day_energy 11.8 rate_import 26.02 day_cost_import 293.52 day_cost 241.0
2024-11-27 16:15:05.717845 INFO pred_bat: MJI2 minute 788 minute_back 186 energy 0.15 load_energy 0.0 day_energy 11.95 rate_import 26.02 day_cost_import 297.42 day_cost 244.9
2024-11-27 16:15:05.718828 INFO pred_bat: MJI2 minute 789 minute_back 185 energy 0.15 load_energy 0.0 day_energy 12.1 rate_import 26.02 day_cost_import 301.38 day_cost 248.86

So, the data was correct, and then 3 hours later, it recalculated the slot cost and got it wrong, adding £3 because IOG no longer reported the old slot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants