Skip to content

Conversation

simon3panda
Copy link
Contributor

Linxura Zigbee mode include 4 buttons, each button support press, double press, held.

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

New sub-driver for zigbee button, which support four buttons, each support press, double press, held.

Summary of Completed Tests

Linxura Zigbee mode include 4 buttons, each button support press, double press, held.
@CLAassistant
Copy link

CLAassistant commented Dec 17, 2024

CLA assistant check
All committers have signed the CLA.

add configuration part for Linxura smart controller driver
@simon3panda
Copy link
Contributor Author

Does anything I need to do, before anyone can review this request?

Remove main button info in device panel. So user could only see four buttons information.
Remove firmwareUpdate on profile.
Add Aura smart button device.
@@ -0,0 +1,129 @@
-- Copyright 2022 SmartThings
Copy link
Contributor

Choose a reason for hiding this comment

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

date should be 2024, I think?

Copy link
Contributor

Choose a reason for hiding this comment

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

We use 2-space tabs in our drivers. You've got a mix here of 2- and 4-spaces.

local IASZone = (require "st.zigbee.zcl.clusters").IASZone
local constants = require "st.zigbee.constants"
local clusters = require "st.zigbee.zcl.clusters"
local Groups = clusters.Groups
Copy link
Contributor

Choose a reason for hiding this comment

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

unused

Choose a reason for hiding this comment

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

local capabilities = require "st.capabilities"
local IASZone = (require "st.zigbee.zcl.clusters").IASZone
local log = require "log"
Remain these three lines.


local capabilities = require "st.capabilities"
local IASZone = (require "st.zigbee.zcl.clusters").IASZone
local constants = require "st.zigbee.constants"
Copy link
Contributor

Choose a reason for hiding this comment

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

unused

Choose a reason for hiding this comment

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

local capabilities = require "st.capabilities"
local IASZone = (require "st.zigbee.zcl.clusters").IASZone
local log = require "log"
Remain these three lines.

Comment on lines 21 to 23
local device_management = require "st.zigbee.device_management"
local zcl_commands = require "st.zigbee.zcl.global_commands"
local zcl_clusters = require "st.zigbee.zcl.clusters"
Copy link
Contributor

Choose a reason for hiding this comment

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

unused

Choose a reason for hiding this comment

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

The same as comment above.


if status.value == BUTTON1_HELD or status.value == BUTTON1_PUSHED or status.value == BUTTON1_DOUBLE then
device:emit_component_event(device.profile.components[BUTTON1], event)
device:emit_event(event)
Copy link
Contributor

@greens greens Mar 19, 2025

Choose a reason for hiding this comment

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

this will log an error every time since main has no button capability

Choose a reason for hiding this comment

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

Removed.
device:emit_event(event)

return false
end

if status.value == BUTTON1_HELD or status.value == BUTTON1_PUSHED or status.value == BUTTON1_DOUBLE then
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd just use the // (integer division) operator to determine the button, e.g.:

