Skip to content

WWSTCERT-10701 Add Sonoff SNZB-01M Smart Scene Button into zigbee-button.#2510

Open
Oniums wants to merge 13 commits intoSmartThingsCommunity:mainfrom
Oniums:main
Open

WWSTCERT-10701 Add Sonoff SNZB-01M Smart Scene Button into zigbee-button.#2510
Oniums wants to merge 13 commits intoSmartThingsCommunity:mainfrom
Oniums:main

Conversation

@Oniums
Copy link
Copy Markdown

@Oniums Oniums commented Oct 30, 2025

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

This PR adds support for the Sonoff SNZB-01M Smart Scene Button to the existing zigbee-button driver.

Changes made:

  1. Added device fingerprint in fingerprints.yml to recognize the SONOFF SNZB-01M device
  2. Created device profile sonoff-buttons-battery.yml with 4 button components and battery capability
  3. Implemented custom handler in src/zigbee-multi-button/sonoff/init.lua to handle SONOFF-specific Zigbee communication
  4. Added device support to the multi-button matching matrix with support for 4 button actions: pushed, double, held, pushed_3x
  5. Created test file test_sonoff_button.lua for verification purposes

Summary of Completed Tests

Device Testing:

  • Device pairing: Successfully paired SONOFF SNZB-01M with SmartThings Hub
  • Button actions: Verified all 4 button types work correctly:
    • Single press (pushed)
    • Double press (double)
    • Long press (held)
    • Triple press (pushed_3x)
  • Battery reporting: Confirmed battery percentage is correctly displayed in SmartThings app
  • Endpoint mapping: Verified button events are properly mapped to correct button components (button1-button4)

Code Testing:

  • Fingerprint recognition: Device correctly identified during pairing process
  • Profile loading: Device profile loaded successfully with all 4 button components
  • Event handling: Custom SONOFF handler processes Zigbee messages correctly
  • Integration: No conflicts with existing button drivers

Compatibility:

  • SmartThings Hub compatibility: Tested on SmartThings Hub v3
  • Driver integration: Successfully integrates with existing zigbee-button driver framework
  • No regression: Existing button devices continue to function normally

Comment thread drivers/SmartThings/zigbee-button/src/zigbee-multi-button/sonoff/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua Outdated
Comment thread drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua Outdated
@github-actions
Copy link
Copy Markdown

Duplicate profile check: Passed - no duplicate profiles detected.

@github-actions
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 13, 2025

Test Results

   72 files  ± 0    500 suites  +5   0s ⏱️ ±0s
2 746 tests +32  2 746 ✅ +32  0 💤 ±0  0 ❌ ±0 
4 639 runs  +49  4 639 ✅ +49  0 💤 ±0  0 ❌ ±0 

Results for commit 70dd9ec. ± Comparison against base commit 09cb31c.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 13, 2025

File Coverage
All files 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/SLED/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/ikea/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/aqara/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/init.lua 83%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/supported_values.lua 99%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/frient/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/zunzunbee/init.lua 95%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/robb/init.lua 99%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/ecosmart/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/wallhero/init.lua 87%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/aqara-knob/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/iris/init.lua 89%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/shinasystems/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/ikea/TRADFRI_remote_control/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/adurosmart/init.lua 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/heiman/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/lazy_load_subdriver.lua 57%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/button_utils.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/vimar/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/somfy/somfy_situo_4/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/pushButton/init.lua 76%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 70dd9ec

Comment thread drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua Outdated
Comment thread drivers/SmartThings/zigbee-button/src/zigbee-multi-button/sonoff/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-button/src/zigbee-multi-button/sonoff/init.lua Outdated
@greens
Copy link
Copy Markdown
Contributor

greens commented Feb 5, 2026

Checking drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua 8 warnings

    drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua:67:1: (W611) line contains only whitespace
    drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua:143:122: (W612) line contains trailing whitespace
    drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua:145:1: (W611) line contains only whitespace
    drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua:161:1: (W611) line contains only whitespace
    drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua:180:1: (W611) line contains only whitespace
    drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua:199:1: (W611) line contains only whitespace
    drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua:218:1: (W611) line contains only whitespace
    drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua:253:1: (W611) line contains only whitespace

