Skip to content
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

Request to add a Zigbee button for SLED switch #1021

Merged
merged 18 commits into from
Dec 1, 2023
Merged

Request to add a Zigbee button for SLED switch #1021

merged 18 commits into from
Dec 1, 2023

Conversation

seungkwan-choi
Copy link
Contributor

This is a new project for Samsung LED.
It's a ZigBee Button and the model no. is SAMSUNG-ITM-Z-005.
Please review it.

Add  SAMSUNG-ITM-Z-005
SLED profiles for SAMSUNG-ITM-Z-005
Add SLED for SAMSUNG-ITM-Z-005
add SLED for SAMSUNG-ITM-Z-005
add SLED for SAMSUNG-ITM-Z-005
@CLAassistant
Copy link

CLAassistant commented Oct 19, 2023

CLA assistant check
All committers have signed the CLA.

@lelandblue lelandblue added do not merge needs invite link Needs the bestow invite like WWST labels Oct 20, 2023
@github-actions
Copy link

Duplicate profile check: Passed - no duplicate profiles detected.

@github-actions
Copy link

github-actions bot commented Oct 20, 2023

Channel deleted.

@github-actions
Copy link

github-actions bot commented Oct 20, 2023

Test Results

     54 files     346 suites   0s ⏱️
1 621 tests 1 621 ✔️ 0 💤 0
2 848 runs  2 848 ✔️ 0 💤 0

Results for commit 8c6fc70.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Oct 20, 2023

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 8c6fc70

@@ -0,0 +1,93 @@
-- 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

Choose a reason for hiding this comment

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

I will modify it.

Comment on lines 23 to 25
local fields = {
IGNORE_MOVETOCOLORTEMP = "ignore_next_movetocolortemperature"
}
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.

I will delete it.

local comp = device.profile.components[button_name]
if comp ~= nil then
device:emit_component_event(comp, event)
device:emit_event(event)
Copy link
Contributor

Choose a reason for hiding this comment

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

the main component does not have the button capability so this will fail, same below

Choose a reason for hiding this comment

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

Do you mean to delete this code?
Or do you want me to add button from main in profile?
-id: main
capabilities:
- id: button
version: 1

Copy link
Contributor

Choose a reason for hiding this comment

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

Up to you how to implement it. Either of those solutions would work.

In our drivers, we have had the main component of a multi-button device emit an event when any of the buttons are pressed, but some users have found this confusing.

Choose a reason for hiding this comment

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

We will also be confused if we have a main component.
Then please guide me on how to modify the code without main component.
If not, I will add main component.

Copy link
Contributor

Choose a reason for hiding this comment

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

just remove the device:emit_event(event) line

That attempts to emit the event from the main component, which does not have the capability used by the event, and so it would log a warning.

Choose a reason for hiding this comment

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

I will check it after modifying it. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I modified the code, but the held button is not visible, so I am rechecking it.

Copy link
Contributor

@greens greens left a comment

Choose a reason for hiding this comment

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

please includes some tests

I'd at least like a test of the "added" and some of the pressed and pushed events just to verify that you're setting supportedButtonValues correctly.

@lelandblue
Copy link
Contributor

Hello @seungkwan-choi Please see our review, we look forward to your additional changes and thank you.

@greens
Copy link
Contributor

greens commented Oct 25, 2023

Checking drivers/SmartThings/zigbee-button/src/zigbee-multi-button/SLED/init.lua 3 warnings

    drivers/SmartThings/zigbee-button/src/zigbee-multi-button/SLED/init.lua:23:7: (W211) unused variable fields
    drivers/SmartThings/zigbee-button/src/zigbee-multi-button/SLED/init.lua:57:3: (W113) accessing undefined variable do_refresh
    drivers/SmartThings/zigbee-button/src/zigbee-multi-button/SLED/init.lua:66:54: (W113) accessing undefined variable do_refresh

add SLED folder
modify code
@lelandblue lelandblue removed the needs invite link Needs the bestow invite like label Oct 30, 2023
Comment on lines 51 to 53
{ mfr = "Samsung Electronics", model = "SAMSUNG-ITM-Z-005" },
},
SUPPORTED_BUTTON_VALUES = { "pushed" },
Copy link
Contributor

Choose a reason for hiding this comment

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

