Skip to content

[WWSTCERT-13462, WWSTCERT-13465] Sonoff SWV2C valve support - #3171

Open
yezi289 wants to merge 7 commits into
SmartThingsCommunity:mainfrom
yezi289:swv2c
Open

yezi289 wants to merge 7 commits into
SmartThingsCommunity:mainfrom
yezi289:swv2c

Conversation

@yezi289

@yezi289 yezi289 commented Aug 11, 2026

Copy link
Copy Markdown

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

1、Add Sonoff valve subdriver lazy loading.
2、Modify comment language and file name
@CLAassistant

CLAassistant commented Aug 11, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@yezi289

yezi289 commented Aug 11, 2026

Copy link
Copy Markdown
Author

I have tested this with a physical Sonoff SWV2C device. It pairs successfully in the SmartThings app, and both valve controls work normally.

@ldeora

ldeora commented Aug 11, 2026 •

Copy link
Copy Markdown

I have tested this with a physical Sonoff SWV2C device. It pairs successfully in the SmartThings app, and both valve controls work normally.

That's the easiest part, but does it stay on for longer than 10 minutes or does it automatically turn itself off after 10 minutes? What happens after - say - 15 minutes?

The device is completely useless when it turns itself off after 10 minutes. Users don't want to turn it on every 10 minutes if they want to irrigate for an hour.

Discussion:

https://community.smartthings.com/t/st-edge-sonoff-hydro-one-duo-family-swv-zfe-swv-zfu-swv-zne-swv-znu-swv-zf2e-swv-zf2u/309672

It's a bit more complicated (link to (outdated) code and technical documentation):

https://community.smartthings.com/t/st-edge-sonoff-hydro-one-duo-family-swv-zfe-swv-zfu-swv-zne-swv-znu-swv-zf2e-swv-zf2u/309672/106

@ldeora

ldeora commented Aug 11, 2026

Copy link
Copy Markdown

Another issue: before a channel is turned on, the opposite channel must be turned off. According to the official manual only one channel should be open at any time.

https://github.com/ldeora/SmartThingsEdgeDrivers/blob/main/sonoff-hydro/TECHNICAL_DOCUMENTATION.md#19-hydro-duo-architecture

@yezi289

yezi289 commented Aug 11, 2026

Copy link
Copy Markdown
Author

I tested this with a physical Sonoff SWV2C device.

For the 10-minute behavior: yes, the device has an internal default auto-close/manual watering duration. In my test, if a valve is opened normally, the device closes it automatically after the configured duration. The default value appears to be 10 minutes. Users can change the irrigation/manual watering duration through the device's own configuration path outside of this basic valve control behavior.

For the dual-channel behavior: I also tested the mutual exclusion behavior on the physical device. The two channels cannot stay open at the same time. If channel 1 is open and then channel 2 is opened, channel 1 is automatically closed and channel 2 opens. The device firmware reports the valve state automatically when a valve is operated, and the SmartThings app state updates correctly from those reports.

If preferred, I can update the driver to explicitly send an Off command to the opposite endpoint before opening the requested channel, so the SmartThings state stays aligned with the device behavior.

@KKlimczukS KKlimczukS changed the title Add Sonoff SWV2C valve support [WWSTCERT-13462, WWSTCERT-13465] Sonoff SWV2C valve support Aug 27, 2026

@KKlimczukS KKlimczukS left a comment

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.

@yezi289 Why don't You add those changes to the other PR #3157 that is being currently reviewed ?

@yezi289

yezi289 commented Aug 28, 2026

Copy link
Copy Markdown
Author

Thanks for the feedback.

I’d prefer to keep this PR focused on SWV2C. SWV2C is a different hardware product from SWV1C. SWV1C is a single-channel valve, while SWV2C is a dual-channel valve with two endpoints and mutual-exclusion behavior between the two channels.

There is already a separate PR for SWV1C, and that PR is focused on the single-channel device. Since SWV2C requires different handling for the second endpoint and child device, I think it is clearer and safer to review SWV2C in this dedicated PR instead of combining both hardware products into one submission.

This also keeps the scope of each PR aligned with one hardware product and one WWST certification flow.

