GadgetReactor / pyHS100

Python Library to control TPLink Switch (HS100 / HS110)
Other
409 stars 128 forks source link

calling is_dimmable queries device #164

Closed ljmerza closed 5 years ago

ljmerza commented 5 years ago

Many properties get a device attribute by calling self.is_dimmable which in return queries the device. I think device capabilities should be cached on init of device as they wouldn't change.

rytilahti commented 5 years ago

I agree with you here, the sysinfo should really be cached and only functionality that depend on the outside state changes (e.g., fetching the state, settings or alias) should explicitly refresh the cache. I want to get the pending #151 merged before doing this change though.

rytilahti commented 5 years ago

I think this can be closed now, as #151 implements a TTL-based caching. In normal usecase the is_dimmable is likely to be queried only during the initialization among other features, so these should now cause only a single request on the device. Please let us know if that works for you!