-
Notifications
You must be signed in to change notification settings - Fork 544
Matter Switch: Add garage door profile and device override #2702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hcarter-775
wants to merge
2
commits into
main
Choose a base branch
from
add-garage-door-binary
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
drivers/SmartThings/matter-switch/profiles/garage-door-battery.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| name: garage-door-battery | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: doorControl | ||
| version: 1 | ||
| - id: battery | ||
| version: 1 | ||
| - id: firmwareUpdate | ||
| version: 1 | ||
| - id: refresh | ||
| version: 1 | ||
| categories: | ||
| - name: GarageDoor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
drivers/SmartThings/matter-switch/src/sub_drivers/third_reality_garage_door/can_handle.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| -- Copyright 2026 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local utils = require "switch_utils.utils" | ||
|
|
||
| return function(opts, driver, device) | ||
| if utils.get_product_override_field(device, "is_third_reality_garage_door") then | ||
| return true, require("sub_drivers.third_reality_garage_door") | ||
| end | ||
| return false | ||
| end |
92 changes: 92 additions & 0 deletions
92
drivers/SmartThings/matter-switch/src/sub_drivers/third_reality_garage_door/init.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| -- Copyright © 2026 SmartThings, Inc. | ||
| -- Licensed under the Apache License, Version 2.0 | ||
|
|
||
| local capabilities = require "st.capabilities" | ||
| local clusters = require "st.matter.clusters" | ||
|
|
||
| ------------------------------------------------------------------------------------- | ||
| -- Third Reality Garage Door Opener specifics | ||
| -- | ||
| -- This device uses the OnOff cluster to control the door: | ||
| -- OnOff = true -> door open | ||
| -- OnOff = false -> door closed | ||
| -- Commands are mapped from doorControl capability to OnOff cluster commands. | ||
| ------------------------------------------------------------------------------------- | ||
|
|
||
| local function device_init(driver, device) | ||
| -- Force a subscription to the OnOff cluster, since doorControl does not explicitly map to it in the default driver. | ||
| device:add_subscribed_attribute(clusters.OnOff.attributes.OnOff) | ||
| device:add_subscribed_attribute(clusters.PowerSource.attributes.BatPercentRemaining) | ||
| device:subscribe() | ||
| end | ||
|
|
||
| local function match_profile(driver, device) | ||
| device:try_update_metadata({profile = "garage-door-battery"}) | ||
| end | ||
|
|
||
| -- Prevent any of the main driver's logic from running | ||
| local function device_added(driver, device) end | ||
|
|
||
| -- Prevent any of the main driver's logic from running | ||
| local function info_changed(driver, device, event, args) end | ||
|
|
||
| local function do_configure(driver, device) | ||
| match_profile(driver, device) | ||
| end | ||
|
|
||
| local function driver_switched(driver, device) | ||
| match_profile(driver, device) | ||
| device:try_update_metadata({provisioning_state = "PROVISIONED"}) | ||
| end | ||
|
|
||
|
|
||
| local function on_off_attr_handler(driver, device, ib, response) | ||
| if ib.data.value then | ||
| device:emit_event_for_endpoint(ib.endpoint_id, capabilities.doorControl.door.open()) | ||
| else | ||
| device:emit_event_for_endpoint(ib.endpoint_id, capabilities.doorControl.door.closed()) | ||
| end | ||
| end | ||
|
|
||
| local function handle_door_open(driver, device, cmd) | ||
| local endpoint_id = device:component_to_endpoint(cmd.component) | ||
| device:emit_event_for_endpoint(endpoint_id, capabilities.doorControl.door.opening()) | ||
| device:send(clusters.OnOff.server.commands.On(device, endpoint_id)) | ||
| end | ||
|
|
||
| local function handle_door_close(driver, device, cmd) | ||
| local endpoint_id = device:component_to_endpoint(cmd.component) | ||
| device:emit_event_for_endpoint(endpoint_id, capabilities.doorControl.door.closing()) | ||
| device:send(clusters.OnOff.server.commands.Off(device, endpoint_id)) | ||
| end | ||
|
|
||
| local third_reality_garage_door_handler = { | ||
| NAME = "ThirdReality Garage Door Handler", | ||
| lifecycle_handlers = { | ||
| init = device_init, | ||
| added = device_added, | ||
| doConfigure = do_configure, | ||
| driverSwitched = driver_switched, | ||
| infoChanged = info_changed, | ||
| }, | ||
| matter_handlers = { | ||
| attr = { | ||
| [clusters.OnOff.ID] = { | ||
| [clusters.OnOff.attributes.OnOff.ID] = on_off_attr_handler, | ||
| }, | ||
| }, | ||
| }, | ||
| capability_handlers = { | ||
| [capabilities.doorControl.ID] = { | ||
| [capabilities.doorControl.commands.open.NAME] = handle_door_open, | ||
| [capabilities.doorControl.commands.close.NAME] = handle_door_close, | ||
| }, | ||
| }, | ||
| supported_capabilities = { | ||
| capabilities.doorControl, | ||
| capabilities.battery, | ||
| }, | ||
| can_handle = require("sub_drivers.third_reality_garage_door.can_handle") | ||
| } | ||
|
|
||
| return third_reality_garage_door_handler | ||
7 changes: 2 additions & 5 deletions
7
drivers/SmartThings/matter-switch/src/sub_drivers/third_reality_mk1/can_handle.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to set the device state to
PROVISIONEDhere?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we do, added!