Skip to content

add support for tuya devices #2102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pInksenberg
Copy link
Contributor

@pInksenberg pInksenberg commented Apr 29, 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

add support for tuya devices

Summary of Completed Tests

Copy link

Duplicate profile check: Passed - no duplicate profiles detected.

Copy link

github-actions bot commented Apr 29, 2025

Test Results

   67 files    432 suites   0s ⏱️
2 214 tests 2 214 ✅ 0 💤 0 ❌
3 788 runs  3 788 ✅ 0 💤 0 ❌

Results for commit 5b9c034.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Apr 29, 2025

File Coverage
All files 99%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/Unofficial/tuya-zigbee/src/smoke-detector/init.lua 96%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/Unofficial/tuya-zigbee/src/curtain/init.lua 96%

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 5b9c034

@pInksenberg pInksenberg force-pushed the add_support_for_tuya_devices branch from ba8b84d to f822692 Compare April 29, 2025 05:20
Comment on lines 76 to 78
supported_capabilities = {
capabilities.button
},
Copy link
Contributor

Choose a reason for hiding this comment

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

this field doesn't do anything in sub-drivers

@pInksenberg pInksenberg force-pushed the add_support_for_tuya_devices branch from f822692 to 7b0383c Compare April 30, 2025 02:08
@pInksenberg pInksenberg force-pushed the add_support_for_tuya_devices branch 3 times, most recently from 80f6709 to 41fd4b1 Compare May 13, 2025 12:21
@pInksenberg
Copy link
Contributor Author

@inasail revise finished

-- limitations under the License.

local capabilities = require "st.capabilities"
local OnOff = (require "st.zigbee.zcl.clusters").OnOff
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there any meaning about brackets?
I think below way is more common that is used better in other drivers.

local clusters = require "st.zigbee.zcl.clusters"
local OnOff = clusters.OnOff

Copy link

Choose a reason for hiding this comment

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

Thank you for your comment, we will change it

-- reverse direction
if reverseCurtainDirectionPrefValue == true then
tuya_utils.send_tuya_command(device, '\x05', tuya_utils.DP_TYPE_ENUM, '\x01', packet_id)
packet_id = (packet_id + 1) % 65536
Copy link
Collaborator

Choose a reason for hiding this comment

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

why don't you make a function like below?

function increase_packet_id()
  packet_id = (packet_id + 1) % 65536
end

Copy link

Choose a reason for hiding this comment

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

That will be better, we will modify

local function tuya_cluster_handler(driver, device, zb_rx)
local window_shade_level_event, window_shade_val_event
local raw = zb_rx.body.zcl_body.body_bytes
local dp = raw:byte(3)
Copy link
Collaborator

@kdbang kdbang May 14, 2025

Choose a reason for hiding this comment

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

what means dp? data point? can you explain the variable name?

Copy link

Choose a reason for hiding this comment

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

Yes, that means data ponit, it is a Tuya data payload, we will explain it in our code.

device:send(device_management.build_bind_request(device, Basic.ID, driver.environment_info.hub_zigbee_eui))
end

local function tuya_cluster_handler(driver, device, zb_rx)
Copy link
Collaborator

@kdbang kdbang May 14, 2025

Choose a reason for hiding this comment

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

if possible, why don't you move all tuay_cluster_handler()s to tuya_utils.lua?

Copy link

Choose a reason for hiding this comment

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

After investigating about Tuya devices, each Tuya device has its specific tuay_cluster_handler() logic, so it is hard for us to move all tuay_cluster_handler()s to tuya_utils.lua

@pInksenberg pInksenberg force-pushed the add_support_for_tuya_devices branch 2 times, most recently from 2484a39 to d653ba0 Compare May 14, 2025 05:39
@pInksenberg pInksenberg force-pushed the add_support_for_tuya_devices branch from d653ba0 to 5b9c034 Compare May 14, 2025 05:40
Copy link
Collaborator

@kdbang kdbang left a comment

Choose a reason for hiding this comment

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

LGTM

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.

4 participants