Add support for V2 Energy Monitoring for S515D#1663
Add support for V2 Energy Monitoring for S515D#1663ZeliardM wants to merge 3 commits intopython-kasa:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds tolerance for SMART Energy v2 devices (notably S515D) that either omit get_current_power or return an error for it, while still supporting energy monitoring via other endpoints.
Changes:
- Treat
get_current_poweras an optional response key for Energy v2+ so update cycles don’t fail when it errors. - Harden energy module tests to handle
get_current_powerbeing missing or non-dict, and add a regression test for v2 fixtures. - Add an S515D SMART fixture and register/document the model in test fixture filters and supported-device docs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
kasa/smart/modules/energy.py |
Makes get_current_power optional for Energy v2+ to avoid failing updates on unsupported/erroring devices. |
tests/smart/modules/test_energy.py |
Updates existing tests for missing/non-dict get_current_power and adds a v2 regression test covering error responses. |
tests/fixtures/smart/S515D(US)_1.6_1.0.4.json |
Introduces an S515D SMART fixture (Energy Monitoring v2) without get_current_power. |
tests/device_fixtures.py |
Includes S515D in SMART switch/dimmer and emeter-capable model sets so it participates in relevant parametrized tests. |
SUPPORTED.md |
Documents S515D as supported with tested hw/fw. |
README.md |
Adds S515D to the tested wall-switch list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1663 +/- ##
==========================================
+ Coverage 93.22% 93.24% +0.02%
==========================================
Files 157 157
Lines 9815 9817 +2
Branches 1003 1004 +1
==========================================
+ Hits 9150 9154 +4
+ Misses 472 471 -1
+ Partials 193 192 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@rytilahti This should be good to go. Normally, I don't add other changes with a fixture but all of the energy tests went wild when this fixture was added because of the Energy Monitoring V2 handling we currently had in place and the differences in how this device operated. I'm not exactly positive that this will work. I'm going to have the guy from my plug-in pull it down and test it to make sure. |
|
It looks like for this device they moved current_power under get_energy_usage instead of it being its own get_current_power, I will go based on that assumption and have to make some additional changes here before this is ready too. |
Add support for V2 Energy Monitoring for S515D Switch that does not have "get_current_power" but still has Energy Monitoring.