Skip to content
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

Add Linxura Smart Controller Zigbee mode integrate with SmartThings hub #1829

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions drivers/SmartThings/zigbee-button/fingerprints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ zigbeeManufacturer:
manufacturer: Samsung Electronics
model: SAMSUNG-ITM-Z-005
deviceProfileName: SLED-three-buttons
- id: "Linxura Smart Controller"
deviceLabel: Linxura Smart Controller
manufacturer: Linxura
model: Smart Controller
deviceProfileName: four-buttons
isJoinable: true
# Wall Hero
- id: "WALL HERO/ACL-401SCA4"
deviceLabel: WallHero Remote Control (4-Inch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ local ZIGBEE_MULTI_BUTTON_FINGERPRINTS = {
{ mfr = "ROBB smarrt", model = "ROB_200-007-0" },
{ mfr = "ROBB smarrt", model = "ROB_200-008-0" },
{ mfr = "WALL HERO", model = "ACL-401SCA4" },
{ mfr = "Samsung Electronics", model = "SAMSUNG-ITM-Z-005" }
{ mfr = "Samsung Electronics", model = "SAMSUNG-ITM-Z-005" },
{ mfr = "Linxura", model = "Smart Controller" }
}

local function can_handle_zigbee_multi_button(opts, driver, device, ...)
Expand Down Expand Up @@ -88,7 +89,8 @@ local zigbee_multi_button = {
require("zigbee-multi-button.shinasystems"),
require("zigbee-multi-button.robb"),
require("zigbee-multi-button.wallhero"),
require("zigbee-multi-button.SLED")
require("zigbee-multi-button.SLED"),
require("zigbee-multi-button.linxura")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
-- Copyright 2022 SmartThings
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

local capabilities = require "st.capabilities"
local IASZone = (require "st.zigbee.zcl.clusters").IASZone
local constants = require "st.zigbee.constants"
local clusters = require "st.zigbee.zcl.clusters"
local Groups = clusters.Groups
local log = require "log"
local device_management = require "st.zigbee.device_management"
local zcl_commands = require "st.zigbee.zcl.global_commands"
local zcl_clusters = require "st.zigbee.zcl.clusters"

local BUTTON1_HELD = 0x0001
local BUTTON1_PUSHED = 0x0003
local BUTTON1_DOUBLE = 0x0005
local BUTTON2_HELD = 0x0007
local BUTTON2_PUSHED = 0x0009
local BUTTON2_DOUBLE = 0x000B
local BUTTON3_HELD = 0x000D
local BUTTON3_PUSHED = 0x000F
local BUTTON3_DOUBLE = 0x0011
local BUTTON4_HELD = 0x00013
local BUTTON4_PUSHED = 0x00015
local BUTTON4_DOUBLE = 0x0017

local BUTTON1 = "button1"
local BUTTON2 = "button2"
local BUTTON3 = "button3"
local BUTTON4 = "button4"


local LINXURA_BUTTON_FINGERPRINTS = {
{ mfr = "Linxura", model = "Smart Controller" }
}

local configuration = {
{
cluster = IASZone.ID,
attribute = IASZone.attributes.ZoneStatus.ID,
minimum_interval = 0,
maximum_interval = 3600,
data_type = IASZone.attributes.ZoneStatus.base_type,
reportable_change = 1
}
}
local is_linxura_button = function(opts, driver, device)
for _, fingerprint in ipairs(LINXURA_BUTTON_FINGERPRINTS) do
if device:get_manufacturer() == fingerprint.mfr and device:get_model() == fingerprint.model then
return true
end
end
return false
end

local function present_value_attr_handler(driver, device, zone_status, zb_rx)
log.info("present_value_attr_handler The current value is: ", zone_status.value)
local status = zone_status


local additional_fields = {
state_change = true
}
local event
local mod = status.value % 6
if mod == 1 then
event = capabilities.button.button.pushed(additional_fields)
elseif mod == 3 then
event = capabilities.button.button.double(additional_fields)
elseif mod == 5 then
event = capabilities.button.button.held(additional_fields)
else
return false
end

if status.value == BUTTON1_HELD or status.value == BUTTON1_PUSHED or status.value == BUTTON1_DOUBLE then
device:emit_component_event(device.profile.components[BUTTON1], event)
--device:emit_event(device.profile.components[BUTTON1],event)
device:emit_event(event)
elseif status.value == BUTTON2_HELD or status.value == BUTTON2_PUSHED or status.value == BUTTON2_DOUBLE then
device:emit_component_event(device.profile.components[BUTTON2], event)
device:emit_event(event)
elseif status.value == BUTTON3_HELD or status.value == BUTTON3_PUSHED or status.value == BUTTON3_DOUBLE then
device:emit_component_event(device.profile.components[BUTTON3], event)
device:emit_event(event)
elseif status.value == BUTTON4_HELD or status.value == BUTTON4_PUSHED or status.value == BUTTON4_DOUBLE then
device:emit_component_event(device.profile.components[BUTTON4], event)
device:emit_event(event)
end
end


local function device_init(driver, device)
for _, attribute in ipairs(configuration) do
device:add_configured_attribute(attribute)


device:add_monitored_attribute(attribute)
end
end



local linxura_device_handler = {
NAME = "Linxura Device Handler",
lifecycle_handlers = {
init = device_init,
},

zigbee_handlers = {
attr = {
[IASZone.ID] = {
[IASZone.attributes.ZoneStatus.ID] = present_value_attr_handler
}
},
},

can_handle = is_linxura_button,
}

return linxura_device_handler
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ local devices = {
},
BUTTON_PUSH_HELD_DOUBLE_4 = {
MATCHING_MATRIX = {
{ mfr = "ShinaSystem", model = "MSM-300Z" }
{ mfr = "ShinaSystem", model = "MSM-300Z" },
{ mfr = "Linxura", model = "Smart Controller" }
},
SUPPORTED_BUTTON_VALUES = { "pushed", "held", "double" },
NUMBER_OF_BUTTONS = 4
Expand Down