BottlecapDave / HomeAssistant-OctopusEnergy

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

Incorrect API calls when backfilling Octopus Home Mini data #246

Closed adds68 closed 1 year ago

adds68 commented 1 year ago

Describe the bug

Hi, we're seeing some 400 errors from the Octopus Home Mini API, when we've looked into this, we have noticed it's customers who have the HA plugin enabled.

To Reproduce

The Home Mini goes offline and then the HA plugin then tries to backfill the data at minutely intervals.

The Home mini stays offline for more than a week, however HA is still trying to backfill the data in minutely intervals, which is not a valid request causing a 400 error.

Expected behavior

When calling the API, we have these rules in place for time ranges:

Any time range one day or greater can only be a minumum interval of minutes or hours
Any time greater than one week must be in a minumum interval of hours

So if no data has been retrieved from the Home mini api in over a week, the HA plugin should begin to request this data at an hourly resolution.

I suspect the code that needs updating is:

https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/blob/950a47042596bffdd53d02b1a47d87c35160d919/custom_components/octopus_energy/binary_sensor.py#L33 ?

Home Assistant Version

N/A

Integration Version

N/A

Fresh Install?

N/A

Home Assistant Logs

N/A

BottlecapDave commented 1 year ago

Hello and thanks for raising the issue. I'll try and find some time over the weekend to limit the volume of data being backdated.

I hope it hasn't caused you too many issues and thanks for helping to provide useful APIs for us.

adds68 commented 1 year ago

Hey @BottlecapDave, not a problem, there is no immediate rush, we only have a low priorty alarm on this, but it took us some time to figure out where they were originating from.

Thanks for responding so quickly, let me know if i can assist in anyway.

BottlecapDave commented 1 year ago

This has been restricted as part of v7.2.0. It might take a while for you to see results as people upgrade their versions.

adds68 commented 1 year ago

Amazing, thanks @BottlecapDave