Skip to content

Commit 2389712

Browse files
Matter Camera: Check for server cluster type (#2570)
Check for cluster_type = SERVER or BOTH when adding optional capabilities. When using get_endpoints, omit the check for SERVER because it is already implied in that api.
1 parent 1395f67 commit 2389712

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

drivers/SmartThings/matter-switch/src/sub_drivers/camera/camera_utils/device_configuration.lua

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ function CameraDeviceConfiguration.match_profile(device, status_light_enabled_pr
4949
local microphone_component_capabilities = {}
5050
local doorbell_component_capabilities = {}
5151

52+
local function has_server_cluster_type(cluster)
53+
return cluster.cluster_type == "SERVER" or cluster.cluster_type == "BOTH"
54+
end
55+
5256
local camera_endpoints = switch_utils.get_endpoints_by_device_type(device, fields.DEVICE_TYPE_ID.CAMERA)
5357
if #camera_endpoints > 0 then
54-
if #device:get_endpoints(clusters.WebRTCTransportProvider.ID, {cluster_type = "SERVER"}) > 0 and
55-
#device:get_endpoints(clusters.WebRTCTransportRequestor.ID, {cluster_type = "CLIENT"}) > 0 then
56-
table.insert(main_component_capabilities, capabilities.webrtc.ID)
57-
end
5858
local camera_ep = switch_utils.get_endpoint_info(device, camera_endpoints[1])
5959
for _, ep_cluster in pairs(camera_ep.clusters or {}) do
60-
if ep_cluster.cluster_id == clusters.CameraAvStreamManagement.ID then
60+
if ep_cluster.cluster_id == clusters.CameraAvStreamManagement.ID and has_server_cluster_type(ep_cluster) then
6161
local clus_has_feature = function(feature_bitmap)
6262
return clusters.CameraAvStreamManagement.are_features_supported(feature_bitmap, ep_cluster.feature_map)
6363
end
@@ -92,7 +92,7 @@ function CameraDeviceConfiguration.match_profile(device, status_light_enabled_pr
9292
if clus_has_feature(clusters.CameraAvStreamManagement.types.Feature.NIGHT_VISION) then
9393
table.insert(main_component_capabilities, capabilities.nightVision.ID)
9494
end
95-
elseif ep_cluster.cluster_id == clusters.CameraAvSettingsUserLevelManagement.ID then
95+
elseif ep_cluster.cluster_id == clusters.CameraAvSettingsUserLevelManagement.ID and has_server_cluster_type(ep_cluster) then
9696
local clus_has_feature = function(feature_bitmap)
9797
return clusters.CameraAvSettingsUserLevelManagement.are_features_supported(feature_bitmap, ep_cluster.feature_map)
9898
end
@@ -102,10 +102,13 @@ function CameraDeviceConfiguration.match_profile(device, status_light_enabled_pr
102102
table.insert(main_component_capabilities, capabilities.mechanicalPanTiltZoom.ID)
103103
end
104104
table.insert(main_component_capabilities, capabilities.videoStreamSettings.ID)
105-
elseif ep_cluster.cluster_id == clusters.ZoneManagement.ID then
105+
elseif ep_cluster.cluster_id == clusters.ZoneManagement.ID and has_server_cluster_type(ep_cluster) then
106106
table.insert(main_component_capabilities, capabilities.zoneManagement.ID)
107-
elseif ep_cluster.cluster_id == clusters.OccupancySensing.ID then
107+
elseif ep_cluster.cluster_id == clusters.OccupancySensing.ID and has_server_cluster_type(ep_cluster) then
108108
table.insert(main_component_capabilities, capabilities.motionSensor.ID)
109+
elseif ep_cluster.cluster_id == clusters.WebRTCTransportProvider.ID and has_server_cluster_type(ep_cluster) and
110+
#device:get_endpoints(clusters.WebRTCTransportRequestor.ID, {cluster_type = "CLIENT"}) > 0 then
111+
table.insert(main_component_capabilities, capabilities.webrtc.ID)
109112
end
110113
end
111114
end

drivers/SmartThings/matter-switch/src/test/test_matter_camera.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ local function update_device_profile()
156156
{
157157
"main",
158158
{
159-
"webrtc",
160159
"videoCapture2",
161160
"cameraViewportSettings",
162161
"localMediaStorage",
@@ -168,6 +167,7 @@ local function update_device_profile()
168167
"mechanicalPanTiltZoom",
169168
"videoStreamSettings",
170169
"zoneManagement",
170+
"webrtc",
171171
"motionSensor",
172172
"sounds",
173173
}

0 commit comments

Comments
 (0)