Closed pdecat closed 10 months ago
I do not disagree as such, but one has to consider other use cases as well.
For instance, I just wait for the device to report some values as they are sleepy and actually reading the value from the device would need a lot of repetitions. Not falling back to a read ensures a fast return.
So "use_cache" could be updated to accept false, true, 0, 1, and 2 where "2" would indicate that it is ok to fallback to a normal read.
We need to be careful not to apply "tries" to the read from cache.
I am currently on vacation, so I will not be implementing this in the next few weeks, but I am open to a PR.
See v0.9.8!
Awesome, thanks @mdeweerd! :rocket:
When
attr_read
/attr_write
are invoked withuse_cache=True
, if the attribute is not in the cache, shouldn't an actual read happen to fill the cache?Currently, the actual read only happens if
use_cache
isFalse
: https://github.com/mdeweerd/zha-toolkit/blob/v0.9.7/custom_components/zha_toolkit/zcl_attr.py#L367I'd replace the
else:
by anif not use_cache or not success:
.WDYT?