Comment thread drivers/SmartThings/zigbee-button/profiles/sonoff-buttons-battery.yml Outdated
Comment thread drivers/SmartThings/zigbee-button/src/zigbee-multi-button/sonoff/init.lua Outdated
Comment on lines +133 to +139
},
SONOFF_BUTTON_4 = {
MATCHING_MATRIX = {
{ mfr = "SONOFF", model = "SNZB-01M" }
},
SUPPORTED_BUTTON_VALUES = { "pushed", "double", "held", "pushed_3x" },
NUMBER_OF_BUTTONS = 4
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since you overwrote added in your handler (because you did not include the button capability on your main component, this info is never used.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

@greens greens Feb 25, 2026

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

It seems that you are going to go forward with the profile as is. I am commenting to make sure you have tested the device on the platform to ensure it works the way you want, since this is different than what we have for our multibutton profiles. We recommend having the button capability on the main component, and duplicating events for any button press to that component also, so that in the device list view of the app, you can see the events affect the device rather than in just the details view. Doing so also gives users a hook for routines that will trigger on any button press of the remote.

@greens
Copy link
Copy Markdown
Contributor

greens commented Feb 10, 2026

Checking drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua 1 warning

    drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua:143:122: (W612) line contains trailing whitespace

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 25, 2026

CLA assistant check
All committers have signed the CLA.

Comment thread drivers/SmartThings/zigbee-button/src/zigbee-multi-button/sonoff/init.lua Outdated
@greens
Copy link
Copy Markdown
Contributor

greens commented Feb 27, 2026

driver needs to be rebased

@Oniums
Copy link
Copy Markdown
Author

Oniums commented Mar 6, 2026

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?

@greens
Copy link
Copy Markdown
Contributor

greens commented Mar 9, 2026

@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 main:

In your fork's directory:

git remote add upstream git@github.com:SmartThingsCommunity/SmartThingsEdgeDrivers.git
git checkout upstream/main
git pull
git checkout main
git rebase upstream/main

Then you should be able to resolve the conflicts and git push --force up your changes.

Comment thread drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua Outdated
@greens greens changed the title Add Sonoff SNZB-01M Smart Scene Button into zigbee-button. WWSTCERT-9467 Add Sonoff SNZB-01M Smart Scene Button into zigbee-button. Mar 10, 2026
@cbaumler cbaumler requested review from ctowns and hcarter-775 and removed request for pegor-karoglanian and wkhenon March 18, 2026 21:41
@cbaumler cbaumler requested review from cjswedes and removed request for hcarter-775 March 26, 2026 22:32
@KKlimczukS KKlimczukS changed the title WWSTCERT-9467 Add Sonoff SNZB-01M Smart Scene Button into zigbee-button. WWSTCERT-10701 Add Sonoff SNZB-01M Smart Scene Button into zigbee-button. Mar 27, 2026
Copy link
Copy Markdown
Contributor

@KKlimczukS KKlimczukS left a comment

Choose a reason for hiding this comment

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

Please update copyright sections

Comment thread drivers/SmartThings/zigbee-button/src/test/test_sonoff_button.lua Outdated
Comment thread drivers/SmartThings/zigbee-button/src/zigbee-multi-button/sonoff/can_handle.lua Outdated
Comment thread drivers/SmartThings/zigbee-button/src/zigbee-multi-button/sonoff/fingerprints.lua Outdated
Comment thread drivers/SmartThings/zigbee-button/src/zigbee-multi-button/sonoff/init.lua Outdated
@cbaumler cbaumler requested review from aleclorimer and removed request for ctowns March 27, 2026 16:11
Copy link
Copy Markdown
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.

LGTM, just note the suggestion to reconsider adding the button capability to the main component of the device and emitting events for it when any button is affected.

return false
end

return sonoff_can_handle No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: newline in this file and all the other files.

Comment on lines +133 to +139
},
SONOFF_BUTTON_4 = {
MATCHING_MATRIX = {
{ mfr = "SONOFF", model = "SNZB-01M" }
},
SUPPORTED_BUTTON_VALUES = { "pushed", "double", "held", "pushed_3x" },
NUMBER_OF_BUTTONS = 4
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

It seems that you are going to go forward with the profile as is. I am commenting to make sure you have tested the device on the platform to ensure it works the way you want, since this is different than what we have for our multibutton profiles. We recommend having the button capability on the main component, and duplicating events for any button press to that component also, so that in the device list view of the app, you can see the events affect the device rather than in just the details view. Doing so also gives users a hook for routines that will trigger on any button press of the remote.

@Oniums
Copy link
Copy Markdown
Author

Oniums commented Mar 31, 2026

I tested it on the platform and it works as expected. The two screenshots above are from the SmartThings app during testing.

@cjswedes cjswedes requested a review from KKlimczukS April 3, 2026 15:31
@cjswedes
Copy link
Copy Markdown
Contributor

cjswedes commented Apr 3, 2026

@Oniums the view that Steven and I are mentioning where button presses will not be shown is the list view for the devices. This is why we typically include the button capability on the main component and then issue events for it whenever one of the buttons is pressed. This is the app view I am referencing:

devices-view

@cbaumler
Copy link
Copy Markdown
Contributor

cbaumler commented Apr 6, 2026

Hello @Oniums, in addition to @cjswedes's feedback about making sure the device is working the way you expect, there are also some test failures and merge conflicts that need to be addressed before this PR can be merged.

Oniums and others added 2 commits April 8, 2026 09:53
- Reuse existing four-buttons-battery profile instead of custom sonoff-buttons-battery
- Mirror button events to main component via emit_event for device list visibility
- Update test profile reference and add main component event assertions
- Remove unused sonoff-buttons-battery.yml profile
@Oniums
Copy link
Copy Markdown
Author

Oniums commented Apr 8, 2026

I've updated the SNZB-01M implementation based on the review feedback:

  • Switched to the existing four-buttons-battery profile (removed the custom sonoff-buttons-battery profile)
  • Added event mirroring to the main component via emit_event so button events are visible in the device list
  • Updated tests with the correct profile reference and added main component event assertions

I tested on a Hub V3 with a physical SNZB-01M device, and everything works as expected.
Here are the screenshots:
f5bd9b01514d49f9abb795ab3e3e4e20d9f6b87144fc45a7b2e3e8fda9dd1f86

@cbaumler
Copy link
Copy Markdown
Contributor

cbaumler commented Apr 8, 2026

@Oniums it looks like there are still test failures that need to be addressed.

- replace unsupported build_custom_report_attribute usage with an explicit custom Zigbee attribute report builder
- add missing main component expectations for the added lifecycle test
- add min_api_version guards to Sonoff test cases
- keep Sonoff button event assertions aligned with the four-buttons-battery profile behavior
@KKlimczukS KKlimczukS requested a review from cjswedes April 13, 2026 11:59
@cbaumler
Copy link
Copy Markdown
Contributor

Hello @Oniums, it looks like this PR branch is out of date with main. Please update it with the latest main and push the result so it can be merged.

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.

8 participants