Skip to content

Conversation

@nickolas-deboom
Copy link
Contributor

@nickolas-deboom nickolas-deboom commented Mar 27, 2025

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
  • Test case update

Description of Change

Add backwards compatibility for matter switch test cases down to lua libs version v10 and improve overall test coverage. Most of the issues were from test cases expecting native handler registrations, which was added in v11. This PR also fixes a bug in the driver code for lua libs version v10 and lower, which prevented the energyMeter capability from being emitted.

It might be possible to extend support to even lower versions, but there are a few additional api changes that would need to be accounted for.

Also note that to run these tests against lower versions, any capabilities that are not available in that version of the lua libs would need to be manually added to prevent test failures.

@github-actions
Copy link

github-actions bot commented Mar 27, 2025

Channel deleted.

@github-actions
Copy link

github-actions bot commented Mar 27, 2025

Test Results

   66 files    424 suites   0s ⏱️
2 195 tests 2 195 ✅ 0 💤 0 ❌
3 721 runs  3 721 ✅ 0 💤 0 ❌

Results for commit 32a9f65.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Mar 27, 2025

File Coverage
All files 98%
/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/embedded-cluster-utils.lua 91%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/eve-energy/init.lua 91%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 32a9f65

@nickolas-deboom nickolas-deboom force-pushed the matter-switch-fix-test-cases-for-lower-lua-libs branch 2 times, most recently from 63574b2 to 7188758 Compare March 28, 2025 15:04
@nickolas-deboom nickolas-deboom force-pushed the matter-switch-fix-test-cases-for-lower-lua-libs branch 3 times, most recently from 4ea4089 to a07ec42 Compare April 15, 2025 19:20
Add backwards compatibility for matter switch test cases down to lua
libs version v10. Most of the issues were from test cases expecting
native handler registrations, which was added in v11. Also, running the
test cases against lower lua libs caught a bug in the driver code for
lua libs version v10 and lower, which prevented the energyMeter
capability from being emitted. This is also fixed by this PR.

It might be possible to extend support to even lower versions, but there
are a few additional api changes that would need to be accounted for.

Also note that to run these tests against lower versions, any
capabilities that are not available in that version of the lua libs
would need to be manually added to prevent test failures.
@nickolas-deboom nickolas-deboom force-pushed the matter-switch-fix-test-cases-for-lower-lua-libs branch from a07ec42 to be5f48e Compare April 15, 2025 19:23
This commit removes some unreachable code and also adds new test cases
to improve code coverage.
@nickolas-deboom nickolas-deboom force-pushed the matter-switch-fix-test-cases-for-lower-lua-libs branch 2 times, most recently from daf4874 to f8ae614 Compare April 17, 2025 21:02
@nickolas-deboom nickolas-deboom changed the title Make matter switch tests backwards compatible down to lua libs v10 Improve test coverage and add backwards compatibility for matter switch tests down to lua libs v10 Apr 17, 2025
@nickolas-deboom nickolas-deboom changed the title Improve test coverage and add backwards compatibility for matter switch tests down to lua libs v10 Improve test coverage and backwards compatibility for matter switch tests Apr 18, 2025
@nickolas-deboom nickolas-deboom force-pushed the matter-switch-fix-test-cases-for-lower-lua-libs branch 2 times, most recently from 409c457 to b9c573d Compare April 18, 2025 15:27
Add new test cases to cover areas missing test coverage.
@nickolas-deboom nickolas-deboom force-pushed the matter-switch-fix-test-cases-for-lower-lua-libs branch from b9c573d to 32a9f65 Compare April 18, 2025 15:29
end

local function mired_to_kelvin(value, minOrMax)
if value == 0 then -- shouldn't happen, but has
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code is unreachable because 0 is outside of the range of "sane" values checked at the call site

elseif minOrMax == COLOR_TEMP_MAX then
else -- minOrMax = COLOR_TEMP_MAX
return utils.round(MIRED_KELVIN_CONVERSION_CONSTANT / (kelvin_step_size * (value - 1)) - rounding_value) * kelvin_step_size
else
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This else is unreachable because this function is only called with COLOR_TEMP_MIN or COLOR_TEMP_MAX, so it can be removed

if ep.endpoint_id == endpoint_id then
for _, dt in ipairs(ep.device_types) do
if dt.device_type_id == DIMMABLE_LIGHT_DEVICE_TYPE_ID then
for _, fingerprint in ipairs(child_device_profile_overrides_per_vendor_id[0x115F]) do
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This Aqara device uses device type 0x100, while DIMMABLE_LIGHT_DEVICE_TYPE_ID is 0x101, so this code can be removed

end

local function configure_buttons(device)
if device.network_type == device_lib.NETWORK_TYPE_CHILD then
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check is already done at both call sites of configure_buttons so it can be removed

@hcarter-775
Copy link
Contributor

do you think this is worth a rebase? Should we close this? Just checking since it's been open for ~6 months.

@nickolas-deboom
Copy link
Contributor Author

do you think this is worth a rebase? Should we close this? Just checking since it's been open for ~6 months.

I would say probably not because backwards compatibility was broken by scripting engine changes. Closing

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