-
Notifications
You must be signed in to change notification settings - Fork 532
support thirdreality smart button zb2 #2890
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
weihuan1111
wants to merge
5
commits into
SmartThingsCommunity:main
Choose a base branch
from
weihuan1111:3RSB01085Z
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
5 commits
Select commit
Hold shift + click to select a range
da495a0
support thirdreality smart button zb2
weihuan1111 f642c07
Update can_handle.lua
weihuan1111 a489ee6
Update init.lua
weihuan1111 42284fb
Merge branch 'main' into 3RSB01085Z
weihuan1111 c7a2fe4
Merge branch 'main' into 3RSB01085Z
weihuan1111 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
30 changes: 30 additions & 0 deletions
30
drivers/SmartThings/zigbee-button/profiles/thirdreality-three-button.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,30 @@ | ||
| name: thirdreality-three-button | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: battery | ||
| version: 1 | ||
| - 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 |
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
11 changes: 11 additions & 0 deletions
11
drivers/SmartThings/zigbee-button/src/thirdreality-zb2/can_handle.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,11 @@ | ||
| -- Copyright 2025 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local function thirdreality_zb2_can_handle(opts, driver, device, ...) | ||
| if device:get_manufacturer() == "Third Reality, Inc" and device:get_model() == "3RSB01085Z" then | ||
| return true, require("thirdreality-zb2") | ||
| end | ||
| return false | ||
| end | ||
|
|
||
| return thirdreality_zb2_can_handle |
64 changes: 64 additions & 0 deletions
64
drivers/SmartThings/zigbee-button/src/thirdreality-zb2/init.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,64 @@ | ||
| local capabilities = require "st.capabilities" | ||
|
|
||
| local MULTISTATE_INPUT_CLUSTER_ID = 0x0012 | ||
| local PRESENT_VALUE_ATTR_ID = 0x0055 | ||
|
|
||
| local HELD = 0x0000 | ||
| local PUSHED = 0x0001 | ||
| local DOUBLE = 0x0002 | ||
|
|
||
| local COMPONENT_MAP = { | ||
| [1] = "button1", | ||
| [2] = "button2", | ||
| [3] = "button3" | ||
| } | ||
|
|
||
| local function present_value_attr_handler(driver, device, value, zb_rx) | ||
| local event | ||
|
|
||
| if value.value == PUSHED then | ||
| event = capabilities.button.button.pushed({ state_change = true }) | ||
| elseif value.value == DOUBLE then | ||
| event = capabilities.button.button.double({ state_change = true }) | ||
| elseif value.value == HELD then | ||
| event = capabilities.button.button.held({ state_change = true }) | ||
| end | ||
|
|
||
| if not event then return end | ||
|
|
||
| local ep = zb_rx.address_header.src_endpoint.value | ||
| local component_id = COMPONENT_MAP[ep] | ||
|
|
||
| if component_id and device.profile.components[component_id] then | ||
| device:emit_component_event(device.profile.components[component_id], event) | ||
| end | ||
| end | ||
|
|
||
| local function device_added(driver, device) | ||
| local supported = { "pushed", "double", "held" } | ||
|
|
||
| for ep, comp_id in pairs(COMPONENT_MAP) do | ||
| local comp = device.profile.components[comp_id] | ||
| if comp then | ||
| device:emit_component_event(comp, capabilities.button.supportedButtonValues(supported, { visibility = { displayed = false } })) | ||
| device:emit_component_event(comp, capabilities.button.numberOfButtons({ value = 1 })) | ||
| end | ||
| end | ||
| end | ||
|
|
||
| local thirdreality_3button_handler = { | ||
| NAME = "ThirdReality Smart Button ZB2", | ||
| lifecycle_handlers = { | ||
| added = device_added | ||
| }, | ||
| zigbee_handlers = { | ||
| attr = { | ||
| [MULTISTATE_INPUT_CLUSTER_ID] = { | ||
| [PRESENT_VALUE_ATTR_ID] = present_value_attr_handler | ||
| } | ||
| } | ||
| }, | ||
| can_handle = require("thirdreality-zb2.can_handle"), | ||
| } | ||
|
|
||
| return thirdreality_3button_handler |
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.
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.
There is already a
three-buttons-batteryprofile, does not look like there is a need to create a specific profile. The convention for Zigbee buttons has always been thatmaincomponent acts as a catch-all so any event emitted for other components has to be replicated in main so the dashboard view displays the correct state.