Skip to content

Conversation

tandres
Copy link
Contributor

@tandres tandres commented Oct 2, 2025

A small number of zwave devices failed to migrate correctly and ended up as zwave devices attached to the zigbee switch driver. This change adds a patched driver.lua which includes a mechanism to filter devices when building device info which don't match device type filters added to the driver.

https://smartthings.atlassian.net/browse/CHAD-16558

Check all that apply

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

Summary of Completed Tests

Copy link

github-actions bot commented Oct 2, 2025

Copy link

github-actions bot commented Oct 2, 2025

Test Results

   71 files    455 suites   0s ⏱️
2 355 tests 2 355 ✅ 0 💤 0 ❌
3 978 runs  3 978 ✅ 0 💤 0 ❌

Results for commit 9bbd9f5.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Oct 2, 2025

File Coverage
All files 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara/version/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/ge-link-bulb/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/init.lua 93%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/preferences.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/jasco/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/frient/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/inovelli-vzm31-sn/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/tuya-multi/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/wallhero/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara-light/init.lua 93%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/laisiao/init.lua 90%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-switch/src/aqara/init.lua 94%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 9bbd9f5

@tandres tandres requested review from greens, varzac, aleclorimer and cjswedes and removed request for greens October 2, 2025 00:18
@varzac
Copy link
Contributor

varzac commented Oct 2, 2025

I think rather than including the entire driver.lua file here (since we often have to leave workarounds like this in for a long time due to slow to update hubs), I would rather we just override the individual functions.


function Driver:_filter_network_type(raw_device_table)
if self.device_network_type_filter then
return self.device_network_type_filter[raw_device_table.network_type] ~= nil
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
return self.device_network_type_filter[raw_device_table.network_type] ~= nil
return self.device_network_type_filter[raw_device_table.network_type] or false

Not critical, but in case we ever add an entry with false, this would still work.

end

test.set_test_init_function(test_init)
test.register_test("mismatched_prot_ignored", function() end, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't understand this test.

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 pushed up some additional comments on the test. It's just making sure the driver doesn't crash when you add a ZWave device to it.

@greens
Copy link
Contributor

greens commented Oct 2, 2025

I agree with @varzac . These "temporary" fixes tend to stick around for a while. I think it would be better to write this as a sub-driver full of no-ops.

@varzac
Copy link
Contributor

varzac commented Oct 2, 2025

I agree with @varzac . These "temporary" fixes tend to stick around for a while. I think it would be better to write this as a sub-driver full of no-ops.

I hadn't considered a subdriver full of noops. Originally I was thinking that may not be sufficient because any functions in the driver class may be assuming a specific device type. But looking at the zigbee driver class, the only place the device object is referenced is if the health_check stuff is true, and we have that disabled. So we might be able to consider this approach as a short term fix. I don't necessarily have a problem with the approach taken here, but I do think a subdriver might be a neater solution.

@tandres tandres force-pushed the CHAD-16558 branch 2 times, most recently from a675b27 to 0843dc6 Compare October 2, 2025 18:39
local log = require "log"

local function can_handle(opts, driver, device)
if device.network_type ~= st_device.NETWORK_TYPE_ZIGBEE then
Copy link
Contributor

Choose a reason for hiding this comment

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

Child devices shouldn't use this subdriver either.

Copy link
Contributor

@cjswedes cjswedes left a comment

Choose a reason for hiding this comment

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

Can you add a test, where a non zigbee device has a capability command come in, to make sure that doesnt crash. I also think that infoChanged could cause problems, so please add that to the existing test.

One thing I liked about monkey patching the driver, is that it more deeply prevented the device from being used in by anything in the zigbee driver than the subdriver approach does.

A small number of zwave devices failed to migrate correctly and ended up
as zwave devices attached to the zigbee switch driver. This change adds
a subdriver (non_zigbee_devices) which handles non-zigbee devices safely
without crashing the driver.

https://smartthings.atlassian.net/browse/CHAD-16558
@tandres
Copy link
Contributor Author

tandres commented Oct 3, 2025

Can you add a test, where a non zigbee device has a capability command come in, to make sure that doesnt crash. I also think that infoChanged could cause problems, so please add that to the existing test.

One thing I liked about monkey patching the driver, is that it more deeply prevented the device from being used in by anything in the zigbee driver than the subdriver approach does.

Info changed added, also added a command test which doesn't seem to break anything. My driver skillz are weak so I appreciate the in-depth review!

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.

4 participants