Skip to content

Commit bc937cc

Browse files
Override driverSwitched event handler
A handler for driverSwitched was added to the main driver, so add an override to the subdriver to prevent the main driver version from running.
1 parent 4d90c68 commit bc937cc

File tree

1 file changed

+15
-4
lines changed
  • drivers/SmartThings/matter-switch/src/third-reality-mk1

1 file changed

+15
-4
lines changed

drivers/SmartThings/matter-switch/src/third-reality-mk1/init.lua

+15-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ local THIRD_REALITY_MANUFACTURER_ID = 0x1407
2828
local THIRD_REALITY_MK1_PRODUCT_ID = 0x1388
2929

3030
local function is_third_reality_mk1(opts, driver, device)
31-
if not device.manufacturer_info then return false end
32-
-- this sub driver does not support child devices
3331
if device.network_type == device_lib.NETWORK_TYPE_MATTER and
3432
device.manufacturer_info.vendor_id == THIRD_REALITY_MANUFACTURER_ID and
3533
device.manufacturer_info.product_id == THIRD_REALITY_MK1_PRODUCT_ID then
@@ -104,12 +102,24 @@ local function info_changed(driver, device, event, args)
104102
end
105103
end
106104

107-
local function do_configure(driver, device)
105+
local function match_profile(driver, device)
108106
device:try_update_metadata({profile = "12-button-keyboard"})
109107
build_button_component_map(device)
110108
configure_buttons(device)
111109
end
112110

111+
local function do_configure(driver, device)
112+
if device.network_type == device_lib.NETWORK_TYPE_MATTER then
113+
match_profile(driver, device)
114+
end
115+
end
116+
117+
local function driver_switched(driver, device)
118+
if device.network_type == device_lib.NETWORK_TYPE_MATTER then
119+
match_profile(driver, device)
120+
end
121+
end
122+
113123
local function initial_press_event_handler(driver, device, ib, response)
114124
device:emit_event_for_endpoint(ib.endpoint_id, capabilities.button.button.pushed({state_change = true}))
115125
end
@@ -120,7 +130,8 @@ local third_reality_mk1_handler = {
120130
init = device_init,
121131
added = device_added,
122132
infoChanged = info_changed,
123-
doConfigure = do_configure
133+
doConfigure = do_configure,
134+
driverSwitched = driver_switched
124135
},
125136
matter_handlers = {
126137
event = {

0 commit comments

Comments
 (0)