PJCzx / homebridge-thermostat

Supports thermostat devices on HomeBridge Platform
Apache License 2.0
34 stars 71 forks source link

Cache for status #39

Closed mariusz2108 closed 5 years ago

mariusz2108 commented 5 years ago

Optional status caching. If cache is set than first status request is sent to server and result is saved to cache. Cache is valid for some time, during that time every status request is taken from cache. Cache is invalidated by any set operation.

phenotypic commented 5 years ago

Whilst I agree with your original issue, I don't think caching the status in the way you have implemented it in your branch is the cleanest approach, as I think it will bring instability for some people.

Wouldn't it be better to have one smaller central function as I suggested, and have that answer the requests from each of the get functions? I'm willing to work on a branch but won't be able to for a few days.

Best, Tom

mariusz2108 commented 5 years ago

As I said I’m not JS expert. This is just my proposal. I agree that it can be done better :) So I’m waiting for better solution.

phenotypic commented 5 years ago

@mariusz2108 After getting some help, I was able to make my own HTTP thermostat plugin here which solves this issue by caching polled data (taken in 1 request) and simply returning this to the user. It does this in a very efficient manner and functions perfectly for me. Hopefully you find this useful.