Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions drivers/SmartThings/matter-switch/profiles/3-button-motion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 3-button-motion
components:
- id: main
capabilities:
- id: button
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
categories:
- name: RemoteController
- id: button2
capabilities:
- id: button
version: 1
categories:
- name: RemoteController
- id: button3
capabilities:
- id: button
version: 1
categories:
- name: RemoteController
- id: motion
capabilities:
- id: motionSensor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'm wondering why we're putting motion on its own component in the first place? Seems like this should be in the main component. Same for the other

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, our current process is to put all capabilities that don't require special handling to be placed on the main component. Doing this will make the changes in the component map moot, and the event should be emitted on main by default. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, that's a good callout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have tried this modification before, but the results are somewhat different from what we expected. We put the details in the comments on this page (https://smartthings.atlassian.net/browse/MTR-939). Please review.

version: 1
categories:
- name: MotionSensor
48 changes: 48 additions & 0 deletions drivers/SmartThings/matter-switch/profiles/6-button-motion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: 6-button-motion
components:
- id: main
capabilities:
- id: button
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
categories:
- name: RemoteController
- id: button2
capabilities:
- id: button
version: 1
categories:
- name: RemoteController
- id: button3
capabilities:
- id: button
version: 1
categories:
- name: RemoteController
- id: button4
capabilities:
- id: button
version: 1
categories:
- name: RemoteController
- id: button5
capabilities:
- id: button
version: 1
categories:
- name: RemoteController
- id: button6
capabilities:
- id: button
version: 1
categories:
- name: RemoteController
- id: motion
capabilities:
- id: motionSensor
version: 1
categories:
- name: MotionSensor
19 changes: 13 additions & 6 deletions drivers/SmartThings/matter-switch/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ local function find_child(parent, ep_id)
return parent:get_child_by_parent_assigned_key(string.format("%d", ep_id))
end

local function build_button_component_map(device, main_endpoint, button_eps)
-- create component mapping on the main profile button endpoints
local function build_button_component_map(device, main_endpoint, button_eps, motion_eps)
-- create component mapping on the main profile button endpoints and motion endpoint
table.sort(button_eps)
local component_map = {}
component_map["main"] = main_endpoint
Expand All @@ -572,14 +572,20 @@ local function build_button_component_map(device, main_endpoint, button_eps)
component_map[button_component] = ep
end
end
if #motion_eps > 0 then
component_map["motion"] = motion_eps[1]
end
device:set_field(COMPONENT_TO_ENDPOINT_MAP, component_map, {persist = true})
end

local function build_button_profile(device, main_endpoint, num_button_eps)
local function build_button_profile(device, main_endpoint, num_button_eps, num_motion_eps)
local profile_name = string.gsub(num_button_eps .. "-button", "1%-", "") -- remove the "1-" in a device with 1 button ep
if device_type_supports_button_switch_combination(device, main_endpoint) then
profile_name = "light-level-" .. profile_name
end
if num_motion_eps > 0 then
profile_name = profile_name .. "-motion"
end
local battery_supported = #device:get_endpoints(clusters.PowerSource.ID, {feature_bitmap = clusters.PowerSource.types.PowerSourceFeature.BATTERY}) > 0
if battery_supported then -- battery profiles are configured later, in power_source_attribute_list_handler
device:send(clusters.PowerSource.attributes.AttributeList:read(device))
Expand Down Expand Up @@ -651,11 +657,12 @@ end
local function initialize_buttons_and_switches(driver, device, main_endpoint)
local profile_found = false
local button_eps = device:get_endpoints(clusters.Switch.ID, {feature_bitmap=clusters.Switch.types.SwitchFeature.MOMENTARY_SWITCH})
local motion_eps = device:get_endpoints(clusters.OccupancySensing.ID)
if tbl_contains(STATIC_BUTTON_PROFILE_SUPPORTED, #button_eps) then
build_button_profile(device, main_endpoint, #button_eps)
build_button_profile(device, main_endpoint, #button_eps, #motion_eps)
-- All button endpoints found will be added as additional components in the profile containing the main_endpoint.
-- The resulting endpoint to component map is saved in the COMPONENT_TO_ENDPOINT_MAP field
build_button_component_map(device, main_endpoint, button_eps)
build_button_component_map(device, main_endpoint, button_eps, motion_eps)
configure_buttons(device)
profile_found = true
end
Expand Down Expand Up @@ -1129,7 +1136,7 @@ local function illuminance_attr_handler(driver, device, ib, response)
end

local function occupancy_attr_handler(driver, device, ib, response)
device:emit_event(ib.data.value == 0x01 and capabilities.motionSensor.motion.active() or capabilities.motionSensor.motion.inactive())
device:emit_event_for_endpoint(ib.endpoint_id, ib.data.value == 0x01 and capabilities.motionSensor.motion.active() or capabilities.motionSensor.motion.inactive())
end

local function cumul_energy_imported_handler(driver, device, ib, response)
Expand Down
Loading
Loading