diff --git a/drivers/SmartThings/zigbee-button/fingerprints.yml b/drivers/SmartThings/zigbee-button/fingerprints.yml index 61285448f7..7b2b348b3b 100644 --- a/drivers/SmartThings/zigbee-button/fingerprints.yml +++ b/drivers/SmartThings/zigbee-button/fingerprints.yml @@ -244,7 +244,7 @@ zigbeeManufacturer: deviceLabel: Aura Smart Button manufacturer: Linxura model: Aura Smart Button - deviceProfileName: four-buttons-without-main-button + deviceProfileName: twelve-buttons-without-main-button isJoinable: true # Wall Hero - id: "WALL HERO/ACL-401SCA4" diff --git a/drivers/SmartThings/zigbee-button/profiles/twelve-buttons-without-main-button.yml b/drivers/SmartThings/zigbee-button/profiles/twelve-buttons-without-main-button.yml new file mode 100644 index 0000000000..adbe68a733 --- /dev/null +++ b/drivers/SmartThings/zigbee-button/profiles/twelve-buttons-without-main-button.yml @@ -0,0 +1,82 @@ +name: twelve-buttons-without-main-button +components: + - id: main + capabilities: + - id: battery + 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 + - 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 + - id: button9 + capabilities: + - id: button + version: 1 + categories: + - name: RemoteController + - id: button10 + capabilities: + - id: button + version: 1 + categories: + - name: RemoteController + - id: button11 + capabilities: + - id: button + version: 1 + categories: + - name: RemoteController + - id: button12 + capabilities: + - id: button + version: 1 + categories: + - name: RemoteController diff --git a/drivers/SmartThings/zigbee-button/src/test/test_linxura_aura_smart_button.lua b/drivers/SmartThings/zigbee-button/src/test/test_linxura_aura_smart_button_12x_button.lua similarity index 94% rename from drivers/SmartThings/zigbee-button/src/test/test_linxura_aura_smart_button.lua rename to drivers/SmartThings/zigbee-button/src/test/test_linxura_aura_smart_button_12x_button.lua index 4b9ca6dfd9..732888b727 100644 --- a/drivers/SmartThings/zigbee-button/src/test/test_linxura_aura_smart_button.lua +++ b/drivers/SmartThings/zigbee-button/src/test/test_linxura_aura_smart_button_12x_button.lua @@ -25,13 +25,13 @@ local button_attr = capabilities.button.button local mock_device = test.mock_device.build_test_zigbee_device( { - profile = t_utils.get_profile_definition("four-buttons-without-main-button.yml"), + profile = t_utils.get_profile_definition("twelve-buttons-without-main-button.yml"), zigbee_endpoints = { [1] = { id = 1, manufacturer = "Linxura", model = "Aura Smart Button", - server_clusters = {0x0500, 0x0000} + server_clusters = {0x0001, 0x0500, 0x0000} } } } @@ -72,7 +72,7 @@ test.register_coroutine_test( test.register_coroutine_test( "Test cases for Buttons Pushed", function() - for var = 0, 3 do + for var = 0, 11 do test.socket.zigbee:__queue_receive({ mock_device.id, ZoneStatusAttribute:build_test_attr_report(mock_device, 1 + var * 6) @@ -88,7 +88,7 @@ test.register_coroutine_test( test.register_coroutine_test( "Test cases for Buttons Double", function() - for var = 0, 3 do + for var = 0, 11 do test.socket.zigbee:__queue_receive({ mock_device.id, ZoneStatusAttribute:build_test_attr_report(mock_device, 3 + var * 6) @@ -105,7 +105,7 @@ test.register_coroutine_test( test.register_coroutine_test( "Test cases for Buttons Held", function() - for var = 0, 3 do + for var = 0, 11 do test.socket.zigbee:__queue_receive({ mock_device.id, ZoneStatusAttribute:build_test_attr_report(mock_device, 5 + var * 6) diff --git a/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/linxura/init.lua b/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/linxura/init.lua index 0e7cf44e93..220de89d8a 100644 --- a/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/linxura/init.lua +++ b/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/linxura/init.lua @@ -13,6 +13,10 @@ -- limitations under the License. local capabilities = require "st.capabilities" local IASZone = (require "st.zigbee.zcl.clusters").IASZone +local zcl_clusters = require "st.zigbee.zcl.clusters" +local PowerConfiguration = zcl_clusters.PowerConfiguration +local supported_values = require "zigbee-multi-button.supported_values" + local log = require "log" @@ -29,6 +33,14 @@ local configuration = { maximum_interval = 3600, data_type = IASZone.attributes.ZoneStatus.base_type, reportable_change = 1 + }, + { + cluster = PowerConfiguration.ID, + attribute = PowerConfiguration.attributes.BatteryPercentageRemaining.ID, + minimum_interval = 0, + maximum_interval = 3600, + data_type = PowerConfiguration.attributes.BatteryPercentageRemaining.base_type, + reportable_change = 2 } } local is_linxura_button = function(opts, driver, device) @@ -56,6 +68,8 @@ local function present_value_attr_handler(driver, device, zone_status, zb_rx) event = capabilities.button.button.double(additional_fields) elseif mod == 5 then event = capabilities.button.button.held(additional_fields) + else + return false end if (event) then @@ -64,22 +78,67 @@ local function present_value_attr_handler(driver, device, zone_status, zb_rx) end end +local function battery_attr_handler(driver, device, value, zb_rx) + local raw = value.value + if raw == nil then return end + + local pct = nil + if raw == 0xFF then + log.info("BatteryPercentageRemaining is unknown (0xFF)") + else + pct = math.floor(math.max(0, math.min(200, raw)) / 2) + end + + if pct then + device:emit_event(capabilities.battery.battery(pct)) + end +end local function device_init(driver, device) for _, attribute in ipairs(configuration) do device:add_configured_attribute(attribute) end end +local function device_added(driver, device) + local config = supported_values.get_device_parameters(device) + for _, component in pairs(device.profile.components) do + if config ~= nil then + local number_of_buttons = component.id == "main" and config.NUMBER_OF_BUTTONS or 1 + device:emit_component_event(component, + capabilities.button.supportedButtonValues(config.SUPPORTED_BUTTON_VALUES, { visibility = { displayed = false } })) + device:emit_component_event(component, + capabilities.button.numberOfButtons({ value = number_of_buttons }, { visibility = { displayed = false } })) + else + device:emit_component_event(component, + capabilities.button.supportedButtonValues({ "pushed", "held" }, { visibility = { displayed = false } })) + device:emit_component_event(component, + capabilities.button.numberOfButtons({ value = 1 }, { visibility = { displayed = false } })) + end + end + device:emit_event(capabilities.button.button.pushed({state_change = false})) + + -- device:send(PowerConfiguration.attributes.BatteryPercentageRemaining:read(device)) +end + +local function do_configure(driver, device) + device:configure() + device:send(PowerConfiguration.attributes.BatteryPercentageRemaining:read(device)) +end local linxura_device_handler = { NAME = "Linxura Device Handler", lifecycle_handlers = { - init = device_init + init = device_init, + added = device_added, + doConfigure = do_configure, }, zigbee_handlers = { attr = { [IASZone.ID] = { [IASZone.attributes.ZoneStatus.ID] = present_value_attr_handler + }, + [PowerConfiguration.ID] = { + [PowerConfiguration.attributes.BatteryPercentageRemaining.ID] = battery_attr_handler } } }, diff --git a/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/supported_values.lua b/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/supported_values.lua index 172a7c1ca3..a7418621b7 100644 --- a/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/supported_values.lua +++ b/drivers/SmartThings/zigbee-button/src/zigbee-multi-button/supported_values.lua @@ -119,11 +119,17 @@ local devices = { { mfr = "ShinaSystem", model = "SBM300ZC4" }, { mfr = "ShinaSystem", model = "SQM300ZC4" }, { mfr = "Linxura", model = "Smart Controller" }, - { mfr = "Linxura", model = "Aura Smart Button" } }, SUPPORTED_BUTTON_VALUES = { "pushed", "held", "double" }, NUMBER_OF_BUTTONS = 4 }, + BUTTON_PUSH_HELD_DOUBLE_12 = { + MATCHING_MATRIX = { + { mfr = "Linxura", model = "Aura Smart Button" } + }, + SUPPORTED_BUTTON_VALUES = { "pushed", "held", "double" }, + NUMBER_OF_BUTTONS = 12 + }, BUTTON_PUSH_DOWN_HOLD_UP_VIMAR_2 = { MATCHING_MATRIX = { { mfr = "Vimar", model = "RemoteControl_v1.0" }