BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
572 stars 57 forks source link

Half hourly reporting #40

Closed reecebedding closed 2 years ago

reecebedding commented 2 years ago

Is it possible to have half hourly / hourly values displayed as half hourly values are available in the api? Not sure if this possible, but I currently only get the accumulated value at 4am each day.

Cheers

BottlecapDave commented 2 years ago

Hi there, sorry for the late response - Work life is busy at the moment.

When you say display, do you mean in the energy dashboard or separate sensors?

For the energy dashboard, no as HA currently only officially supports "live" data which is why we have the accumulations for the previous day. There is an issue which has uncovered a way of potentially porting stats historically, but there is currently no documentation (which makes me nervous about how stable it is) and I haven't had the time to investigate.

In terms if separate sensors, I'm not sure how useful this would be.

I can however look at exposing the breakdowns on the accumlation sensor as an attribute. That way you can create template sensors and then do what you need with the data?

reecebedding commented 2 years ago

No need to apologize.

Sorry, yes I meant the breakdown on the energy dashboard.

The officially supporting only live data makes sense as to why its not possible yet. I was curious as I could see the data from Octopus being in 30 minute intervals. If HA does support / document importing historic data, that would be nice to throw the previous days break down in.

gitothy commented 2 years ago

Thanks for taking the time to assist but I'm a little confused also. My understanding of the process:

  1. Octopus publish your daily usage in 30 minute intervals one day in arrears, as a bulk upload.
  2. When this integration imports this data it stores it under a sensor labelled '...Accumulative Consumption'.
  3. As HA doesn't document how to store energy usage dated in the past, these 48 entries from the previous day are summed and stored at the current point in time representing the previous day's usage.
  4. Provided the integration runs at the same time every day and Octopus publish the previous day's usage in advance on this, everything should be good.

Understanding this, do the sensor values and what's show in my Energy Dashboard reconcile? I can't make sense of it.

image

image

BottlecapDave commented 2 years ago

Yeah I can understand why your output is causing confusion.

Octopus publish your daily usage in 30 minute intervals one day in arrears, as a bulk upload.

Ideally this is what Octopus would do, however in testing and with previously raised issues, this is not what occurs in practice. There are days when Octopus part publishes the previous days worth of data, and then publishes the rest later on in the day. This is what looks like is happening in your instance, which results in the dashboard summing the partial total and actual total. I'm not sure why one of your days is going negative when the value is clearly positive. This might be a bug with HA.

I tried to combat the partial updates by waiting for there to be 48 entries available before updating the sensor. Unfortunately, some other users ended up never seeing their sensors update because there was missing data.

I'll add something to the list to see about making the entry threshold configurable before the sensors are updated. This way, users can reduce this threshold in instances where their meter might be missing half hour blocks.

gitothy commented 2 years ago

Cheers, I think I’ve got it now. I’d say that with these limitations considered you’ve implemented this in the best way. Truthfully though until retrospective data loads are possible there will always be issues esp. with such an inconsistent 3rd party.

I had a look and there are a number of CRs logged to add this functionality to load historical data. None of them seem to be getting off the ground. I’m guessing that something in the ability to retrospectively modify sensor data must break something architecturally. Would definitely cause issues for any feeds out of HA (e.g. to Influx).

There are some cowboy suggestions for doing your own SQL updates to the HA database but am sure you’ve seen these and discounted the approach as being too risky. E.g. https://community.home-assistant.io/t/remove-faulty-readings-from-energy-dashboard-history/335555

Will put my mind to it and let you know if I can think of another approach.

BottlecapDave commented 2 years ago

Closing this issue until a better solution from home assistant is possible.