Skip to content

Matter Switch: Fix Electrical profiling coroutine errors and improve fallback handling - #3150

Merged
hcarter-775 merged 3 commits into
mainfrom
update/energy-struct-error-handling
Jul 31, 2026
Merged

Matter Switch: Fix Electrical profiling coroutine errors and improve fallback handling#3150
hcarter-775 merged 3 commits into
mainfrom
update/energy-struct-error-handling

Conversation

@hcarter-775

@hcarter-775 hcarter-775 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Description of Change

This attempts to improve some open issues in Electrical Sensor handling:

  1. Avoid coroutine errors when handling nil Electrical Energy struct inputs for all hubs using a lua libs version below 21, above which this fix is already in place
  2. Avoid nil-case errors when no default profile for a device type is found for the onOff endpoint- in this case, likely if the device type is Electrical Sensor
  3. Add profiling attributes to refresh as needed, in case errors that can be fixed via retry occur in the future, so that a refresh can trigger re-profiling as needed. All associated handlers block re-profiling if the device has already marked itself as profiled

This solves the following issue: #3147

Summary of Completed Tests

Unit tests continue to pass. Tested on-device: https://community.smartthings.com/t/driver-for-tp-link-tapo-p316m/310364.

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

Channel deleted.

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

matter-switch_coverage.xml

File Coverage
All files 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/hager/init.lua 93%
/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/device_configuration.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_handlers/capability_handlers.lua 83%
/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/aqara_cube/init.lua 95%
/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_utils/utils.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/ikea_scroll/scroll_handlers/event_handlers.lua 75%
/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/eve_energy/init.lua 91%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/ikea_scroll/scroll_utils/event_utils.lua 52%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/third_reality_garage_door/init.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/switch_handlers/event_handlers.lua 97%
/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/sub_drivers/ikea_scroll/init.lua 90%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/sub_drivers/third_reality_mk1/init.lua 93%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/init.lua 97%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against df177dc

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

Test Results

   73 files    540 suites   0s ⏱️
3 241 tests 3 241 ✅ 0 💤 0 ❌
5 233 runs  5 233 ✅ 0 💤 0 ❌

Results for commit df177dc.

♻️ This comment has been updated with latest results.

@hcarter-775
hcarter-775 force-pushed the update/energy-struct-error-handling branch from f210a13 to df177dc Compare July 30, 2026 16:50
@hcarter-775 hcarter-775 changed the title Matter Switch: Avoid coroutine errors from nil inputs for energy structs Matter Switch: Fix Electrical profiling coroutine errors and improve fallback handling Jul 30, 2026
is_optional = true,
data_type = require "st.matter.data_types.Uint64",
},
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we also need to make these updates in matter-thermostat and matter-energy where this is also defined via an embedded cluster definition?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think it matters in those drivers. 1. Nobody is using them 2. Even if they were, there'd be no real side effects of the coroutine error for them

@hcarter-775
hcarter-775 merged commit 2bd5faa into main Jul 31, 2026
14 of 18 checks passed
@hcarter-775
hcarter-775 deleted the update/energy-struct-error-handling branch July 31, 2026 21:04
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