-
Notifications
You must be signed in to change notification settings - Fork 531
Expand file tree
/
Copy pathinit.lua
More file actions
109 lines (103 loc) · 4.73 KB
/
init.lua
File metadata and controls
109 lines (103 loc) · 4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
-- 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 supported_values = require "zigbee-multi-button.supported_values"
local button_utils = require "button_utils"
local ZIGBEE_MULTI_BUTTON_FINGERPRINTS = {
{ mfr = "CentraLite", model = "3450-L" },
{ mfr = "CentraLite", model = "3450-L2" },
{ mfr = "AduroSmart Eria", model = "ADUROLIGHT_CSC" },
{ mfr = "ADUROLIGHT", model = "ADUROLIGHT_CSC" },
{ mfr = "AduroSmart Eria", model = "Adurolight_NCC" },
{ mfr = "ADUROLIGHT", model = "Adurolight_NCC" },
{ mfr = "HEIMAN", model = "SceneSwitch-EM-3.0" },
{ mfr = "HEIMAN", model = "HS6SSA-W-EF-3.0" },
{ mfr = "HEIMAN", model = "HS6SSB-W-EF-3.0" },
{ mfr = "IKEA of Sweden", model = "TRADFRI on/off switch" },
{ mfr = "IKEA of Sweden", model = "TRADFRI open/close remote" },
{ mfr = "IKEA of Sweden", model = "TRADFRI remote control" },
{ mfr = "KE", model = "TRADFRI open/close remote" },
{ mfr = "\x02KE", model = "TRADFRI open/close remote" },
{ mfr = "SOMFY", model = "Situo 1 Zigbee" },
{ mfr = "SOMFY", model = "Situo 4 Zigbee" },
{ mfr = "LDS", model = "ZBT-CCTSwitch-D0001" },
{ mfr = "ShinaSystem", model = "MSM-300Z" },
{ mfr = "ShinaSystem", model = "BSM-300Z" },
{ mfr = "ShinaSystem", model = "SBM300ZB1" },
{ mfr = "ShinaSystem", model = "SBM300ZB2" },
{ mfr = "ShinaSystem", model = "SBM300ZB3" },
{ mfr = "ShinaSystem", model = "SBM300ZC1" },
{ mfr = "ShinaSystem", model = "SBM300ZC2" },
{ mfr = "ShinaSystem", model = "SBM300ZC3" },
{ mfr = "ShinaSystem", model = "SBM300ZC4" },
{ mfr = "ShinaSystem", model = "SQM300ZC4" },
{ 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 = "Vimar", model = "RemoteControl_v1.0" },
{ mfr = "Linxura", model = "Smart Controller" },
{ mfr = "Linxura", model = "Aura Smart Button" },
{ mfr = "zunzunbee", model = "SSWZ8T" },
{ mfr = "SONOFF", model = "SNZB-01M" }
}
local function can_handle_zigbee_multi_button(opts, driver, device, ...)
for _, fingerprint in ipairs(ZIGBEE_MULTI_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 added_handler(self, 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
button_utils.emit_event_if_latest_state_missing(device, "main", capabilities.button, capabilities.button.button.NAME, capabilities.button.button.pushed({state_change = false}))
end
local zigbee_multi_button = {
NAME = "ZigBee multi button",
lifecycle_handlers = {
added = added_handler
},
can_handle = can_handle_zigbee_multi_button,
sub_drivers = {
require("zigbee-multi-button.ikea"),
require("zigbee-multi-button.somfy"),
require("zigbee-multi-button.ecosmart"),
require("zigbee-multi-button.centralite"),
require("zigbee-multi-button.adurosmart"),
require("zigbee-multi-button.heiman"),
require("zigbee-multi-button.shinasystems"),
require("zigbee-multi-button.robb"),
require("zigbee-multi-button.wallhero"),
require("zigbee-multi-button.SLED"),
require("zigbee-multi-button.vimar"),
require("zigbee-multi-button.linxura"),
require("zigbee-multi-button.zunzunbee")
}
}
return zigbee_multi_button