Skip to content

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

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

WWSTCERT-10701 Add Sonoff SNZB-01M Smart Scene Button into zigbee-button.#2510
Oniums wants to merge 9 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

@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    496 suites   0s ⏱️
2 716 tests 2 711 ✅ 0 💤 0 ❌ 5 🔥
4 585 runs  4 580 ✅ 0 💤 0 ❌ 5 🔥

For more details on these errors, see this check.

Results for commit d487ce0.

♻️ 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/adurosmart/init.lua 97%
/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/ecosmart/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/ikea/TRADFRI_remote_control/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/pushButton/init.lua 76%
/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/supported_values.lua 99%
/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/iris/init.lua 89%
/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/ikea/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/zigbee-multi-button/robb/init.lua 99%
/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/frient/init.lua 98%
/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/aqara/init.lua 94%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/sonoff/init.lua 70%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/heiman/init.lua 98%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against d487ce0

@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 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.

@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.

Oniums added 2 commits March 10, 2026 09:12
- Remove custom battery attribute handler and added lifecycle in Sonoff subdriver
- Align Sonoff tests with default added behavior and keep battery report coverage
@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 on lines +1 to +13
-- Copyright 2026 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
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.

Suggested change
-- Copyright 2026 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

Comment on lines +1 to +12
-- Copyright 2026 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
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.

Suggested change
-- Copyright 2026 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

Comment on lines +1 to +13
-- Copyright 2026 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
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.

Suggested change
-- Copyright 2026 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

Comment on lines +1 to +13
-- Copyright 2026 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
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.

Suggested change
-- Copyright 2026 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

@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.

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.

7 participants