Skip to content

Matter Switch: Update find default endpoint #2155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: profile-energy-child-plugs
Choose a base branch
from

Conversation

hcarter-775
Copy link
Contributor

Description of Change

This PR aims to expand and clarify the use of find_default_endpoint in the matter switch driver. At the moment, nothing should change as far as logic, but this will create a more extensible system moving forward.

This builds on top of the plug-energy PR, but technically does not need to.

Summary of Completed Tests

Copy link

Copy link

github-actions bot commented May 29, 2025

Test Results

   67 files  ±0    440 suites  ±0   0s ⏱️ ±0s
2 250 tests ±0  2 250 ✅ ±0  0 💤 ±0  0 ❌ ±0 
3 842 runs  ±0  3 842 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit fd2bb89. ± Comparison against base commit aef53f3.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented May 29, 2025

File Coverage
All files 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/aqara-cube/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/init.lua 93%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/eve-energy/init.lua 90%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/embedded-cluster-utils.lua 38%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/third-reality-mk1/init.lua 95%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against fd2bb89

@nickolas-deboom
Copy link
Contributor

Wouldn't the default endpoint always be the first switch (or button if there are no switches) endpoint? Child devices would be created for any additional endpoints that implement OnOff

@hcarter-775
Copy link
Contributor Author

Not sure exactly what you're asking @nickolas-deboom, sorry. The default endpoint shouldn't have to be the first endpoint that implements onOff in all cases, but as it stands that's basically how it is, which in general is not correct. For now, it works, but it may not work in all cases.

-- Return the first switch endpoint as the default endpoint if no button endpoints are present
if #button_eps == 0 and #switch_eps > 0 then
return get_first_non_zero_endpoint(switch_eps)
if #switch_eps then
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if #switch_eps then
if #switch_eps > 0 then

You might need > 0 since 0 would evaluate to true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true, thanks!

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