diff --git a/drivers/SmartThings/matter-rvc/profiles/rvc-clean-mode-service-area.yml b/drivers/SmartThings/matter-rvc/profiles/rvc-clean-mode-service-area.yml index 15c766fbdb..a2e064c04f 100644 --- a/drivers/SmartThings/matter-rvc/profiles/rvc-clean-mode-service-area.yml +++ b/drivers/SmartThings/matter-rvc/profiles/rvc-clean-mode-service-area.yml @@ -5,6 +5,8 @@ components: capabilities: - id: robotCleanerOperatingState version: 1 + - id: mode + version: 1 - id: serviceArea version: 1 - id: refresh @@ -13,20 +15,6 @@ components: version: 1 categories: - name: RobotCleaner - - id: runMode - label: Run mode - capabilities: - - id: mode - version: 1 - categories: - - name: RobotCleaner - - id: cleanMode - label: Clean mode - capabilities: - - id: mode - version: 1 - categories: - - name: RobotCleaner deviceConfig: dashboard: states: @@ -38,22 +26,15 @@ deviceConfig: capability: robotCleanerOperatingState version: 1 - component: main - capability: serviceArea - version: 1 - - component: runMode capability: mode version: 1 patch: - op: replace path: /0/list/command/supportedValues value: supportedArguments.value - - component: cleanMode - capability: mode + - component: main + capability: serviceArea version: 1 - patch: - - op: replace - path: /0/list/command/supportedValues - value: supportedArguments.value - component: main capability: refresh version: 1 @@ -65,22 +46,7 @@ deviceConfig: - component: main capability: robotCleanerOperatingState version: 1 - - component: runMode - capability: mode - version: 1 - patch: - - op: replace - path: /0/displayType - value: dynamicList - - op: add - path: /0/dynamicList - value: - value: mode.value - supportedValues: - value: supportedModes.value - - op: remove - path: /0/list - - component: cleanMode + - component: main capability: mode version: 1 patch: @@ -99,22 +65,7 @@ deviceConfig: - component: main capability: robotCleanerOperatingState version: 1 - - component: runMode - capability: mode - version: 1 - patch: - - op: replace - path: /0/displayType - value: dynamicList - - op: add - path: /0/dynamicList - value: - command: setMode - supportedValues: - value: supportedModes.value - - op: remove - path: /0/list - - component: cleanMode + - component: main capability: mode version: 1 patch: diff --git a/drivers/SmartThings/matter-rvc/profiles/rvc-clean-mode.yml b/drivers/SmartThings/matter-rvc/profiles/rvc-clean-mode.yml index a83c7801a0..22347086d6 100644 --- a/drivers/SmartThings/matter-rvc/profiles/rvc-clean-mode.yml +++ b/drivers/SmartThings/matter-rvc/profiles/rvc-clean-mode.yml @@ -5,26 +5,14 @@ components: capabilities: - id: robotCleanerOperatingState version: 1 + - id: mode + version: 1 - id: firmwareUpdate version: 1 - id: refresh version: 1 categories: - name: RobotCleaner - - id: runMode - label: Run mode - capabilities: - - id: mode - version: 1 - categories: - - name: RobotCleaner - - id: cleanMode - label: Clean mode - capabilities: - - id: mode - version: 1 - categories: - - name: RobotCleaner deviceConfig: dashboard: states: @@ -35,14 +23,7 @@ deviceConfig: - component: main capability: robotCleanerOperatingState version: 1 - - component: runMode - capability: mode - version: 1 - patch: - - op: replace - path: /0/list/command/supportedValues - value: supportedArguments.value - - component: cleanMode + - component: main capability: mode version: 1 patch: @@ -60,22 +41,7 @@ deviceConfig: - component: main capability: robotCleanerOperatingState version: 1 - - component: runMode - capability: mode - version: 1 - patch: - - op: replace - path: /0/displayType - value: dynamicList - - op: add - path: /0/dynamicList - value: - value: mode.value - supportedValues: - value: supportedModes.value - - op: remove - path: /0/list - - component: cleanMode + - component: main capability: mode version: 1 patch: @@ -94,22 +60,7 @@ deviceConfig: - component: main capability: robotCleanerOperatingState version: 1 - - component: runMode - capability: mode - version: 1 - patch: - - op: replace - path: /0/displayType - value: dynamicList - - op: add - path: /0/dynamicList - value: - command: setMode - supportedValues: - value: supportedModes.value - - op: remove - path: /0/list - - component: cleanMode + - component: main capability: mode version: 1 patch: diff --git a/drivers/SmartThings/matter-rvc/profiles/rvc-service-area.yml b/drivers/SmartThings/matter-rvc/profiles/rvc-service-area.yml index 8f5ca7bc21..560eda12fa 100644 --- a/drivers/SmartThings/matter-rvc/profiles/rvc-service-area.yml +++ b/drivers/SmartThings/matter-rvc/profiles/rvc-service-area.yml @@ -13,75 +13,3 @@ components: version: 1 categories: - name: RobotCleaner - - id: runMode - label: Run mode - capabilities: - - id: mode - version: 1 - categories: - - name: RobotCleaner -deviceConfig: - dashboard: - states: - - component: main - capability: robotCleanerOperatingState - version: 1 - detailView: - - component: main - capability: robotCleanerOperatingState - version: 1 - - component: main - capability: serviceArea - version: 1 - - component: runMode - capability: mode - version: 1 - patch: - - op: replace - path: /0/list/command/supportedValues - value: supportedArguments.value - - component: main - capability: refresh - version: 1 - - component: main - capability: firmwareUpdate - version: 1 - automation: - conditions: - - component: main - capability: robotCleanerOperatingState - version: 1 - - component: runMode - capability: mode - version: 1 - patch: - - op: replace - path: /0/displayType - value: dynamicList - - op: add - path: /0/dynamicList - value: - value: mode.value - supportedValues: - value: supportedModes.value - - op: remove - path: /0/list - actions: - - component: main - capability: robotCleanerOperatingState - version: 1 - - component: runMode - capability: mode - version: 1 - patch: - - op: replace - path: /0/displayType - value: dynamicList - - op: add - path: /0/dynamicList - value: - command: setMode - supportedValues: - value: supportedModes.value - - op: remove - path: /0/list \ No newline at end of file diff --git a/drivers/SmartThings/matter-rvc/profiles/rvc.yml b/drivers/SmartThings/matter-rvc/profiles/rvc.yml index 7246590f4e..84bed73495 100644 --- a/drivers/SmartThings/matter-rvc/profiles/rvc.yml +++ b/drivers/SmartThings/matter-rvc/profiles/rvc.yml @@ -11,72 +11,3 @@ components: version: 1 categories: - name: RobotCleaner - - id: runMode - label: Run mode - capabilities: - - id: mode - version: 1 - categories: - - name: RobotCleaner -deviceConfig: - dashboard: - states: - - component: main - capability: robotCleanerOperatingState - version: 1 - detailView: - - component: main - capability: robotCleanerOperatingState - version: 1 - - component: runMode - capability: mode - version: 1 - patch: - - op: replace - path: /0/list/command/supportedValues - value: supportedArguments.value - - component: main - capability: refresh - version: 1 - - component: main - capability: firmwareUpdate - version: 1 - automation: - conditions: - - component: main - capability: robotCleanerOperatingState - version: 1 - - component: runMode - capability: mode - version: 1 - patch: - - op: replace - path: /0/displayType - value: dynamicList - - op: add - path: /0/dynamicList - value: - value: mode.value - supportedValues: - value: supportedModes.value - - op: remove - path: /0/list - actions: - - component: main - capability: robotCleanerOperatingState - version: 1 - - component: runMode - capability: mode - version: 1 - patch: - - op: replace - path: /0/displayType - value: dynamicList - - op: add - path: /0/dynamicList - value: - command: setMode - supportedValues: - value: supportedModes.value - - op: remove - path: /0/list diff --git a/drivers/SmartThings/matter-rvc/src/init.lua b/drivers/SmartThings/matter-rvc/src/init.lua index 4165535fef..ffd8af0ac0 100644 --- a/drivers/SmartThings/matter-rvc/src/init.lua +++ b/drivers/SmartThings/matter-rvc/src/init.lua @@ -32,10 +32,11 @@ if version.api < 13 then clusters.Global = require "Global" end -local COMPONENT_TO_ENDPOINT_MAP = "__component_to_endpoint_map" local RUN_MODE_SUPPORTED_MODES = "__run_mode_supported_modes" +local CURRENT_RUN_MODE = "__current_run_mode" local CLEAN_MODE_SUPPORTED_MODES = "__clean_mode_supported_modes" local OPERATING_STATE_SUPPORTED_COMMANDS = "__operating_state_supported_commands" +local SERVICE_AREA_PROFILED = "__SERVICE_AREA_PROFILED" local subscribed_attributes = { [capabilities.mode.ID] = { @@ -54,32 +55,19 @@ local subscribed_attributes = { } } -local function component_to_endpoint(device, component) - local map = device:get_field(COMPONENT_TO_ENDPOINT_MAP) or {} - if map[component] then - return map[component] - else - return device.MATTER_DEFAULT_ENDPOINT +local function find_default_endpoint(device, cluster_id) + local eps = device:get_endpoints(cluster_id) + table.sort(eps) + for _, v in ipairs(eps) do + if v ~= 0 then --0 is the matter RootNode endpoint + return v + end end + device.log.warn(string.format("Did not find default endpoint, will use endpoint %d instead", device.MATTER_DEFAULT_ENDPOINT)) + return device.MATTER_DEFAULT_ENDPOINT end -local function device_added(driver, device) - local run_mode_eps = device:get_endpoints(clusters.RvcRunMode.ID) or {} - local clean_mode_eps = device:get_endpoints(clusters.RvcCleanMode.ID) or {} - local component_to_endpoint_map = { - ["main"] = run_mode_eps[1], - ["runMode"] = run_mode_eps[1], - ["cleanMode"] = clean_mode_eps[1] - } - device:set_field(COMPONENT_TO_ENDPOINT_MAP, component_to_endpoint_map, {persist = true}) -end - -local function device_init(driver, device) - device:subscribe() - device:set_component_to_endpoint_fn(component_to_endpoint) -end - -local function do_configure(driver, device) +local function match_profile(driver, device) local clean_mode_eps = device:get_endpoints(clusters.RvcCleanMode.ID) or {} local service_area_eps = embedded_cluster_utils.get_endpoints(device, clusters.ServiceArea.ID) or {} @@ -93,6 +81,25 @@ local function do_configure(driver, device) device.log.info_with({hub_logs = true}, string.format("Updating device profile to %s.", profile_name)) device:try_update_metadata({profile = profile_name}) +end + +local function device_init(driver, device) + device:subscribe() + + -- comp/ep map functionality removed 9/5/25. + device:set_field("__component_to_endpoint_map", nil) + + if not device:get_field(SERVICE_AREA_PROFILED) then + if #device:get_endpoints(clusters.ServiceArea.ID) > 0 then + match_profile(driver, device) + end + device:set_field(SERVICE_AREA_PROFILED, true, { persist = true }) + end +end + +local function do_configure(driver, device) + match_profile(driver, device) + device:set_field(SERVICE_AREA_PROFILED, true, { persist = true }) device:send(clusters.RvcOperationalState.attributes.AcceptedCommandList:read()) end @@ -159,7 +166,7 @@ local function can_send_state_command(device, command_name, current_state, curre return false end -local function update_supported_arguments(device, current_run_mode, current_state) +local function update_supported_arguments(device, ep, current_run_mode, current_state) device.log.info(string.format("update_supported_arguments: %s, %s", current_run_mode, current_state)) if current_run_mode == nil or current_state == nil then return @@ -170,15 +177,7 @@ local function update_supported_arguments(device, current_run_mode, current_stat local event = capabilities.robotCleanerOperatingState.supportedOperatingStateCommands( {}, {visibility = {displayed = false}} ) - device:emit_component_event(device.profile.components["main"], event) - -- Set runMode to empty - event = capabilities.mode.supportedArguments({}, {visibility = {displayed = false}}) - device:emit_component_event(device.profile.components["runMode"], event) - -- Set cleanMode to empty - local component = device.profile.components["cleanMode"] - if component ~= nil then - device:emit_component_event(component, event) - end + device:emit_event_for_endpoint(ep, event) return end @@ -198,7 +197,6 @@ local function update_supported_arguments(device, current_run_mode, current_stat -- Set Supported Operating State Commands local cap_op_cmds = capabilities.robotCleanerOperatingState.commands - local cap_op_enum = capabilities.robotCleanerOperatingState.operatingState local supported_op_commands = {} if can_send_state_command(device, cap_op_cmds.goHome.NAME, current_state, nil) == true then @@ -213,42 +211,7 @@ local function update_supported_arguments(device, current_run_mode, current_stat local event = capabilities.robotCleanerOperatingState.supportedOperatingStateCommands( supported_op_commands, {visibility = {displayed = false}} ) - device:emit_component_event(device.profile.components["main"], event) - - -- Check whether non-idle mode can be selected or not - local can_be_non_idle = false - if current_tag == clusters.RvcRunMode.types.ModeTag.IDLE and - (current_state == cap_op_enum.stopped.NAME or current_state == cap_op_enum.paused.NAME or - current_state == cap_op_enum.docked.NAME or current_state == cap_op_enum.charging.NAME) then - can_be_non_idle = true - end - - -- Set supported run arguments - local supported_arguments = {} -- For generic plugin - for _, mode in ipairs(supported_run_modes) do - if mode.tag == clusters.RvcRunMode.types.ModeTag.IDLE or can_be_non_idle == true then - table.insert(supported_arguments, mode.label) - end - end - - -- Send event to set supported run arguments - local component = device.profile.components["runMode"] - local event = capabilities.mode.supportedArguments(supported_arguments, {visibility = {displayed = false}}) - device:emit_component_event(component, event) - - -- Set supported clean arguments - local supported_clean_modes = device:get_field(CLEAN_MODE_SUPPORTED_MODES) or {} - supported_arguments = {} - for _, mode in ipairs(supported_clean_modes) do - table.insert(supported_arguments, mode.label) - end - - -- Send event to set supported clean modes - local component = device.profile.components["cleanMode"] - if component ~= nil then - local event = capabilities.mode.supportedArguments(supported_arguments, {visibility = {displayed = false}}) - device:emit_component_event(component, event) - end + device:emit_event_for_endpoint(ep, event) end -- Matter Handlers -- @@ -279,23 +242,14 @@ local function run_mode_supported_mode_handler(driver, device, ib, response) end device:set_field(RUN_MODE_SUPPORTED_MODES, supported_modes_id_tag, { persist = true }) - -- Update Supported Modes - local component = device.profile.components["runMode"] - local event = capabilities.mode.supportedModes(supported_modes, {visibility = {displayed = false}}) - device:emit_component_event(component, event) - -- Update Supported Arguments - local current_run_mode = device:get_latest_state( - "runMode", - capabilities.mode.ID, - capabilities.mode.mode.NAME - ) + local current_run_mode = device:get_field(CURRENT_RUN_MODE) local current_state = device:get_latest_state( "main", capabilities.robotCleanerOperatingState.ID, capabilities.robotCleanerOperatingState.operatingState.NAME ) - update_supported_arguments(device, current_run_mode, current_state) + update_supported_arguments(device, ib.endpoint_id, current_run_mode, current_state) end local function run_mode_current_mode_handler(driver, device, ib, response) @@ -315,8 +269,7 @@ local function run_mode_current_mode_handler(driver, device, ib, response) end -- Set current mode - local component = device.profile.components["runMode"] - device:emit_component_event(component, capabilities.mode.mode(current_run_mode)) + device:set_field(CURRENT_RUN_MODE, current_run_mode, { persist = true }) -- Update supported mode local current_state = device:get_latest_state( @@ -324,11 +277,10 @@ local function run_mode_current_mode_handler(driver, device, ib, response) capabilities.robotCleanerOperatingState.ID, capabilities.robotCleanerOperatingState.operatingState.NAME ) - update_supported_arguments(device, current_run_mode, current_state) + update_supported_arguments(device, ib.endpoint_id, current_run_mode, current_state) end local function clean_mode_supported_mode_handler(driver, device, ib, response) - device.log.info("clean_mode_supported_mode_handler") local supported_modes = {} local supported_modes_id = {} for _, mode in ipairs(ib.data.elements) do @@ -340,11 +292,10 @@ local function clean_mode_supported_mode_handler(driver, device, ib, response) end device:set_field(CLEAN_MODE_SUPPORTED_MODES, supported_modes_id, { persist = true }) - local component = device.profile.components["cleanMode"] local event = capabilities.mode.supportedModes(supported_modes, {visibility = {displayed = false}}) - device:emit_component_event(component, event) + device:emit_event_for_endpoint(ib.endpoint_id, event) event = capabilities.mode.supportedArguments(supported_modes, {visibility = {displayed = false}}) - device:emit_component_event(component, event) + device:emit_event_for_endpoint(ib.endpoint_id, event) end local function clean_mode_current_mode_handler(driver, device, ib, response) @@ -353,8 +304,7 @@ local function clean_mode_current_mode_handler(driver, device, ib, response) local supported_clean_mode = device:get_field(CLEAN_MODE_SUPPORTED_MODES) or {} for _, mode in ipairs(supported_clean_mode) do if mode.id == mode_id then - local component = device.profile.components["cleanMode"] - device:emit_component_event(component, capabilities.mode.mode(mode.label)) + device:emit_event_for_endpoint(ib.endpoint_id, capabilities.mode.mode(mode.label)) break end end @@ -378,15 +328,11 @@ local function rvc_operational_state_attr_handler(driver, device, ib, response) end -- Supported Mode update - local current_run_mode = device:get_latest_state( - "runMode", - capabilities.mode.ID, - capabilities.mode.mode.NAME - ) + local current_run_mode = device:get_field(CURRENT_RUN_MODE) if ib.data.value ~= clus_op_enum.ERROR then - update_supported_arguments(device, current_run_mode, OPERATING_STATE_MAP[ib.data.value].NAME) + update_supported_arguments(device, ib.endpoint_id, current_run_mode, OPERATING_STATE_MAP[ib.data.value].NAME) else - update_supported_arguments(device, current_run_mode, "Error") + update_supported_arguments(device, ib.endpoint_id, current_run_mode, "Error") end end @@ -438,11 +384,7 @@ local function handle_rvc_operational_state_accepted_command_list(driver, device device:set_field(OPERATING_STATE_SUPPORTED_COMMANDS, supportedOperatingStateCommands, { persist = true }) -- Get current run mode, current tag, current operating state - local current_run_mode = device:get_latest_state( - "runMode", - capabilities.mode.ID, - capabilities.mode.mode.NAME - ) + local current_run_mode = device:get_field(CURRENT_RUN_MODE) local current_tag = 0xFFFF local supported_run_modes = device:get_field(RUN_MODE_SUPPORTED_MODES) or {} for _, mode in ipairs(supported_run_modes) do @@ -478,7 +420,7 @@ local function handle_rvc_operational_state_accepted_command_list(driver, device local event = capabilities.robotCleanerOperatingState.supportedOperatingStateCommands( supported_op_commands, {visibility = {displayed = false}} ) - device:emit_component_event(device.profile.components["main"], event) + device:emit_event_for_endpoint(ib.endpoint_id, event) end local function upper_to_camelcase(name) @@ -523,9 +465,8 @@ local function rvc_service_area_supported_areas_handler(driver, device, ib, resp end -- Update Supported Areas - local component = device.profile.components["main"] local event = capabilities.serviceArea.supportedAreas(supported_areas, {visibility = {displayed = false}}) - device:emit_component_event(component, event) + device:emit_event_for_endpoint(ib.endpoint_id, event) end -- In case selected area is not in supportedarea then should i add to supported area or remove from selectedarea @@ -535,9 +476,8 @@ local function rvc_service_area_selected_areas_handler(driver, device, ib, respo table.insert(selected_areas, areaId.value) end - local component = device.profile.components["main"] local event = capabilities.serviceArea.selectedAreas(selected_areas, {visibility = {displayed = false}}) - device:emit_component_event(component, event) + device:emit_event_for_endpoint(ib.endpoint_id, event) end local function robot_cleaner_areas_selection_response_handler(driver, device, ib, response) @@ -552,23 +492,18 @@ local function robot_cleaner_areas_selection_response_handler(driver, device, ib else device.log.error(string.format("robot_cleaner_areas_selection_response_handler: %s, %s",status.pretty_print(status),status_text)) local selectedAreas = device:get_latest_state("main", capabilities.serviceArea.ID, capabilities.serviceArea.selectedAreas.NAME) - local component = device.profile.components["main"] local event = capabilities.serviceArea.selectedAreas(selectedAreas, {state_change = true}) - device:emit_component_event(component, event) + device:emit_event_for_endpoint(ib.endpoint_id, event) end end -- Capability Handlers -- local function handle_robot_cleaner_operating_state_start(driver, device, cmd) device.log.info("handle_robot_cleaner_operating_state_start") - local endpoint_id = device:component_to_endpoint(cmd.component) + local endpoint_id = find_default_endpoint(device, clusters.RvcOperationalState.ID) -- Get current run mode, current tag, current operating state - local current_run_mode = device:get_latest_state( - "runMode", - capabilities.mode.ID, - capabilities.mode.mode.NAME - ) + local current_run_mode = device:get_field(CURRENT_RUN_MODE) local current_tag = 0xFFFF local supported_run_modes = device:get_field(RUN_MODE_SUPPORTED_MODES) or {} for _, mode in ipairs(supported_run_modes) do @@ -594,7 +529,7 @@ local function handle_robot_cleaner_operating_state_start(driver, device, cmd) device:send(clusters.RvcOperationalState.commands.Resume(device, endpoint_id)) elseif can_send_state_command(device, capabilities.mode.commands.setMode.NAME, current_state, current_tag) == true then for _, mode in ipairs(supported_run_modes) do - endpoint_id = device:component_to_endpoint("runMode") + endpoint_id = find_default_endpoint(device, clusters.RvcOperationalState.ID) if mode.tag == clusters.RvcRunMode.types.ModeTag.CLEANING then device:send(clusters.RvcRunMode.commands.ChangeToMode(device, endpoint_id, mode.id)) return @@ -605,37 +540,26 @@ end local function handle_robot_cleaner_operating_state_pause(driver, device, cmd) device.log.info("handle_robot_cleaner_operating_state_pause") - local endpoint_id = device:component_to_endpoint(cmd.component) + local endpoint_id = find_default_endpoint(device, clusters.RvcOperationalState.ID) device:send(clusters.RvcOperationalState.commands.Pause(device, endpoint_id)) end local function handle_robot_cleaner_operating_state_go_home(driver, device, cmd) device.log.info("handle_robot_cleaner_operating_state_go_home") - local endpoint_id = device:component_to_endpoint(cmd.component) + local endpoint_id = find_default_endpoint(device, clusters.RvcOperationalState.ID) device:send(clusters.RvcOperationalState.commands.GoHome(device, endpoint_id)) end local function handle_robot_cleaner_mode(driver, device, cmd) device.log.info(string.format("handle_robot_cleaner_mode component: %s, mode: %s", cmd.component, cmd.args.mode)) - local endpoint_id = device:component_to_endpoint(cmd.component) - if cmd.component == "runMode" then - local supported_modes = device:get_field(RUN_MODE_SUPPORTED_MODES) or {} - for _, mode in ipairs(supported_modes) do - if cmd.args.mode == mode.label then - device.log.info(string.format("mode.label: %s, mode.id: %s", mode.label, mode.id)) - device:send(clusters.RvcRunMode.commands.ChangeToMode(device, endpoint_id, mode.id)) - return - end - end - elseif cmd.component == "cleanMode" then - local supported_modes = device:get_field(CLEAN_MODE_SUPPORTED_MODES) or {} - for _, mode in ipairs(supported_modes) do - if cmd.args.mode == mode.label then - device.log.info(string.format("mode.label: %s, mode.id: %s", mode.label, mode.id)) - device:send(clusters.RvcCleanMode.commands.ChangeToMode(device, endpoint_id, mode.id)) - return - end + local endpoint_id = find_default_endpoint(device, clusters.RvcOperationalState.ID) + local supported_modes = device:get_field(CLEAN_MODE_SUPPORTED_MODES) or {} + for _, mode in ipairs(supported_modes) do + if cmd.args.mode == mode.label then + device.log.info(string.format("mode.label: %s, mode.id: %s", mode.label, mode.id)) + device:send(clusters.RvcCleanMode.commands.ChangeToMode(device, endpoint_id, mode.id)) + return end end end @@ -648,7 +572,7 @@ local function handle_robot_cleaner_areas_selection(driver, device, cmd) for i, areaId in ipairs(cmd.args.areas) do table.insert(selectAreas, uint32_dt(areaId)) end - local endpoint_id = device:component_to_endpoint(cmd.component) + local endpoint_id = find_default_endpoint(device, clusters.RvcOperationalState.ID) if cmd.component == "main" then device:send(clusters.ServiceArea.commands.SelectAreas(device, endpoint_id, selectAreas)) end @@ -657,7 +581,6 @@ end local matter_rvc_driver = { lifecycle_handlers = { init = device_init, - added = device_added, doConfigure = do_configure, infoChanged = info_changed, }, diff --git a/drivers/SmartThings/matter-rvc/src/test/test_matter_rvc.lua b/drivers/SmartThings/matter-rvc/src/test/test_matter_rvc.lua index 5bed191802..c051f188fb 100644 --- a/drivers/SmartThings/matter-rvc/src/test/test_matter_rvc.lua +++ b/drivers/SmartThings/matter-rvc/src/test/test_matter_rvc.lua @@ -31,6 +31,7 @@ if version.api < 13 then end local APPLICATION_ENDPOINT = 10 +local SERVICE_AREA_PROFILED = "__SERVICE_AREA_PROFILED" local mock_device = test.mock_device.build_test_matter_device({ profile = t_utils.get_profile_definition("rvc-clean-mode-service-area.yml"), @@ -64,6 +65,7 @@ local mock_device = test.mock_device.build_test_matter_device({ }) local function test_init() + mock_device:set_field(SERVICE_AREA_PROFILED, true, { persist = true }) test.disable_startup_messages() test.mock_device.add_test_device(mock_device) local subscribed_attributes = { @@ -119,8 +121,6 @@ local RUN_MODES = { CLEANING_MODE, } -local RUN_MODE_LABELS = { RUN_MODES[1].label, RUN_MODES[2].label, RUN_MODES[3].label } - local CLEAN_MODE_1 = { label = "Clean Mode 1", mode = 0, mode_tags = { modeTagStruct({ mfg_code = 0x1E1E, value = 1 }) } } local CLEAN_MODE_2 = { label = "Clean Mode 2", mode = 1, mode_tags = { modeTagStruct({ mfg_code = 0x1E1E, value = 2 }) } } @@ -143,12 +143,6 @@ local function supported_run_mode_init() } ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedModes(RUN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) end local function supported_clean_mode_init() @@ -163,13 +157,13 @@ local function supported_clean_mode_init() }) test.socket.capability:__expect_send( mock_device:generate_test_message( - "cleanMode", + "main", capabilities.mode.supportedModes(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) ) ) test.socket.capability:__expect_send( mock_device:generate_test_message( - "cleanMode", + "main", capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) ) ) @@ -223,7 +217,7 @@ test.register_coroutine_test( ) test.register_coroutine_test( - "On changing the run mode to a mode with an IDLE tag, supportedArgument must be set to the appropriate value", function() + "On changing the run mode to a mode with an IDLE tag, supportedOperatingStateCommands must be set to the appropriate value", function() supported_run_mode_init() supported_clean_mode_init() operating_state_init() @@ -235,12 +229,6 @@ test.register_coroutine_test( IDLE_MODE.mode ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.mode({value = IDLE_MODE.label}) - ) - ) test.socket.capability:__expect_send( mock_device:generate_test_message( "main", @@ -253,23 +241,11 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments(RUN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) end ) test.register_coroutine_test( - "On changing the run mode to a mode with an CLEANING tag, supportedArgument must be set to the appropriate value", function() + "On changing the run mode to a mode with an CLEANING tag, supportedOperatingStateCommands must be set to the appropriate value", function() supported_run_mode_init() supported_clean_mode_init() operating_state_init() @@ -281,12 +257,6 @@ test.register_coroutine_test( CLEANING_MODE.mode ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.mode({value = CLEANING_MODE.label}) - ) - ) test.socket.capability:__expect_send( mock_device:generate_test_message( "main", @@ -296,23 +266,11 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments({ IDLE_MODE.label }, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) end ) test.register_coroutine_test( - "On changing the run mode to a mode with an MAPPING tag, supportedArgument must be set to the appropriate value", function() + "On changing the run mode to a mode with an MAPPING tag, supportedOperatingStateCommands must be set to the appropriate value", function() supported_run_mode_init() supported_clean_mode_init() operating_state_init() @@ -324,12 +282,6 @@ test.register_coroutine_test( MAPPING_MODE.mode ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.mode({value = MAPPING_MODE.label}) - ) - ) test.socket.capability:__expect_send( mock_device:generate_test_message( "main", @@ -339,18 +291,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments({ IDLE_MODE.label }, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) end ) @@ -370,7 +310,7 @@ test.register_coroutine_test( }) test.socket.capability:__expect_send( mock_device:generate_test_message( - "cleanMode", + "main", capabilities.mode.mode({value = cleanMode.label}) ) ) @@ -378,24 +318,6 @@ test.register_coroutine_test( end ) -test.register_coroutine_test( - "On changing the rvc run mode, appropriate RvcRunMode command must be sent to the device", function() - supported_run_mode_init() - operating_state_init() - test.wait_for_events() - for _, runMode in ipairs(RUN_MODES) do - test.socket.capability:__queue_receive({ - mock_device.id, - { capability = "mode", component = "runMode", command = "setMode", args = { runMode.label } } - }) - test.socket.matter:__expect_send({ - mock_device.id, - clusters.RvcRunMode.server.commands.ChangeToMode(mock_device, APPLICATION_ENDPOINT, runMode.mode) - }) - end - end -) - test.register_coroutine_test( "On changing the rvc clean mode, appropriate RvcCleanMode command must be sent to the device", function() supported_clean_mode_init() @@ -404,7 +326,7 @@ test.register_coroutine_test( for _, cleanMode in ipairs(CLEAN_MODES) do test.socket.capability:__queue_receive({ mock_device.id, - { capability = "mode", component = "cleanMode", command = "setMode", args = { cleanMode.label } } + { capability = "mode", component = "main", command = "setMode", args = { cleanMode.label } } }) test.socket.matter:__expect_send({ mock_device.id, @@ -415,7 +337,7 @@ test.register_coroutine_test( ) test.register_coroutine_test( - "On receive the Start Command, supportedArgument must be set to the appropriate value", function() + "On receive the start Command of the capability, ChangeToMode command must be sent to the device", function() supported_run_mode_init() supported_clean_mode_init() operating_state_init() @@ -428,12 +350,6 @@ test.register_coroutine_test( IDLE_MODE.mode ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.mode({value = IDLE_MODE.label}) - ) - ) test.socket.capability:__expect_send( mock_device:generate_test_message( "main", @@ -446,18 +362,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments(RUN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) test.wait_for_events() test.socket.capability:__queue_receive({ mock_device.id, @@ -471,7 +375,7 @@ test.register_coroutine_test( ) test.register_coroutine_test( - "On receive the goHome Command, supportedArgument must be set to the appropriate value", function() + "On receive the goHome Command of the capability, GoHome command must be sent to the device", function() supported_run_mode_init() supported_clean_mode_init() operating_state_init() @@ -484,12 +388,6 @@ test.register_coroutine_test( CLEANING_MODE.mode ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.mode({value = CLEANING_MODE.label}) - ) - ) test.socket.capability:__expect_send( mock_device:generate_test_message( "main", @@ -499,18 +397,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments({IDLE_MODE.label}, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) test.wait_for_events() test.socket.capability:__queue_receive({ mock_device.id, @@ -524,7 +410,7 @@ test.register_coroutine_test( ) test.register_coroutine_test( - "On receive the pause Command, supportedArgument must be set to the appropriate value", function() + "On receive the pause Command of the capability, Pause command must be sent to the device", function() supported_run_mode_init() supported_clean_mode_init() operating_state_init() @@ -537,12 +423,6 @@ test.register_coroutine_test( CLEANING_MODE.mode ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.mode({value = CLEANING_MODE.label}) - ) - ) test.socket.capability:__expect_send( mock_device:generate_test_message( "main", @@ -552,18 +432,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments({IDLE_MODE.label}, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) test.socket.matter:__queue_receive({ mock_device.id, clusters.RvcOperationalState.server.attributes.OperationalState:build_test_report_data( @@ -590,18 +458,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments({ IDLE_MODE.label }, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) test.wait_for_events() test.socket.capability:__queue_receive({ mock_device.id, @@ -627,12 +483,6 @@ test.register_coroutine_test( IDLE_MODE.mode ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.mode({value = IDLE_MODE.label}) - ) - ) test.socket.capability:__expect_send( mock_device:generate_test_message( "main", @@ -645,18 +495,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments(RUN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) test.socket.matter:__queue_receive({ mock_device.id, clusters.RvcOperationalState.server.attributes.OperationalState:build_test_report_data( @@ -680,18 +518,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments({ IDLE_MODE.label }, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) end ) @@ -708,12 +534,6 @@ test.register_coroutine_test( IDLE_MODE.mode ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.mode({value = IDLE_MODE.label}) - ) - ) test.socket.capability:__expect_send( mock_device:generate_test_message( "main", @@ -726,18 +546,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments(RUN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) test.socket.matter:__queue_receive({ mock_device.id, clusters.RvcOperationalState.server.attributes.OperationalState:build_test_report_data( @@ -764,18 +572,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments(RUN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) end ) @@ -792,12 +588,6 @@ test.register_coroutine_test( IDLE_MODE.mode ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.mode({value = IDLE_MODE.label}) - ) - ) test.socket.capability:__expect_send( mock_device:generate_test_message( "main", @@ -810,18 +600,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments(RUN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) test.socket.matter:__queue_receive({ mock_device.id, clusters.RvcOperationalState.server.attributes.OperationalState:build_test_report_data( @@ -848,18 +626,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments({ IDLE_MODE.label }, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) end ) @@ -876,12 +642,6 @@ test.register_coroutine_test( IDLE_MODE.mode ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.mode({value = IDLE_MODE.label}) - ) - ) test.socket.capability:__expect_send( mock_device:generate_test_message( "main", @@ -894,18 +654,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments(RUN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) test.socket.matter:__queue_receive({ mock_device.id, clusters.RvcOperationalState.server.attributes.OperationalState:build_test_report_data( @@ -929,18 +677,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments(RUN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) end ) @@ -957,12 +693,6 @@ test.register_coroutine_test( IDLE_MODE.mode ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.mode({value = IDLE_MODE.label}) - ) - ) test.socket.capability:__expect_send( mock_device:generate_test_message( "main", @@ -975,18 +705,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments(RUN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) test.socket.matter:__queue_receive({ mock_device.id, clusters.RvcOperationalState.server.attributes.OperationalState:build_test_report_data( @@ -1010,18 +728,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments(RUN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) end ) @@ -1038,12 +744,6 @@ test.register_coroutine_test( IDLE_MODE.mode ) }) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.mode({value = IDLE_MODE.label}) - ) - ) test.socket.capability:__expect_send( mock_device:generate_test_message( "main", @@ -1056,18 +756,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments(RUN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments(CLEAN_MODE_LABELS, { visibility = { displayed = false } }) - ) - ) test.socket.matter:__queue_receive({ mock_device.id, clusters.RvcOperationalState.server.attributes.OperationalState:build_test_report_data( @@ -1085,18 +773,6 @@ test.register_coroutine_test( ) ) ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "runMode", - capabilities.mode.supportedArguments({}, { visibility = { displayed = false } }) - ) - ) - test.socket.capability:__expect_send( - mock_device:generate_test_message( - "cleanMode", - capabilities.mode.supportedArguments({}, { visibility = { displayed = false } }) - ) - ) test.socket.matter:__queue_receive({ mock_device.id, clusters.RvcOperationalState.server.attributes.OperationalError:build_test_report_data(