WWSTCERT-9467 Add Sonoff SNZB-01M Smart Scene Button into zigbee-button.#2510
WWSTCERT-9467 Add Sonoff SNZB-01M Smart Scene Button into zigbee-button.#2510Oniums wants to merge 8 commits intoSmartThingsCommunity:mainfrom
Conversation
| @@ -0,0 +1,87 @@ | |||
| -- Copyright 2024 SmartThings | |||
| @@ -0,0 +1,26 @@ | |||
| -- Test file for SONOFF SNZB-01M integration | |||
| end | ||
| end | ||
|
|
||
| return test No newline at end of file |
There was a problem hiding this comment.
Please add some proper unit tests utiliizing expect_send and expect_receive. More details can be found here
|
Duplicate profile check: Passed - no duplicate profiles detected. |
|
Invitation URL: |
Test Results 72 files 493 suites 0s ⏱️ For more details on these errors, see this check. Results for commit 61d1077. ♻️ This comment has been updated with latest results. |
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against 61d1077 |
| @@ -0,0 +1,261 @@ | |||
| -- Copyright 2022 SmartThings | |||
| local function battery_attr_handler(driver, device, value, zb_rx) | ||
| local percent = math.floor((value.value or 0) / 2) | ||
| device:emit_event(capabilities.battery.battery(percent)) | ||
| log.info(string.format("Battery percentage remaining: %d%%", percent)) |
| local endpoint = zb_rx.address_header.src_endpoint.value | ||
| local button_name = "button" .. tostring(endpoint) | ||
| local event_func = EVENT_MAP[attr_val] | ||
| log.info(string.format("SONOFF attr: endpoint=%s, value=%s, button=%s", endpoint, attr_val, button_name)) |
|
There was a problem hiding this comment.
to avoid duplication here, I'd recommend you use the existing profile four-buttons-without-main-button
| local function battery_attr_handler(driver, device, value, zb_rx) | ||
| local percent = math.floor((value.value or 0) / 2) | ||
| device:emit_event(capabilities.battery.battery(percent)) | ||
| end |
There was a problem hiding this comment.
this should be handled by the defaults
| }, | ||
| SONOFF_BUTTON_4 = { | ||
| MATCHING_MATRIX = { | ||
| { mfr = "SONOFF", model = "SNZB-01M" } | ||
| }, | ||
| SUPPORTED_BUTTON_VALUES = { "pushed", "double", "held", "pushed_3x" }, | ||
| NUMBER_OF_BUTTONS = 4 |
There was a problem hiding this comment.
Since you overwrote added in your handler (because you did not include the button capability on your main component, this info is never used.
There was a problem hiding this comment.
Thanks for the suggestion. I checked the existing profiles: four-buttons-without-main-button has no battery capability, while four-buttons-battery includes button on main, which doesn’t match the SNZB-01M capability layout. Would you prefer that I: use four-buttons-without-main-button and accept no battery on main, or use the profile I added earlier.
There was a problem hiding this comment.
I understand why you've added the new profile, but I'll advise you on why our multi-button profiles include the button capability on the main component: without it (and duplicating any other buttons' events to main, the remote on the device list will not change to indicate button presses. You'll only see them within the device details page.
I didn't notice four-buttons-without-main-button didn't have battery. I definitely think you should maintain that.
So you can go with your new profile if you like, but this comment was merely pointing out that, because these values are only used in the zigbee-multi-button added handler, your additions to this file are not used.
|
| log.warn("Unknown button component: " .. button_name) | ||
| end | ||
| else | ||
| log.warn("Unknown event value: " .. tostring(attr_val)) |
There was a problem hiding this comment.
remove these log statements
|
driver needs to be rebased |
|
Is the rebase based on this PR? If I submit a new PR, will it cause any issues if it doesn’t match the PR used for the Samsung certification application? |
|
@Oniums you should be able to set your fork's upstream to our main repo, update the main branch there, then rebase your changes on your local branch onto In your fork's directory: Then you should be able to resolve the conflicts and |
… lines Update copyright year from 2022 to 2026,remove remove whitespace-only lines
remove log.info
- Remove custom battery attribute handler and added lifecycle in Sonoff subdriver - Align Sonoff tests with default added behavior and keep battery report coverage
| end | ||
| ) | ||
|
|
||
| return test |
There was a problem hiding this comment.
Your tests are not being run.
Your test should end with test.run_registered_tests().
If you had run your tests, you would see that they fail, because you have not actually added your sub-driver to the base driver. You need to use this file: https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/main/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/sub_drivers.lua a and also change how your can_handle function is written and broken out. Here's an example: https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/main/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/ecosmart/can_handle.lua
Your directory structure should look like all the other sub-drivers'
Check all that apply
Type of Change
Checklist
Description of Change
This PR adds support for the Sonoff SNZB-01M Smart Scene Button to the existing zigbee-button driver.
Changes made:
fingerprints.ymlto recognize the SONOFF SNZB-01M devicesonoff-buttons-battery.ymlwith 4 button components and battery capabilitysrc/zigbee-multi-button/sonoff/init.luato handle SONOFF-specific Zigbee communicationtest_sonoff_button.luafor verification purposesSummary of Completed Tests
Device Testing:
Code Testing:
Compatibility: