Optimize I/O access#59
Optimize I/O access#59rytilahti merged 2 commits intopython-kasa:masterpython-kasa/python-kasa:masterfrom rytilahti:refactor/request_combinerytilahti/python-kasa:refactor/request_combineCopy head branch name to clipboard
Conversation
|
This is the last showstopper I wanted to tackle before making a release. It may not be be prettiest code you have ever seen, but I think it's the time to get the first (pre-)release out and let the downstream users to enjoy the improvements, at last.. edit: I think there is one more thing that should be done pre-release: getting rid of implicit |
the backend lib will after python-kasa/python-kasa#59 fetch all the necessary wanted in a single update cycle.
|
I'm in favor of removing the automatic updates everywhere. I think it should be up to the user of the library to determine when its best to ask for information. |
A single update() will now fetch information from all interesting modules, including the current device state and the emeter information. In practice, this will allow dropping the number of I/O reqs per homeassistant update cycle to 1, which is paramount at least for bulbs which are very picky about sequential accesses. This can be further extend to other modules/methods, if needed. Currently fetched data: * sysinfo * realtime, today's and this months emeter stats New properties: * emeter_realtime: return the most recent emeter information, update()-version of get_emeter_realtime() * emeter_today: returning today's energy consumption * emeter_this_month: same for this month Other changes: * Accessing @requires_update properties will cause SmartDeviceException if the device has not ever been update()d * Fix __repr__ for devices that haven't been updated * Smartbulb uses now the state data from get_sysinfo instead of separately querying the bulb service * SmartStrip's state_information no longer lists onsince for separate plugs * The above mentioned properties are now printed out by cli * Simplify is_on handling for bulbs
…README.md instructions. fixes python-kasa#61
9c641a5 to
4faa24a
Compare
Codecov Report
@@ Coverage Diff @@
## master #59 +/- ##
==========================================
- Coverage 78.73% 76.27% -2.47%
==========================================
Files 7 7
Lines 790 826 +36
Branches 104 110 +6
==========================================
+ Hits 622 630 +8
- Misses 150 172 +22
- Partials 18 24 +6
Continue to review full report at Codecov.
|
|
I presume that we can merge this now (and fix any issues in future PRs). |
the backend lib will after python-kasa/python-kasa#59 fetch all the necessary wanted in a single update cycle.
the backend lib will after python-kasa/python-kasa#59 fetch all the necessary wanted in a single update cycle.
the backend lib will after python-kasa/python-kasa#59 fetch all the necessary wanted in a single update cycle.
the backend lib will after python-kasa/python-kasa#59 fetch all the necessary wanted in a single update cycle.
A single update() will now fetch information from all interesting modules,
including the current device state and the emeter information.
In practice, this will allow dropping the number of I/O reqs per homeassistant update cycle to 1,
which is paramount at least for bulbs which are very picky about sequential accesses.
This can be further extend to other modules/methods, if needed.
This will also remove the implicit
update()calls from device state changing methods such asset_brightness(). This allows executing multiple changes on a device without unnecessary I/O.Currently fetched data:
New properties:
Other changes:
Closes #53, closes #61.