@@ -28,15 +28,14 @@ local THIRD_REALITY_MANUFACTURER_ID = 0x1407
28
28
local THIRD_REALITY_MK1_PRODUCT_ID = 0x1388
29
29
30
30
local function is_third_reality_mk1 (opts , driver , device )
31
- return true
32
- -- if not device.manufacturer_info then return false end
33
- ---- this sub driver does not support child devices
34
- -- if device.network_type == device_lib.NETWORK_TYPE_MATTER and
35
- -- device.manufacturer_info.vendor_id == THIRD_REALITY_MANUFACTURER_ID and
36
- -- device.manufacturer_info.product_id == THIRD_REALITY_MK1_PRODUCT_ID then
37
- -- return true
38
- -- end
39
- -- return false
31
+ if not device .manufacturer_info then return false end
32
+ -- this sub driver does not support child devices
33
+ if device .network_type == device_lib .NETWORK_TYPE_MATTER and
34
+ device .manufacturer_info .vendor_id == THIRD_REALITY_MANUFACTURER_ID and
35
+ device .manufacturer_info .product_id == THIRD_REALITY_MK1_PRODUCT_ID then
36
+ return true
37
+ end
38
+ return false
40
39
end
41
40
42
41
local function set_field_for_endpoint (device , field , endpoint , value , additional_params )
@@ -94,10 +93,14 @@ local function device_init(driver, device)
94
93
end
95
94
end
96
95
96
+ local function device_added (driver , device )
97
+ device_init (driver , device )
98
+ end
99
+
97
100
local function info_changed (driver , device , event , args )
98
101
if device .profile .id ~= args .old_st_store .profile .id then
99
- subscribe (device )
100
102
configure_buttons (device )
103
+ subscribe (device )
101
104
end
102
105
end
103
106
@@ -107,13 +110,25 @@ local function do_configure(driver, device)
107
110
configure_buttons (device )
108
111
end
109
112
113
+ local function initial_press_event_handler (driver , device , ib , response )
114
+ device :emit_event_for_endpoint (ib .endpoint_id , capabilities .button .button .pushed ({state_change = true }))
115
+ end
116
+
110
117
local third_reality_mk1_handler = {
111
118
NAME = " ThirdReality MK1 Handler" ,
112
119
lifecycle_handlers = {
113
120
init = device_init ,
121
+ added = device_added ,
114
122
infoChanged = info_changed ,
115
123
doConfigure = do_configure
116
124
},
125
+ matter_handlers = {
126
+ event = {
127
+ [clusters .Switch .ID ] = {
128
+ [clusters .Switch .events .InitialPress .ID ] = initial_press_event_handler
129
+ }
130
+ }
131
+ },
117
132
supported_capabilities = {
118
133
capabilities .button
119
134
},
0 commit comments