etheralm / libpurecool

Python library for dyson devices.
Other
67 stars 30 forks source link

FR: Cache device list retrieved from Dyson account at library startup #23

Open crowbarz opened 4 years ago

crowbarz commented 4 years ago

As Dyson's somewhat unreliable API servers are queried whenever this library is loaded (eg. at Home Assistant startup), their availability is effectively on the critical path of a successful server restart. (They aren't working for me right now: Cloudflare says the backend servers are currently unavailable. I am going to try again later but it got me thinking about how to ameliorate this situation.)

https://github.com/etheralm/libpurecool/issues/14#issuecomment-593083449 mentioned that a list of devices is downloaded via the Dyson API, then the library subsequently connects to devices locally via MQTT. Would it be possible to cache/save that list of devices locally, to be used when the Dyson API is not available? It would greatly reduce the need for Dyson's API servers to be available at library startup.

etheralm commented 4 years ago

Hey, thanks for the idea.

I've been thinking about adding some sort of cache for the dyson API calls for quite some time now. It should be trivial to add and will prevent a lot of the issues. I'll have a go at it when I can find some free time.

I'll keep this ticket open to track the progress.