rcastberg / sure_petcare

Python library for accessing sure connect petflap
GNU General Public License v3.0
55 stars 15 forks source link

Compatibility with API changes for app version 2.0.5.54 #12

Closed therefromhere closed 5 years ago

therefromhere commented 5 years ago

Heads up, it looks like Sureflap changed their API sometime within the last week, to add support for multiple curfews in the current version of the app (2.0.5.54-9771d74), so there's now a list of curfews instead of a single lock/unlock time.

This has broken my integration ( https://github.com/therefromhere/sureflap_gcloud ), I think it's caused some issues with this library as well.

Incidentally, I was thinking about how we could detect or document these sorts of changes - one option would be adding asserts of the API return data structure, eg by using pydantic (though that would require Python >=3.6).

strix-technica commented 5 years ago

If you'd care to submit a pull request to fix the change in curfew format, that'd be great. I don't know when I'll get to it myself, otherwise.

Adding API change detection sounds like a good idea in principle, but also sounds like a fair bit of work. Sure don't change their API that often and I think this is the first time anything obvious in this API is broken.

Unfortunately, Sure expressed as unambiguous disinterest in supporting this API or providing any sort of API to end users on the grounds of infra load (even though I went to great lengths to mitigate and rate-limit such impact). They did not quite threaten me, but came close to. It's a pity, but also understandable.

therefromhere commented 5 years ago

Yep fair enough. I've made a start on defining a API parser/cache schema using pydantic here: https://github.com/therefromhere/sure_petcare/commit/a445ba2d73b155365a77e035a6617a28508c7575

therefromhere commented 5 years ago

Actually I don't think there's any changes needed for sure_petcare as a result of this, since the curfew times aren't touched directly.

Just in case anyone else hits a similar problem to me, the fix was just to make curfew a list of dicts instead of a single dict when setting it:

https://github.com/therefromhere/sureflap_gcloud/commit/305e5a16c48213232445f7d826259eacdef9a36f