From da495a0f5cf1d0e01177f27ec8d16d77c9eeab2f Mon Sep 17 00:00:00 2001 From: weihuan Date: Fri, 10 Apr 2026 15:50:44 +0800 Subject: [PATCH 1/3] support thirdreality smart button zb2 Change-Id: I0e55039b3496aa53436cd44bcc3db4b0e2919ebb --- .../zigbee-button/fingerprints.yml | 5 ++ .../profiles/thirdreality-three-button.yml | 30 +++++++++ .../zigbee-button/src/sub_drivers.lua | 1 + .../src/thirdreality-zb2/can_handle.lua | 12 ++++ .../src/thirdreality-zb2/init.lua | 65 +++++++++++++++++++ 5 files changed, 113 insertions(+) create mode 100644 drivers/SmartThings/zigbee-button/profiles/thirdreality-three-button.yml create mode 100644 drivers/SmartThings/zigbee-button/src/thirdreality-zb2/can_handle.lua create mode 100644 drivers/SmartThings/zigbee-button/src/thirdreality-zb2/init.lua diff --git a/drivers/SmartThings/zigbee-button/fingerprints.yml b/drivers/SmartThings/zigbee-button/fingerprints.yml index f256e0584c..9f8eb8c68e 100644 --- a/drivers/SmartThings/zigbee-button/fingerprints.yml +++ b/drivers/SmartThings/zigbee-button/fingerprints.yml @@ -244,6 +244,11 @@ zigbeeManufacturer: manufacturer: Third Reality, Inc model: 3RSB22BZ deviceProfileName: one-button-battery + - id: "Third Reality/3RSB01085Z" + deviceLabel: ThirdReality Smart Button ZB2 + manufacturer: Third Reality, Inc + model: 3RSB01085Z + deviceProfileName: thirdreality-three-button - id: Samsung/SAMSUNG-ITM-Z-005 deviceLabel: ITM Switch manufacturer: Samsung Electronics diff --git a/drivers/SmartThings/zigbee-button/profiles/thirdreality-three-button.yml b/drivers/SmartThings/zigbee-button/profiles/thirdreality-three-button.yml new file mode 100644 index 0000000000..36aeee23ac --- /dev/null +++ b/drivers/SmartThings/zigbee-button/profiles/thirdreality-three-button.yml @@ -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 diff --git a/drivers/SmartThings/zigbee-button/src/sub_drivers.lua b/drivers/SmartThings/zigbee-button/src/sub_drivers.lua index bec1f76ac1..bb9700b5e0 100644 --- a/drivers/SmartThings/zigbee-button/src/sub_drivers.lua +++ b/drivers/SmartThings/zigbee-button/src/sub_drivers.lua @@ -13,6 +13,7 @@ local sub_drivers = { lazy_load_if_possible("samjin"), lazy_load_if_possible("ewelink"), lazy_load_if_possible("thirdreality"), + lazy_load_if_possible("thirdreality-zb2"), lazy_load_if_possible("ezviz"), } return sub_drivers diff --git a/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/can_handle.lua b/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/can_handle.lua new file mode 100644 index 0000000000..9b14bca89e --- /dev/null +++ b/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/can_handle.lua @@ -0,0 +1,12 @@ +-- 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 + \ No newline at end of file diff --git a/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/init.lua b/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/init.lua new file mode 100644 index 0000000000..f8b5dab674 --- /dev/null +++ b/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/init.lua @@ -0,0 +1,65 @@ +local capabilities = require "st.capabilities" +local data_types = require "st.zigbee.data_types" + +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 From f642c070f748dc2a15bf642c6bb6b524010d697a Mon Sep 17 00:00:00 2001 From: weihuan1111 <99949392+weihuan1111@users.noreply.github.com> Date: Fri, 10 Apr 2026 17:11:58 +0800 Subject: [PATCH 2/3] Update can_handle.lua --- .../src/thirdreality-zb2/can_handle.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/can_handle.lua b/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/can_handle.lua index 9b14bca89e..6235d3e89c 100644 --- a/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/can_handle.lua +++ b/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/can_handle.lua @@ -2,11 +2,10 @@ -- 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 + if device:get_manufacturer() == "Third Reality, Inc" and device:get_model() == "3RSB01085Z" then + return true, require("thirdreality-zb2") end - - return thirdreality_zb2_can_handle - \ No newline at end of file + return false +end + +return thirdreality_zb2_can_handle From a489ee6f9f94487aa4bae29922d15be1ee0f4e2a Mon Sep 17 00:00:00 2001 From: weihuan1111 <99949392+weihuan1111@users.noreply.github.com> Date: Fri, 10 Apr 2026 17:12:23 +0800 Subject: [PATCH 3/3] Update init.lua --- drivers/SmartThings/zigbee-button/src/thirdreality-zb2/init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/init.lua b/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/init.lua index f8b5dab674..1fbca97834 100644 --- a/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/init.lua +++ b/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/init.lua @@ -1,5 +1,4 @@ local capabilities = require "st.capabilities" -local data_types = require "st.zigbee.data_types" local MULTISTATE_INPUT_CLUSTER_ID = 0x0012 local PRESENT_VALUE_ATTR_ID = 0x0055