BottlecapDave / HomeAssistant-OctopusEnergy

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

Ability to pull previous consumption for X previous days #983

Closed th4rius closed 2 months ago

th4rius commented 2 months ago

Describe the feature

Talking to Octopus support almost every month due to export previous consumption sometimes doesn't come through in days. Sometimes also actual import consumption. It is frustrating as I have to manually inject these values to reflect the missing import export.

Expected behaviour

Pull data for X previous days and inject into DB.

Use Case

Octopus have no fix for this unfortunately. They say sometimes their system need to catch up and verify data from the 3rd parties before it is available to users.

Confirmation

BottlecapDave commented 2 months ago

Hello and sorry you're having issues. You can adjust the number of days the sensor looks back at when pulling through data if your meter consistently reports data late (e.g. always look at data 2 days behind).

There is also an existing action/service which allows you to refesh the statistics sensors linked to the previous consumption sensors from a given point in time. It can't load data into the history of the sensors themselves as none of the HA APIs seem to support this. This is not done automatically as data can be missing for a variety of reasons (e.g HA loses connection to OE servers) and doing so automatically could end up in pulling a large volume of data providing strain on OE servers and the users internet connection (which could be metered)

th4rius commented 2 months ago

That's great and thanks for the quick response. It has been 6 days now so will have to contact them again. Might be a silly question but where is this action/service located or how can I run it please? I couldn't find it anywhere.

th4rius commented 2 months ago

Also I see it is only for import and gas at the moment. Would it be possible to have it available for export consumption as well as all _cost entities?

BottlecapDave commented 2 months ago

The service/action can be run via an automation (not recommended) or via the developer tools.

It can be run against the export variants of the specified sensors and as stated will update both the consumption and cost variants of the related statistics sensors.

th4rius commented 2 months ago

Tried the offset and it kind of worked. But had to do one change for each missing day but at least it added them to the history so that's good. In terms of the action/service that did not work. In the notifications it said started/finished but not changed or added anything and tried both gas and electricity.

BottlecapDave commented 2 months ago

Tried the offset and it kind of worked. But had to do one change for each missing day but at least it added them to the history so that's good.

I assume by this you mean you updated the offset to be 5 (for example), let it update, then updated to 4, etc?

As mentioned, this configuration is more of a long term change for those whose meters are always behind. There is a proposition to change this behaviour so that the sensor will automatically shift. This won't add any days between the last successful pull of information and the latest available information.

In terms of the action/service that did not work. In the notifications it said started/finished but not changed or added anything and tried both gas and electricity.

Were you checking the entities themselves or the statistics sensors (the ones described in the energy dashboard setup docs)? If the former, as previously mentioned the service cannot update the history of the entities themselves as the last time I checked HA didn't properly support it (it appeared to initially work and then a negative spike occurred of the total data added appeared). I have it on my list to investigate again, but other things are higher up the list. If it was the latter, did you have any errors in your logs?

th4rius commented 2 months ago

That's correct.

Ah good thought on the proposition. Understandable it is not a priority. Bear in mind there are few scenarios such as consumers with multiple days missing and then when you phone them they load all of it in but maybe with gaps between days which also happened to me. So Mon nothing, Tue there was and Wed nothing etc. Would have to ignore the working days if you re-run after again I guess.

I was checking the entities so fair play. Not sure how the statistics would help me in this case to be honest. I think the offset will do it for now.

BottlecapDave commented 2 months ago

If you have multiple days missing, that is outside of the scope, design and functionality of the sensors. This is why the service exists for those edge case scenarios. Same as adding the integration for the first time with years worth of data available on OE servers.

The statistics sensors are built for the energy dashboard as they break the data down into hourly chunks. These sensors tmk can be used with other things like apex charts.

th4rius commented 2 months ago

Ok that's great. Thanks for your help.