-
Notifications
You must be signed in to change notification settings - Fork 469
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
Changes from 13 commits
3c764ee
24991db
796cb08
25babb2
c061c35
8de812e
ac22da1
53e712e
147a81d
52d8acc
004e813
e01baca
b0efd4a
3008cf0
71953d9
fe0a38a
e3c4c17
8c6fc70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: SLED-three-buttons | ||
components: | ||
- id: main | ||
capabilities: | ||
- id: firmwareUpdate | ||
version: 1 | ||
- id: refresh | ||
version: 1 | ||
categories: | ||
- name: RemoteController | ||
- id: button1 | ||
capabilities: | ||
- id: button | ||
version: 1 | ||
categories: | ||
- name: RemoteController | ||
- id: button2 | ||
capabilities: | ||
- id: button | ||
version: 1 | ||
categories: | ||
- name: RemoteController | ||
- id: button3 | ||
capabilities: | ||
- id: button | ||
version: 1 | ||
categories: | ||
- name: RemoteController |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
-- Copyright 2023 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. | ||
|
||
local capabilities = require "st.capabilities" | ||
local clusters = require "st.zigbee.zcl.clusters" | ||
local device_management = require "st.zigbee.device_management" | ||
local log = require "log" | ||
local Level = clusters.Level | ||
local OnOff = clusters.OnOff | ||
local ColorControl = clusters.ColorControl | ||
|
||
local emit_pushed_event = function(button_name, device) | ||
local additional_fields = { | ||
state_change = true | ||
} | ||
local event = capabilities.button.button.pushed(additional_fields) | ||
local comp = device.profile.components[button_name] | ||
if comp ~= nil then | ||
device:emit_component_event(comp, event) | ||
else | ||
log.warn("Attempted to emit button event for unknown button: " .. button_name) | ||
end | ||
end | ||
|
||
|
||
local emit_held_event = function(button_name, device) | ||
local additional_fields = { | ||
state_change = true | ||
} | ||
local event = capabilities.button.button.held(additional_fields) | ||
local comp = device.profile.components[button_name] | ||
if comp ~= nil then | ||
device:emit_component_event(comp, event) | ||
else | ||
log.warn("Attempted to emit button event for unknown button: " .. button_name) | ||
end | ||
end | ||
|
||
local do_configure = function(self, device) | ||
device:send(device_management.build_bind_request(device, OnOff.ID, self.environment_info.hub_zigbee_eui)) | ||
-- The device reports button presses to this group but it can't be read from the binding table | ||
end | ||
|
||
local SLED_button = { | ||
NAME = "SLED Button", | ||
zigbee_handlers = { | ||
cluster = { | ||
[OnOff.ID] = { | ||
[OnOff.server.commands.Off.ID] = function(driver, device, zb_rx) emit_pushed_event("button2", device) end, | ||
[OnOff.server.commands.On.ID] = function(driver, device, zb_rx) emit_pushed_event("button1", device) end, | ||
[OnOff.server.commands.Toggle.ID] = function(driver, device, zb_rx) emit_pushed_event("button3", device) end | ||
}, | ||
[Level.ID] = { | ||
[Level.server.commands.Move.ID] = function(driver, device, zb_rx) emit_held_event("button2", device) end, | ||
[Level.server.commands.MoveWithOnOff.ID] = function(driver, device, zb_rx) emit_held_event("button1", device) end | ||
}, | ||
[ColorControl.ID] = { | ||
[ColorControl.server.commands.MoveToColorTemperature.ID] = function(driver, device, zb_rx) emit_held_event("button3", device) end | ||
} | ||
} | ||
}, | ||
lifecycle_handlers = { | ||
doConfigure = do_configure | ||
}, | ||
can_handle = function(opts, driver, device, ...) | ||
return device:get_manufacturer() == "Samsung Electronics" and device:get_model() == "SAMSUNG-ITM-Z-005" | ||
end | ||
} | ||
|
||
return SLED_button |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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" }, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the comma. |
||||||
} | ||||||
|
||||||
local function can_handle_zigbee_multi_button(opts, driver, device, ...) | ||||||
|
@@ -86,6 +87,7 @@ local zigbee_multi_button = { | |||||
require("zigbee-multi-button.shinasystems"), | ||||||
require("zigbee-multi-button.robb"), | ||||||
require("zigbee-multi-button.wallhero"), | ||||||
require("zigbee-multi-button.SLED") | ||||||
} | ||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ local devices = { | |
{ mfr = "CentraLite", model = "3450-L" }, | ||
{ mfr = "CentraLite", model = "3450-L2" }, | ||
{ mfr = "ROBB smarrt", model = "ROB_200-008-0" } | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we please remove this extra line that is empty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the extra line. |
||
}, | ||
SUPPORTED_BUTTON_VALUES = { "pushed", "held" }, | ||
NUMBER_OF_BUTTONS = 4 | ||
|
@@ -52,6 +53,13 @@ local devices = { | |
SUPPORTED_BUTTON_VALUES = { "pushed" }, | ||
NUMBER_OF_BUTTONS = 3 | ||
}, | ||
BUTTON_PUSH_HELD_3 = { | ||
MATCHING_MATRIX = { | ||
{ mfr = "Samsung Electronics", model = "SAMSUNG-ITM-Z-005" }, | ||
}, | ||
SUPPORTED_BUTTON_VALUES = { "pushed", "held" }, | ||
NUMBER_OF_BUTTONS = 3 | ||
}, | ||
BUTTON_PUSH_4 = { | ||
MATCHING_MATRIX = { | ||
{ mfr = "LDS", model = "ZBT-CCTSwitch-D0001" }, | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the extra line