HomeAssistant-OctopusEnergy icon indicating copy to clipboard operation
HomeAssistant-OctopusEnergy copied to clipboard

Show the last 10 days history for the next Saving Session period

Open BottlecapDave opened this issue 2 years ago • 3 comments

Discussed in https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/discussions/531

Originally posted by deltamelter November 15, 2023 Since the new saving sessions are looking back over 10 days to decide "normal" usage so that they know how much we "really" save, could you add an entity to show the history for the upcoming period over the previous 10 days?

We’ll look at your historical smart meter data leading up to a Session, and calculate what you usually use at that time of day, on average. If the Session is on a weekday, we’ll look at your half-hourly usage over the last 10 weekdays (excluding Saving Session days). If the Session is on a weekend, we’ll look at your half hourly usage over the last 4 weekend days. We then use these half-hourly averages as a benchmark – so you’ll earn points for every kilowatt hour you save compared to that number during your Session.

BottlecapDave avatar Nov 16 '23 06:11 BottlecapDave

Have you seen this app which does the above and estimates the octopoints received.

https://savingsessions.streamlit.app/

The project is also open sourced. Would you take pull requests for adding this functionality?

ghanel avatar Dec 05 '23 22:12 ghanel

I'm happy to take contributions. I'm currently in the process of reworking how API requests are made (as per https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/issues/597) so it might be best to hold fire until that's complete. I was thinking of looking at this "soon", but it could be a couple of months.

My current plan is

  1. Function which calculates the list of dates to retrieve consumption data for. This should take the target start/end of the saving session along with the collection of joined saving sessions and should return the 10 start/end dates that meet the target requirements. This should be fully unit tested.
  2. Function which takes a collection of consumption data and calculates the average consumption. This should be fully unit tested
  3. Sensor called `octopus_energy_{{ACCOUNT_ID}}_target_saving_session which updates the underlying data every 1 hour (TBC), using function 1 to retrieve current consumption via api client and then calculate and set the target consumption based on function 2.

The only question I have atm is if export meters are brought into the calculation if available.

BottlecapDave avatar Dec 06 '23 11:12 BottlecapDave

I've managed to find some time over the holiday to look into this. I'm just waiting for the next saving session to test it properly

BottlecapDave avatar Jan 01 '24 08:01 BottlecapDave