-
Notifications
You must be signed in to change notification settings - Fork 498
Pull request for zunzunbee Slate Switch zigbee button edge driver #2224
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
toaf2022
wants to merge
7
commits into
SmartThingsCommunity:main
Choose a base branch
from
toaf2022:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e3a82e7
New zigbee multi button edge driver
toaf2022 72ee0ad
Merge branch 'main' of https://github.com/toaf2022/SmartThingsEdgeDri…
toaf2022 7810338
Updates based on #2224
toaf2022 dae4a0e
Merge branch 'main' into main
toaf2022 924c8e9
Lint warning fixes for PR#2224
toaf2022 40e5550
Merge branch 'main' into main
toaf2022 9106a02
Slate Switch: New Zigbee multi button: Code cleanup (#2224)
toaf2022 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
drivers/SmartThings/zigbee-button/profiles/eight-buttons-temp-battery.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: eight-buttons-temp-battery | ||
components: | ||
- id: main | ||
capabilities: | ||
- id: button | ||
version: 1 | ||
- id: battery | ||
version: 1 | ||
- id: tone | ||
version: 1 | ||
- id: firmwareUpdate | ||
version: 1 | ||
- id: refresh | ||
version: 1 | ||
- id: temperatureMeasurement | ||
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 | ||
- id: button4 | ||
capabilities: | ||
- id: button | ||
version: 1 | ||
categories: | ||
- name: RemoteController | ||
- id: button5 | ||
capabilities: | ||
- id: button | ||
version: 1 | ||
categories: | ||
- name: RemoteController | ||
- id: button6 | ||
capabilities: | ||
- id: button | ||
version: 1 | ||
categories: | ||
- name: RemoteController | ||
- id: button7 | ||
capabilities: | ||
- id: button | ||
version: 1 | ||
categories: | ||
- name: RemoteController | ||
- id: button8 | ||
capabilities: | ||
- id: button | ||
version: 1 | ||
categories: | ||
- name: RemoteController | ||
metadata: | ||
mnmn: SmartThingsCommunity | ||
vid: b85e2d6f-0ea4-38e2-b5f4-31c3873b1920 | ||
preferences: | ||
- preferenceId: tempOffset | ||
explicit: true |
206 changes: 206 additions & 0 deletions
206
drivers/SmartThings/zigbee-button/src/test/test_zunzunbee_8_button.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,206 @@ | ||
-- Copyright 2025 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. | ||
|
||
-- Mock out globals | ||
local test = require "integration_test" | ||
local clusters = require "st.zigbee.zcl.clusters" | ||
local IASZone = clusters.IASZone | ||
local PowerConfiguration = clusters.PowerConfiguration | ||
local TemperatureMeasurement = clusters.TemperatureMeasurement | ||
local IasEnrollResponseCode = IASZone.types.EnrollResponseCode | ||
|
||
local capabilities = require "st.capabilities" | ||
local zigbee_test_utils = require "integration_test.zigbee_test_utils" | ||
local t_utils = require "integration_test.utils" | ||
|
||
local ZoneStatusAttribute = IASZone.attributes.ZoneStatus | ||
local button_attr = capabilities.button.button | ||
|
||
local mock_device = test.mock_device.build_test_zigbee_device( | ||
{ | ||
profile = t_utils.get_profile_definition("eight-buttons-temp-battery.yml"), | ||
zigbee_endpoints = { | ||
[1] = { | ||
id = 1, | ||
manufacturer = "zunzunbee", | ||
model = "SSWZ8T", | ||
server_clusters = {0x0000, 0x0001, 0x0003, 0x0020, 0x0402, 0x0500} | ||
} | ||
} | ||
} | ||
) | ||
|
||
zigbee_test_utils.prepare_zigbee_env_info() | ||
local function test_init() | ||
test.mock_device.add_test_device(mock_device) | ||
zigbee_test_utils.init_noop_health_check_timer() | ||
end | ||
|
||
test.set_test_init_function(test_init) | ||
|
||
test.register_coroutine_test( | ||
"added lifecycle event", | ||
function() | ||
test.socket.capability:__set_channel_ordering("relaxed") | ||
for button_name, _ in pairs(mock_device.profile.components) do | ||
if button_name ~= "main" then | ||
test.socket.capability:__expect_send( | ||
mock_device:generate_test_message( | ||
button_name, | ||
capabilities.button.supportedButtonValues({ "pushed", "held"}, { visibility = { displayed = false } }) | ||
) | ||
) | ||
test.socket.capability:__expect_send( | ||
mock_device:generate_test_message( | ||
button_name, | ||
capabilities.button.numberOfButtons({ value = 1 }, { visibility = { displayed = false } }) | ||
) | ||
) | ||
end | ||
end | ||
test.socket.capability:__expect_send( | ||
mock_device:generate_test_message( | ||
"main", | ||
capabilities.button.supportedButtonValues({ "pushed", "held" }, { visibility = { displayed = false } }) | ||
) | ||
) | ||
test.socket.capability:__expect_send( | ||
mock_device:generate_test_message( | ||
"main", | ||
capabilities.button.numberOfButtons({ value = 8 }, { visibility = { displayed = false } }) | ||
) | ||
) | ||
test.socket.capability:__expect_send({ | ||
mock_device.id, | ||
{ | ||
capability_id = "button", component_id = "main", | ||
attribute_id = "button", state = { value = "pushed" } | ||
} | ||
}) | ||
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "added" }) | ||
test.wait_for_events() | ||
end | ||
) | ||
|
||
test.register_coroutine_test( | ||
"Configure should configure all necessary attributes", | ||
function() | ||
test.socket.device_lifecycle:__queue_receive({ mock_device.id, "doConfigure" }) | ||
test.socket.zigbee:__set_channel_ordering("relaxed") | ||
test.socket.zigbee:__expect_send({ | ||
mock_device.id, | ||
PowerConfiguration.attributes.BatteryPercentageRemaining:read(mock_device) | ||
}) | ||
test.socket.zigbee:__expect_send({ | ||
mock_device.id, | ||
TemperatureMeasurement.attributes.MeasuredValue:read(mock_device) | ||
}) | ||
test.socket.zigbee:__expect_send({ | ||
mock_device.id, | ||
IASZone.attributes.ZoneStatus:read(mock_device) | ||
}) | ||
|
||
test.socket.zigbee:__expect_send({ | ||
mock_device.id, | ||
zigbee_test_utils.build_bind_request( | ||
mock_device, | ||
zigbee_test_utils.mock_hub_eui, | ||
PowerConfiguration.ID | ||
) | ||
}) | ||
test.socket.zigbee:__expect_send({ | ||
mock_device.id, | ||
zigbee_test_utils.build_bind_request( | ||
mock_device, | ||
zigbee_test_utils.mock_hub_eui, | ||
TemperatureMeasurement.ID | ||
) | ||
}) | ||
test.socket.zigbee:__expect_send({ | ||
mock_device.id, | ||
PowerConfiguration.attributes.BatteryPercentageRemaining:configure_reporting( | ||
mock_device, 30, 21600, 02 | ||
) | ||
}) | ||
test.socket.zigbee:__expect_send({ | ||
mock_device.id, | ||
TemperatureMeasurement.attributes.MeasuredValue:configure_reporting( | ||
mock_device, 30, 600, 100 | ||
) | ||
}) | ||
test.socket.zigbee:__expect_send({ | ||
mock_device.id, | ||
IASZone.attributes.IASCIEAddress:write(mock_device, zigbee_test_utils.mock_hub_eui) | ||
}) | ||
test.socket.zigbee:__expect_send({ | ||
mock_device.id, | ||
IASZone.server.commands.ZoneEnrollResponse(mock_device, IasEnrollResponseCode.SUCCESS, 0x00) | ||
}) | ||
mock_device:expect_metadata_update({ provisioning_state = "PROVISIONED" }) | ||
end | ||
) | ||
|
||
test.register_coroutine_test( | ||
"Test cases for Buttons Pushed", | ||
function() | ||
for var = 1, 8 do | ||
test.socket.zigbee:__queue_receive({ | ||
mock_device.id, | ||
ZoneStatusAttribute:build_test_attr_report(mock_device, 1<<var) | ||
}) | ||
test.socket.capability:__expect_send( | ||
mock_device:generate_test_message( | ||
"main", | ||
capabilities.button.numberOfButtons({ value = 1 }, { visibility = { displayed = true } }) | ||
) | ||
) | ||
test.socket.capability:__expect_send( | ||
mock_device:generate_test_message(string.format("button%d", var), button_attr.pushed({ state_change = true })) | ||
) | ||
test.socket.capability:__expect_send( | ||
mock_device:generate_test_message(string.format("main", var), button_attr.pushed({ state_change = true })) | ||
) | ||
test.wait_for_events() | ||
end | ||
end | ||
) | ||
|
||
|
||
test.register_coroutine_test( | ||
"Test cases for Buttons Held", | ||
function() | ||
for var = 1, 8 do | ||
test.socket.zigbee:__queue_receive({ | ||
mock_device.id, | ||
ZoneStatusAttribute:build_test_attr_report(mock_device, ((1<<var )| 1)) | ||
}) | ||
test.socket.capability:__expect_send( | ||
mock_device:generate_test_message( | ||
"main", | ||
capabilities.button.numberOfButtons({ value = 1 }, { visibility = { displayed = true } }) | ||
) | ||
) | ||
test.socket.capability:__expect_send( | ||
mock_device:generate_test_message(string.format("button%d", var), button_attr.held({ state_change = true })) | ||
) | ||
test.socket.capability:__expect_send( | ||
mock_device:generate_test_message(string.format("main", var), button_attr.held({ state_change = true })) | ||
) | ||
test.wait_for_events() | ||
end | ||
end | ||
) | ||
|
||
|
||
test.run_registered_tests() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.