Skip to content
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

Add support for Inovelli VTM31-SN Dimmer Switch #1754

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

nickolas-deboom
Copy link
Contributor

@nickolas-deboom nickolas-deboom commented Nov 14, 2024

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

Description of Change

CHAD-14347

This change adds support for the Inovelli VTM31-SN Dimmer Switch. Initial support for this device was added by PR 1663. This PR includes a profile for this device with embedded preferences as well as handling for these preferences.

The preferences were created to match those defined in Inovelli's matter driver for this device.

Summary of Completed Tests

See here for screenshots from testing with the device.
Also see test_matter_multi_button_switch_mcd.lua which tests a mock device with a similar endpoint structure as the Inovelli device.

Copy link

Duplicate profile check: Passed - no duplicate profiles detected.

Copy link

Copy link

github-actions bot commented Nov 14, 2024

Test Results

   64 files  ±0    401 suites  ±0   0s ⏱️ ±0s
1 999 tests ±0  1 999 ✅ ±0  0 💤 ±0  0 ❌ ±0 
3 439 runs  ±0  3 439 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit f48add6. ± Comparison against base commit 98b7d7d.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Nov 14, 2024

File Coverage
All files 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/inovelli-vtm31-sn/init.lua 47%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/matter-switch/src/init.lua 96%
/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 38%
/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 f48add6


local LATEST_CLOCK_SET_TIMESTAMP = "latest_clock_set_timestamp"

local preference_map_inovelli_vtm31sn = {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would make sense to move preferences that are specific to a certain device to a sub driver if we are able to. Or these configs could be moved to their own file at least to keep it separate from the base driver where we should try to handle things as generically as possible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved the inovelli-specific handling to a subdriver in 2e8b4b5

for id, value in pairs(device.preferences) do
if args.old_st_store.preferences[id] ~= value and preferences and preferences[id] then
local new_parameter_value = preferences_to_numeric_value(device.preferences[id])
local req = clusters.ModeSelect.server.commands.ChangeToMode(device, preferences[id].parameter_number, new_parameter_value)
Copy link
Contributor

Choose a reason for hiding this comment

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

If the mode cluster is going to be used here, this would be the first use of it in the matter-switch driver. This means we'd need to add it as an embedded cluster so it could be used on older FW that doesn't support the mode cluster via the lua libs definitions yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like ModeSelect has been been in the spec since matter 1.0. Is there a way to check when it was first added to the lua libs?

return
end

if device.manufacturer_info.vendor_id == fingerprint_profile_overrides[1].vendor_id and
Copy link
Contributor

Choose a reason for hiding this comment

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

This code is somewhat confusing and I think it could use some comments or documentation somewhere since there is some device specific knowledge here. For example, why is the time diff here and what is the significance of the values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this code is used to prevent preferences from being changed faster than every two seconds. This was the same way that Inovelli implemented this for the zigbee driver, so it could be a device limitation. I will add some comments to make things a little more clear.

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