Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/SmartThings/zigbee-button/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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}
}
}
}
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Loading