if (event) then
  button = string.format("button%d", status.value // 6 + 1)
  device:emit_component_event(device.profile.components[button], event)
end

Choose a reason for hiding this comment

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

Thank you, modified.

elseif mod == 5 then
event = capabilities.button.button.held(additional_fields)
else
return false
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you just want a void return here. Not sure how the runner would interpret a false value being returned.

Choose a reason for hiding this comment

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

Modified.
local mod = status.value % 6
if mod == 1 then
event = capabilities.button.button.pushed(additional_fields)
elseif mod == 3 then
event = capabilities.button.button.double(additional_fields)
elseif mod == 5 then
event = capabilities.button.button.held(additional_fields)
end

@xiaodah123
Copy link

Thank you for your suggestion, all modification has been uploaded.

@greens
Copy link
Contributor

greens commented Mar 20, 2025

@xiaodah123 @simon3panda perhaps you forgot to push to your branch? You will also need to re-base your branch to resolve the conflicts.

@simon3panda
Copy link
Contributor Author

@xiaodah123 @simon3panda perhaps you forgot to push to your branch? You will also need to re-base your branch to resolve the conflicts.

Thank you!
We are new on this.
We‘ve re-base to Linxura_test and publish the branch.
image
What else we need to do?

@simon3panda
Copy link
Contributor Author

Do I need to click 'Force push' to Current branch?
image

@simon3panda
Copy link
Contributor Author

I Clicked 'Resolve conflict' button and modified file, can I click the 'Commit Merge' button?
image

image

Copy link

Duplicate profile check: Passed - no duplicate profiles detected.

Copy link

github-actions bot commented Mar 25, 2025

Channel deleted.

Comment on lines 19 to 35
local BUTTON1_HELD = 0x0001
local BUTTON1_PUSHED = 0x0003
local BUTTON1_DOUBLE = 0x0005
local BUTTON2_HELD = 0x0007
local BUTTON2_PUSHED = 0x0009
local BUTTON2_DOUBLE = 0x000B
local BUTTON3_HELD = 0x000D
local BUTTON3_PUSHED = 0x000F
local BUTTON3_DOUBLE = 0x0011
local BUTTON4_HELD = 0x00013
local BUTTON4_PUSHED = 0x00015
local BUTTON4_DOUBLE = 0x0017

local BUTTON1 = "button1"
local BUTTON2 = "button2"
local BUTTON3 = "button3"
local BUTTON4 = "button4"
Copy link
Contributor

Choose a reason for hiding this comment

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

these can all be removed now I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, removed.

Copy link

github-actions bot commented Mar 25, 2025

Test Results

   65 files    421 suites   0s ⏱️
2 141 tests 2 141 ✅ 0 💤 0 ❌
3 668 runs  3 668 ✅ 0 💤 0 ❌

Results for commit e5ba868.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Mar 25, 2025

File Coverage
All files 97%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/adurosmart/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/somfy/somfy_situo_4.lua 98%
/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/ecosmart/init.lua 98%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/ikea/TRADFRI_remote_control.lua 98%
/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/supported_values.lua 99%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/init.lua 94%
/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/button_utils.lua 92%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/init.lua 97%
/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/iris/init.lua 90%
/home/runner/work/SmartThingsEdgeDrivers/SmartThingsEdgeDrivers/drivers/SmartThings/zigbee-button/src/frient/init.lua 93%
/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/wallhero/init.lua 88%
/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 e5ba868

@greens
Copy link
Contributor

greens commented Mar 25, 2025

It would be good if you added some tests of your device's specific behavior. A good template would be this test file, which also bases its behavior off the value of the IAS Zone attribute: https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/main/drivers/SmartThings/zigbee-motion-sensor/src/test/test_gator_motion.lua

@simon3panda
Copy link
Contributor Author

It would be good if you added some tests of your device's specific behavior. A good template would be this test file, which also bases its behavior off the value of the IAS Zone attribute: https://github.com/SmartThingsCommunity/SmartThingsEdgeDrivers/blob/main/drivers/SmartThings/zigbee-motion-sensor/src/test/test_gator_motion.lua

Tests added and uploaded. By the way is there any way for me to run the tests?

@greens
Copy link
Contributor

greens commented Mar 26, 2025

@simon3panda Yep. Assuming you've set up you dev environment following the instructions here: https://developer.smartthings.com/docs/devices/hub-connected/set-up-dev-env

Once you've done that, you can navigate in your terminal to the src directory of the specific driver and then just run lua test/[test_file_name].lua to run the tests locally.

ZoneStatusAttribute:build_test_attr_report(mock_device, 3 + var * 6)
})
test.socket.capability:__expect_send(
mock_device:generate_test_message(string.format("button%d", var + 1), button_attr.double({ state_change = true }))
Copy link
Contributor

Choose a reason for hiding this comment

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

button_attr is undefined in the test file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

button_attr is undefined in the test file

Ok, add definition.

@simon3panda
Copy link
Contributor Author

@simon3panda Yep. Assuming you've set up you dev environment following the instructions here: https://developer.smartthings.com/docs/devices/hub-connected/set-up-dev-env

Once you've done that, you can navigate in your terminal to the src directory of the specific driver and then just run lua test/[test_file_name].lua to run the tests locally.

Thank you. Tests ran. Tests result are in the attaches.
aura_result.txt
linxura_result.txt

@greens greens merged commit aea67b3 into SmartThingsCommunity:main Apr 24, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants