-
Notifications
You must be signed in to change notification settings - Fork 510
zigbee-switch: Filter incorrect network type #2445
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
base: main
Are you sure you want to change the base?
Conversation
Invitation URL: |
Test Results 71 files 455 suites 0s ⏱️ Results for commit 9bbd9f5. ♻️ This comment has been updated with latest results. |
Minimum allowed coverage is Generated by 🐒 cobertura-action against 9bbd9f5 |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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 |
a675b27
to
0843dc6
Compare
local log = require "log" | ||
|
||
local function can_handle(opts, driver, device) | ||
if device.network_type ~= st_device.NETWORK_TYPE_ZIGBEE then |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
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! |
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
Checklist
Description of Change
Summary of Completed Tests