Skip to content

Add support for V2 Energy Monitoring for S515D#1663

Open
ZeliardM wants to merge 3 commits intopython-kasa:masterfrom
ZeliardM:feature/new-device-s515d
Open

Add support for V2 Energy Monitoring for S515D#1663
ZeliardM wants to merge 3 commits intopython-kasa:masterfrom
ZeliardM:feature/new-device-s515d

Conversation

@ZeliardM
Copy link
Contributor

Add support for V2 Energy Monitoring for S515D Switch that does not have "get_current_power" but still has Energy Monitoring.

Copilot AI review requested due to automatic review settings February 28, 2026 04:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_power as an optional response key for Energy v2+ so update cycles don’t fail when it errors.
  • Harden energy module tests to handle get_current_power being 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
Copy link

codecov bot commented Feb 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.24%. Comparing base (be5ce08) to head (a9d8a66).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ZeliardM
Copy link
Contributor Author

@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.

@ZeliardM
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants