-
Notifications
You must be signed in to change notification settings - Fork 531
Expand file tree
/
Copy pathinit.lua
More file actions
executable file
·48 lines (41 loc) · 1.67 KB
/
init.lua
File metadata and controls
executable file
·48 lines (41 loc) · 1.67 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
-- Copyright 2026 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0
local zcl_clusters = require "st.zigbee.zcl.clusters"
local capabilities = require "st.capabilities"
local button_utils = require "button_utils"
local log = require "log"
local IASZone = zcl_clusters.IASZone
local PRIVATE_CMD_ID = 0xF1
local function ias_zone_private_cmd_handler(self, device, zb_rx)
local cmd_data = zb_rx.body.zcl_body.body_bytes:byte(1)
if cmd_data == 0 then
device:emit_event(capabilities.button.button.pushed({state_change = true}))
elseif cmd_data == 1 then
device:emit_event(capabilities.button.button.double({state_change = true}))
elseif cmd_data == 0x80 then
device:emit_event(capabilities.button.button.held({state_change = true}))
else
log.info("ias_zone_private_cmd Unknown value",zb_rx.body.zcl_body.body_bytes:byte(1))
end
end
local function added_handler(self, device)
device:emit_event(capabilities.button.supportedButtonValues({"pushed","double","held"}, {visibility = { displayed = false }}))
device:emit_event(capabilities.button.numberOfButtons({value = 1}, {visibility = { displayed = false }}))
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 MultiIR_Emergency_Button = {
NAME = "MultiIR Emergency Button",
lifecycle_handlers = {
added = added_handler,
},
zigbee_handlers = {
cluster = {
[IASZone.ID] = {
[PRIVATE_CMD_ID] = ias_zone_private_cmd_handler
}
}
},
sub_drivers = {},
can_handle = require("MultiIR.can_handle"),
}
return MultiIR_Emergency_Button