Skip to content

Commit bddd262

Browse files
Matter Camera: fix devices being marked online due to capability inits (#2688)
The driverSwitched event can be triggered in a few different ways, but since it was pointed to the same handler as doConfigure, code that should only be ran for new devices was being run when this event was received by the driver. This includes `initialize_camera_capabilities`, which resulted in offline devices being marked online. This change adds separate handling from driverSwitched, specifically excluding this function as well as `create_child_devices`.
1 parent 0e13a71 commit bddd262

File tree

1 file changed

+8
-1
lines changed
  • drivers/SmartThings/matter-switch/src/sub_drivers/camera

1 file changed

+8
-1
lines changed

drivers/SmartThings/matter-switch/src/sub_drivers/camera/init.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ function CameraLifecycleHandlers.do_configure(driver, device)
3939
camera_cfg.initialize_camera_capabilities(device)
4040
end
4141

42+
function CameraLifecycleHandlers.driver_switched(driver, device)
43+
camera_utils.update_camera_component_map(device)
44+
if #device:get_endpoints(clusters.CameraAvStreamManagement.ID) == 0 then
45+
camera_cfg.match_profile(device, false, false)
46+
end
47+
end
48+
4249
function CameraLifecycleHandlers.info_changed(driver, device, event, args)
4350
if camera_utils.profile_changed(device.profile.components, args.old_st_store.profile.components) then
4451
camera_cfg.initialize_camera_capabilities(device)
@@ -57,7 +64,7 @@ local camera_handler = {
5764
init = CameraLifecycleHandlers.device_init,
5865
infoChanged = CameraLifecycleHandlers.info_changed,
5966
doConfigure = CameraLifecycleHandlers.do_configure,
60-
driverSwitched = CameraLifecycleHandlers.do_configure,
67+
driverSwitched = CameraLifecycleHandlers.driver_switched,
6168
added = CameraLifecycleHandlers.added
6269
},
6370
matter_handlers = {

0 commit comments

Comments
 (0)