Comment thread drivers/SmartThings/zigbee-valve/src/init.lua Outdated
Comment thread drivers/SmartThings/zigbee-valve/src/sub_drivers.lua Outdated
Comment thread drivers/SmartThings/zigbee-valve/src/test/test_sonoff_valve_2.lua Outdated
Comment thread drivers/SmartThings/zigbee-valve/src/test/test_sonoff_valve_2.lua Outdated
Comment thread drivers/SmartThings/zigbee-valve/src/test/test_sonoff_valve_2.lua Outdated
Comment thread drivers/SmartThings/zigbee-valve/src/test/test_sonoff_valve_2.lua Outdated
Comment thread drivers/SmartThings/zigbee-valve/src/test/test_sonoff_valve_2.lua Outdated
Comment thread drivers/SmartThings/zigbee-valve/src/test/test_sonoff_valve_2.lua Outdated
Comment thread drivers/SmartThings/zigbee-valve/src/test/test_sonoff_valve_2.lua Outdated
Comment thread drivers/SmartThings/zigbee-valve/src/test/test_sonoff_valve_2.lua Outdated
Comment thread drivers/SmartThings/zigbee-valve/src/test/test_sonoff_valve_2.lua Outdated
Comment thread drivers/SmartThings/zigbee-valve/src/sonoff/init.lua
Comment thread drivers/SmartThings/zigbee-valve/src/sonoff/init.lua
device:try_update_metadata({ provisioning_state = "PROVISIONED" })
if device.network_type == st_device.NETWORK_TYPE_ZIGBEE then
device:emit_event(capabilities.valve.valve.closed())
device:emit_event(capabilities.battery.battery(100))

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.

what's the source for the 100% battery.
Battery events should be created as the response for the battery report that comes from device.

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.

We should also not have the valve events emitted without the device telling us. If the device is actually open it would not be accurately reflected in the app for the user.

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.

@yezi289 Please change the code according to provided remarks. Thank You.

Comment on lines +117 to +120
[capabilities.valve.ID] = {
[capabilities.valve.commands.open.NAME] = valve_open_handler,
[capabilities.valve.commands.close.NAME] = valve_close_handler,
}

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.

This should be handled by the framework.
Please check without that handler.

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.

@yezi289 Did You check how Your device works without those handlers ?(default handling should work)

Comment on lines +88 to +97
local function valve_open_handler(driver, device, command)
device:send(OnOff.server.commands.On(device))
device:send(OnOff.attributes.OnOff:read(device))
end

--- valve.close
local function valve_close_handler(driver, device, command)
device:send(OnOff.server.commands.Off(device))
device:send(OnOff.attributes.OnOff:read(device))
end

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.

This should be handled by the framework.
Please check without those handlers.

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.

@yezi289 Please confirm if Your device reports new state itself after the command (without the need to read the attirbute here)

@github-actions

Copy link
Copy Markdown

Profile category check: ✅ Passed - all profiles have a category defined.

@github-actions

Copy link
Copy Markdown

Duplicate profile check: Passed - no duplicate profiles detected.

@github-actions

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

zigbee-valve_coverage.xml

File Coverage
All files 96% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-valve/src/sinope/init.lua 97% ✅
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-valve/src/lazy_load_subdriver.lua 57% ❌
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-valve/src/sonoff/init.lua 93% ✅

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 92b8fbe

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Test Results

   73 files    544 suites   0s ⏱️
3 304 tests 3 303 ✅ 0 💤 1 ❌
5 297 runs  5 296 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 92b8fbe.

♻️ This comment has been updated with latest results.

Comment thread drivers/SmartThings/zigbee-valve/src/sonoff/can_handle.lua Outdated
@yezi289

yezi289 commented Oct 9, 2026

Copy link
Copy Markdown
Author

I tested the updated Edge driver (commit a4565e0) with a physical SONOFF SWV2C on a SmartThings v3 Hub. Both valve channels can be controlled from the SmartThings app, and the app reflects the device-reported valve states. Switching from channel 1 to channel 2 closes channel 1 and opens channel 2 as expected. No device firmware changes were made.

@yezi289

yezi289 commented Oct 10, 2026

Copy link
Copy Markdown
Author

Thank you for the review. I pushed e5e09ae to remove a duplicate health_check assignment reported by Luacheck; this does not change driver behavior. I also checked the Driver Tests failures on the previous commit. The GitHub Actions test results reported 3,294/3,294 passing, and I ran all 44 zigbee-valve tests locally against both the 0.57 and 0.58 Lua libraries, with 44/44 passing on each. The external Jenkins statuses for 57, 58, and dev do not include a log or a link to the failing test cases, so I cannot yet determine whether those failures involve this driver. Could you please share the failing test names/logs, or rerun those checks on this commit? I will address any failures attributable to this PR. Thank you.

@yezi289

yezi289 commented Oct 12, 2026

Copy link
Copy Markdown
Author

Quick update: I merged the current upstream main into this PR. Driver Tests for 57, 58, 59, 60, 61, and dev now all pass. This suggests the earlier 57/58/dev failures were related to the outdated base branch, so the failure logs I requested are no longer needed. This update did not change the SWV2C driver logic or device firmware. Thank you, and I would appreciate a re-review when convenient.

@cjswedes

Copy link
Copy Markdown
Contributor

Conflicts will need to be fixed prior to merging. Note the single failing tests is a known intermittent failure in matter test framework.

@KKlimczukS

Copy link
Copy Markdown
Contributor

@yezi289 since other Sonoff valves were merged lately (#3157) , please update Your branch and resolve conflicts.

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.

5 participants