python-miio
python-miio copied to clipboard
Implement embedding DeviceStatus containers
Adds DeviceStatus.embed(self, other: DeviceStatus) method that allows embedding separate DeviceStatus containers into a single one. This will copy over the switch, setting, and sensor descriptors to the container and prefixing their names with the name of the other class.
Internally, __getattribute__ is overridden to check if the property name contains ':' and if so, the attribute lookup is done in an embedded class named after the first part of the key.
This PR also converts roborock vacuum integration to expose cleaning summary and consumable statuses using this functionality.
@starkillerOG feel free to give this PR a try on your vacuum to see if the embedding works as expected! I haven't tested this as of yet as I don't have access to my vacuum at the moment.
Codecov Report
Merging #1526 (789b58b) into master (ff4e18f) will increase coverage by
0.15%. The diff coverage is76.92%.
@@ Coverage Diff @@
## master #1526 +/- ##
==========================================
+ Coverage 82.13% 82.29% +0.15%
==========================================
Files 145 145
Lines 14165 14195 +30
Branches 3416 3422 +6
==========================================
+ Hits 11635 11682 +47
+ Misses 2305 2286 -19
- Partials 225 227 +2
| Impacted Files | Coverage Δ | |
|---|---|---|
| miio/devicestatus.py | 88.23% <68.42%> (-5.71%) |
:arrow_down: |
| .../integrations/vacuum/roborock/tests/test_vacuum.py | 98.27% <100.00%> (+<0.01%) |
:arrow_up: |
| miio/integrations/vacuum/roborock/vacuum.py | 65.59% <100.00%> (+0.38%) |
:arrow_up: |
| ...o/integrations/vacuum/roborock/vacuumcontainers.py | 86.07% <0.00%> (+8.41%) |
:arrow_up: |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
@rytilahti I have tested this today. It works niceley, but the getattribute does not work. I made a fix in this PR: https://github.com/rytilahti/python-miio/pull/1542