Skip to content

Commit 97099e4

Browse files
committed
Re-match profile to support Service Area
Signed-off-by: HunsupJung <hunsup.jung@samsung.com>
1 parent df9744e commit 97099e4

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

drivers/SmartThings/matter-rvc/src/init.lua

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ local RUN_MODE_SUPPORTED_MODES = "__run_mode_supported_modes"
3939
local CURRENT_RUN_MODE = "__current_run_mode"
4040
local CLEAN_MODE_SUPPORTED_MODES = "__clean_mode_supported_modes"
4141
local OPERATING_STATE_SUPPORTED_COMMANDS = "__operating_state_supported_commands"
42+
local SERVICE_AREA_PROFILED = "__SERVICE_AREA_PROFILED"
4243

4344
local subscribed_attributes = {
4445
[capabilities.mode.ID] = {
@@ -76,12 +77,7 @@ local function component_to_endpoint(device, component_name)
7677
return find_default_endpoint(device, clusters.RvcOperationalState.ID)
7778
end
7879

79-
local function device_init(driver, device)
80-
device:subscribe()
81-
device:set_component_to_endpoint_fn(component_to_endpoint)
82-
end
83-
84-
local function do_configure(driver, device)
80+
local function match_profile(driver, device)
8581
local clean_mode_eps = device:get_endpoints(clusters.RvcCleanMode.ID) or {}
8682
local service_area_eps = embedded_cluster_utils.get_endpoints(device, clusters.ServiceArea.ID) or {}
8783

@@ -95,6 +91,20 @@ local function do_configure(driver, device)
9591

9692
device.log.info_with({hub_logs = true}, string.format("Updating device profile to %s.", profile_name))
9793
device:try_update_metadata({profile = profile_name})
94+
end
95+
96+
local function device_init(driver, device)
97+
device:subscribe()
98+
device:set_component_to_endpoint_fn(component_to_endpoint)
99+
if not device:get_field(SERVICE_AREA_PROFILED) and #device:get_endpoints(clusters.ServiceArea.ID) > 0 then
100+
match_profile(driver, device)
101+
device:set_field(SERVICE_AREA_PROFILED, true)
102+
end
103+
end
104+
105+
local function do_configure(driver, device)
106+
match_profile(driver, device)
107+
device:set_field(SERVICE_AREA_PROFILED, true)
98108
device:send(clusters.RvcOperationalState.attributes.AcceptedCommandList:read())
99109
end
100110

drivers/SmartThings/matter-rvc/src/test/test_matter_rvc.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ if version.api < 13 then
3131
end
3232

3333
local APPLICATION_ENDPOINT = 10
34+
local SERVICE_AREA_PROFILED = "__SERVICE_AREA_PROFILED"
3435

3536
local mock_device = test.mock_device.build_test_matter_device({
3637
profile = t_utils.get_profile_definition("rvc-clean-mode-service-area.yml"),
@@ -124,6 +125,7 @@ local CLEAN_MODES = {
124125
local CLEAN_MODE_LABELS = { CLEAN_MODES[1].label, CLEAN_MODES[2].label }
125126

126127
local function supported_run_mode_init()
128+
mock_device:set_field(SERVICE_AREA_PROFILED, true, { persist = true })
127129
test.socket.matter:__queue_receive({
128130
mock_device.id,
129131
clusters.RvcRunMode.attributes.SupportedModes:build_test_report_data(mock_device, APPLICATION_ENDPOINT,

0 commit comments

Comments
 (0)