Skip to content

SONOFF/SWV1C - #3157

Open
yanggx24 wants to merge 2 commits into
SmartThingsCommunity:mainfrom
yanggx24:main
Open

SONOFF/SWV1C#3157
yanggx24 wants to merge 2 commits into
SmartThingsCommunity:mainfrom
yanggx24:main

Conversation

@yanggx24

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

@@ -0,0 +1,14 @@
name: sonoff-irrigation

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.

Please rename this profile to valve-battery

Comment on lines +1 to +6
--[[
Description: SONOFF Water Valve sub-driver for zigbee-valve
Version: 1.2
Author: guoxin.yang
Date: 2026-07-06
--]]

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.

Please change this comment to:

-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local PowerConfiguration = zcl_clusters.PowerConfiguration
local utils = require "st.utils"

-- 电池轮询间隔(秒):SWV1C 是电池休眠设备,每 2 小时轮询一次

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.

Please use english language in You comments (remark applies to all files)

-- 电池轮询间隔(秒):SWV1C 是电池休眠设备,每 2 小时轮询一次
local BATTERY_POLL_INTERVAL = 7200

-- SWV1C 设备指纹匹配表

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.

Please use english language in You comments (remark applies to all files)

Comment on lines +24 to +26
--- OnOff 属性上报处理器 → valve 能力点事件
--- 必须显式处理,因为子驱动定义了 capability_handlers 后,
--- 父驱动的默认 OnOff→valve 映射会被跳过(只剩 OnOff→switch)

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.

Please use english language in You comments (remark applies to all files)

device:send(OnOff.attributes.OnOff:read(device))
end

--- valve.close 能力点处理器

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.

Please use english language in You comments (remark applies to all files)

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.

Please use english language in You comments (remark applies to all files)

},
zigbee_handlers = {
attr = {
-- OnOff 属性上报 → valve 事件(弥补父驱动默认映射被跳过的缺陷)

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.

Please use english language in You comments (remark applies to all files)

[OnOff.ID] = {
[OnOff.attributes.OnOff.ID] = onoff_attr_handler
},
-- 电池百分比属性上报 → battery 事件

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.

Please use english language in You comments (remark applies to all files)

Comment on lines +1 to +13
-- Copyright 2022 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.

Please change this comment to:

-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

Comment on lines +101 to +105
[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.

Did You check if Your device works with the zigbe-valve driver default handling ? (without this custom handling)

Comment on lines +109 to +111
[OnOff.ID] = {
[OnOff.attributes.OnOff.ID] = onoff_attr_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.

Did You check if Your device works with the zigbe-valve driver default handling ? (without this custom handling)

@github-actions

Copy link
Copy Markdown

Duplicate profile check: Passed - no duplicate profiles detected.

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

zigbee-valve_coverage.xml

File Coverage
All files 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-valve/src/sonoff/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-valve/src/sinope/init.lua 97%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against d3ca759

@github-actions

Copy link
Copy Markdown

Test Results

   73 files    541 suites   0s ⏱️
3 246 tests 3 240 ✅ 0 💤  6 ❌
5 243 runs  5 233 ✅ 0 💤 10 ❌

For more details on these failures, see this check.

Results for commit d3ca759.

@KKlimczukS
KKlimczukS requested a review from cbaumler July 31, 2026 09:59
@yanggx24

yanggx24 commented Aug 1, 2026

Copy link
Copy Markdown
Author

Thanks for the review.

Yes, I checked this behavior with the SONOFF SWV1C device. The device uses the Zigbee OnOff cluster for valve control and reports the valve state through the OnOff attribute.

The custom handlers were added to explicitly map:

  • valve.open / valve.close commands to Zigbee OnOff On / Off
  • OnOff attribute reports back to SmartThings valve.open / valve.closed events

This is also needed because the device reports the OnOff value as ZCL_DATA_TYPE_UINT8. In Lua, numeric 0 is truthy, so the handler explicitly checks for false and 0 to avoid treating an OFF report as open.

I can also re-test without the custom handlers and confirm whether the default zigbee-valve handling covers this device correctly.

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.

2 participants