Skip to content

Matter Switch: Use Total Wh for PCR if delta < 0.0#2993

Open
hcarter-775 wants to merge 1 commit into
mainfrom
avoid/negative-power-reports
Open

Matter Switch: Use Total Wh for PCR if delta < 0.0#2993
hcarter-775 wants to merge 1 commit into
mainfrom
avoid/negative-power-reports

Conversation

@hcarter-775
Copy link
Copy Markdown
Contributor

Description of Change

Use total Wh instead of a negative value for the delta of the powerConsumptionReport. This should only ever be negative in the case that the device has had its energy meter reset, so we should avoid spiking the energy report for ST energy in a case like this.

Summary of Completed Tests

Unit tests updated.

@github-actions
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Test Results

   72 files    511 suites   0s ⏱️
2 865 tests 2 865 ✅ 0 💤 0 ❌
4 737 runs  4 737 ✅ 0 💤 0 ❌

Results for commit cfdc32f.

@github-actions
Copy link
Copy Markdown

File Coverage
All files 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/ikea_scroll/init.lua 87%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/eve_energy/init.lua 91%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/utils.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/embedded_cluster_utils.lua 38%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_utils/device_configuration.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_utils/utils.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_utils/device_configuration.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_handlers/capability_handlers.lua 84%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_handlers/attribute_handlers.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/aqara_cube/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/third_reality_mk1/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_handlers/capability_handlers.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_handlers/event_handlers.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/switch_handlers/attribute_handlers.lua 80%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/ikea_scroll/scroll_handlers/event_handlers.lua 93%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against cfdc32f

Copy link
Copy Markdown
Contributor

@Kwang-Hui Kwang-Hui left a comment

Choose a reason for hiding this comment

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

Looks good to me

@mocelet
Copy link
Copy Markdown

mocelet commented May 22, 2026

avoid spiking the energy report for ST energy

I thought the purpose was to avoid losing ST energy data for the interval (e.g. 15 minutes) when a reset happens.

Emitting the total Wh when assuming a reset happened prevents losing the part of the energy post-reset. However, the part before the reset in that interval would be lost.

Maybe the pre-reset part can be restored so the energy reportings for ST Energy are completely reset-proof. Would need to store the maximum energy received in a field and, when the reset is detected, calculate the delta before the reset and add it to the total Wh so the delta of that interval is accurate.

Matter does not have standard commands to reset the meter anyway so probably not worth it complicating it at the moment.

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.

3 participants