Add support for V2 Energy Monitoring for S515D by ZeliardM · Pull Request #1663 · python-kasa/python-kasa

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.