Skip to content

Matter Energy: Fix powerConsumptionReport delta, rename energy parameter, and fix endpoint typo#3112

Open
sangheedotkim wants to merge 3 commits into
SmartThingsCommunity:mainfrom
sangheedotkim:dev/matter/energy
Open

Matter Energy: Fix powerConsumptionReport delta, rename energy parameter, and fix endpoint typo#3112
sangheedotkim wants to merge 3 commits into
SmartThingsCommunity:mainfrom
sangheedotkim:dev/matter/energy

Conversation

@sangheedotkim

@sangheedotkim sangheedotkim commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Description of Change

Summary

This PR contains three small fixes for the Matter Energy driver:

  1. Fix powerConsumptionReport delta calculation: The energy delta was incorrectly reading from the "main" component instead of the actual component (importedEnergy/exportedEnergy), causing incorrect deltaEnergy values (always 0 for non-main components).

  2. Rename energy parameter: latest_total_imported_energy_whlatest_total_energy_wh since the function handles both imported and exported energy.

  3. Fix typo: ib.endopint_idib.endpoint_id in evse_supply_state_handler.

Changes

  • drivers/SmartThings/matter-energy/src/init.lua:

    • Changed device:get_latest_state("main", ...)device:get_latest_state(component.id, ...)
    • Renamed latest_total_imported_energy_whlatest_total_energy_wh
    • Fixed ib.endopint_idib.endpoint_id
  • drivers/SmartThings/matter-energy/src/test/test_battery_storage.lua:

    • Updated test expectations to verify non-zero deltaEnergy values (100 Wh)

Type of Change

  • WWST Certification Request
    • If this is your first time contributing code:
      • I have reviewed the README.md file
      • I have reviewed the CODE_OF_CONDUCT.md file
      • I have signed the CLA
    • I plan on entering a WWST Certification Request or have entered a request through the WWST Certification console at developer.smartthings.com
  • Bug fix
  • New feature
  • Refactor

Checklist

  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have verified my changes by testing with a device or have communicated a plan for testing
  • I am adding new behavior, such as adding a sub-driver, and have added and run new unit tests to cover the new behavior

Summary of Completed Tests

…ent state

The energy delta calculation in `report_power_consumption_to_st_energy`
was incorrectly reading the previous energy state from the "main"
component regardless of whether the report was for imported or exported
energy. This caused incorrect deltaEnergy values when multiple energy
components were involved.

Also update test_battery_storage.lua expectations to verify non-zero
delta values (100 Wh) now that the correct component state is used.
…usage

The parameter `latest_total_imported_energy_wh` in the
`report_power_consumption_to_st_energy` function was misleadingly
named since the function handles both imported and exported energy
reporting (determined by the component id).
@github-actions

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

Test Results

   73 files  ±0    537 suites  ±0   0s ⏱️ ±0s
3 167 tests ±0  3 167 ✅ +3  0 💤 ±0  0 ❌  - 3 
5 168 runs  ±0  5 168 ✅ +3  0 💤 ±0  0 ❌  - 3 

Results for commit 162e25e. ± Comparison against base commit 4dcfe01.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

File Coverage
All files 85%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-energy/src/embedded_cluster_utils.lua 80%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-energy/src/init.lua 85%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 162e25e

…te_handler

Fix a typo in the `evse_supply_state_handler` function where
`ib.endopint_id` was used instead of `ib.endpoint_id` when calling
`device:endpoint_to_component()`. This typo would cause the handler
to fail when looking up the correct component for the EVSE supply state.
@sangheedotkim sangheedotkim changed the title Matter Energy: Fix powerConsumptionReport delta calculation and rename energy parameter Matter Energy: Fix powerConsumptionReport delta, rename energy parameter, and fix endpoint typo Jul 10, 2026
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