@@ -39,6 +39,7 @@ local RUN_MODE_SUPPORTED_MODES = "__run_mode_supported_modes"
39
39
local CURRENT_RUN_MODE = " __current_run_mode"
40
40
local CLEAN_MODE_SUPPORTED_MODES = " __clean_mode_supported_modes"
41
41
local OPERATING_STATE_SUPPORTED_COMMANDS = " __operating_state_supported_commands"
42
+ local SERVICE_AREA_PROFILED = " __SERVICE_AREA_PROFILED"
42
43
43
44
local subscribed_attributes = {
44
45
[capabilities .mode .ID ] = {
@@ -76,12 +77,7 @@ local function component_to_endpoint(device, component_name)
76
77
return find_default_endpoint (device , clusters .RvcOperationalState .ID )
77
78
end
78
79
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 )
85
81
local clean_mode_eps = device :get_endpoints (clusters .RvcCleanMode .ID ) or {}
86
82
local service_area_eps = embedded_cluster_utils .get_endpoints (device , clusters .ServiceArea .ID ) or {}
87
83
@@ -95,6 +91,20 @@ local function do_configure(driver, device)
95
91
96
92
device .log .info_with ({hub_logs = true }, string.format (" Updating device profile to %s." , profile_name ))
97
93
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 )
98
108
device :send (clusters .RvcOperationalState .attributes .AcceptedCommandList :read ())
99
109
end
100
110
0 commit comments