This is why you're not seeing held events. A supportedButtonValues event needs to be generated for each button component that has the button capability that lists the supported values. Because you've added your device to this list here, the zigbee-multi-button driver's init method only emits a supportedButtonValues event with "pushed" instead of "pushed", "held"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code has been modified. Please review.

@greens
Copy link
Contributor

greens commented Oct 30, 2023

Please also address the luacheck errors I pointed out.

end

local do_configure = function(self, device)
do_refresh(self, device)
Copy link
Contributor

Choose a reason for hiding this comment

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

as pointed out by the luacheck automation, do_refresh is not defined

Choose a reason for hiding this comment

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

lua code has been changed.

Copy link
Contributor

@greens greens left a comment

Choose a reason for hiding this comment

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

I'd like to see some tests of this code, please.

Those tests would have made it even more obvious that you were referencing an undefined value.

Delete do_refresh
NAME = "SLED Button",
capability_handlers = {
[capabilities.refresh.ID] = {
[capabilities.refresh.commands.refresh.NAME] = do_refresh,
Copy link
Contributor

Choose a reason for hiding this comment

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

you are also referencing do_refresh here

Checking drivers/SmartThings/zigbee-button/src/zigbee-multi-button/SLED/init.lua 3 warnings

    drivers/SmartThings/zigbee-button/src/zigbee-multi-button/SLED/init.lua:30:45: (W612) line contains trailing whitespace
    drivers/SmartThings/zigbee-button/src/zigbee-multi-button/SLED/init.lua:44:45: (W612) line contains trailing whitespace
    drivers/SmartThings/zigbee-button/src/zigbee-multi-button/SLED/init.lua:59:54: (W113) accessing undefined variable do_refresh

Please address these comments. Please write some tests for this behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code was modified and there were no errors through lua check.

lelandblue and others added 3 commits November 1, 2023 21:17
modify lua file(delete do_refresh)
 Change whitespace
@@ -25,6 +25,7 @@ local devices = {
{ mfr = "CentraLite", model = "3450-L" },
{ mfr = "CentraLite", model = "3450-L2" },
{ mfr = "ROBB smarrt", model = "ROB_200-008-0" }

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please remove this extra line that is empty?

Choose a reason for hiding this comment

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

Remove the extra line.

end
end


Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this is extra whitespace as well that needs to be removed, please review.

Choose a reason for hiding this comment

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

Remove the extra line

@@ -24,7 +24,7 @@ local devices = {
MATCHING_MATRIX = {
{ mfr = "CentraLite", model = "3450-L" },
{ mfr = "CentraLite", model = "3450-L2" },
{ mfr = "ROBB smarrt", model = "ROB_200-008-0" }
{ mfr = "ROBB smarrt", model = "ROB_200-008-0" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{ mfr = "ROBB smarrt", model = "ROB_200-008-0" }
{ mfr = "ROBB smarrt", model = "ROB_200-008-0" }

Choose a reason for hiding this comment

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

if you delete and change the whitespace in the code, it will not be saved and it will be shown to request a creat pull request patch.
Please check it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what you mean.

Choose a reason for hiding this comment

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

Remove the whitespace.

@@ -39,7 +39,8 @@ local ZIGBEE_MULTI_BUTTON_FINGERPRINTS = {
{ mfr = "ShinaSystem", model = "SBM300ZB3" },
{ mfr = "ROBB smarrt", model = "ROB_200-007-0" },
{ mfr = "ROBB smarrt", model = "ROB_200-008-0" },
{ mfr = "WALL HERO", model = "ACL-401SCA4" }
{ mfr = "WALL HERO", model = "ACL-401SCA4" },
{ mfr = "Samsung Electronics", model = "SAMSUNG-ITM-Z-005" },
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{ mfr = "Samsung Electronics", model = "SAMSUNG-ITM-Z-005" },
{ mfr = "Samsung Electronics", model = "SAMSUNG-ITM-Z-005" }

Choose a reason for hiding this comment

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

if you delete and change the comma in the code, it will not be saved and it will be shown to request a creat pull request patch.
Please check it.

Choose a reason for hiding this comment

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

Remove the comma.

@lelandblue lelandblue merged commit 75ac77e into SmartThingsCommunity:main Dec 1, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants