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..6235d3e89c --- /dev/null +++ b/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/can_handle.lua @@ -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 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..1fbca97834 --- /dev/null +++ b/drivers/SmartThings/zigbee-button/src/thirdreality-zb2/init.lua @@ -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