-
Notifications
You must be signed in to change notification settings - Fork 534
Support Closure device type #2875
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
nickolas-deboom
wants to merge
4
commits into
main
Choose a base branch
from
feature/closure-device-type
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
4 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
56 changes: 56 additions & 0 deletions
56
drivers/SmartThings/matter-window-covering/profiles/covering.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,56 @@ | ||
| name: covering | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: windowShade | ||
| version: 1 | ||
| - id: windowShadeLevel | ||
| version: 1 | ||
| optional: true | ||
| - id: battery | ||
| version: 1 | ||
| optional: true | ||
| - id: batteryLevel | ||
| version: 1 | ||
| optional: true | ||
| - id: firmwareUpdate | ||
| version: 1 | ||
| - id: refresh | ||
| version: 1 | ||
| categories: | ||
| - name: Blind | ||
| - id: windowShade1 | ||
| optional: true | ||
| capabilities: | ||
| - id: windowShadeLevel | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: Blind | ||
| - id: windowShade2 | ||
| optional: true | ||
| capabilities: | ||
| - id: windowShadeLevel | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: Blind | ||
| - id: windowShade3 | ||
| optional: true | ||
| capabilities: | ||
| - id: windowShadeLevel | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: Blind | ||
| - id: windowShade4 | ||
| optional: true | ||
| capabilities: | ||
| - id: windowShadeLevel | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: Blind | ||
| preferences: | ||
| - preferenceId: reverse | ||
| explicit: true | ||
56 changes: 56 additions & 0 deletions
56
drivers/SmartThings/matter-window-covering/profiles/door.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,56 @@ | ||
| name: door | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: doorControl | ||
| version: 1 | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| - id: battery | ||
| version: 1 | ||
| optional: true | ||
| - id: batteryLevel | ||
| version: 1 | ||
| optional: true | ||
| - id: firmwareUpdate | ||
| version: 1 | ||
| - id: refresh | ||
| version: 1 | ||
| categories: | ||
| - name: Door | ||
| - id: door1 | ||
| optional: true | ||
| capabilities: | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: Door | ||
| - id: door2 | ||
| optional: true | ||
| capabilities: | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: Door | ||
| - id: door3 | ||
| optional: true | ||
| capabilities: | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: Door | ||
| - id: door4 | ||
| optional: true | ||
| capabilities: | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: Door | ||
| preferences: | ||
| - preferenceId: reverse | ||
| explicit: true |
56 changes: 56 additions & 0 deletions
56
drivers/SmartThings/matter-window-covering/profiles/garage-door.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,56 @@ | ||
| name: garage-door | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: doorControl | ||
| version: 1 | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| - id: battery | ||
| version: 1 | ||
| optional: true | ||
| - id: batteryLevel | ||
| version: 1 | ||
| optional: true | ||
| - id: firmwareUpdate | ||
| version: 1 | ||
| - id: refresh | ||
| version: 1 | ||
| categories: | ||
| - name: GarageDoor | ||
| - id: door1 | ||
| optional: true | ||
| capabilities: | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: GarageDoor | ||
| - id: door2 | ||
| optional: true | ||
| capabilities: | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: GarageDoor | ||
| - id: door3 | ||
| optional: true | ||
| capabilities: | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: GarageDoor | ||
| - id: door4 | ||
| optional: true | ||
| capabilities: | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: GarageDoor | ||
| preferences: | ||
| - preferenceId: reverse | ||
| explicit: true |
56 changes: 56 additions & 0 deletions
56
drivers/SmartThings/matter-window-covering/profiles/gate.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,56 @@ | ||
| name: gate | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: doorControl | ||
| version: 1 | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| - id: battery | ||
| version: 1 | ||
| optional: true | ||
| - id: batteryLevel | ||
| version: 1 | ||
| optional: true | ||
| - id: firmwareUpdate | ||
| version: 1 | ||
| - id: refresh | ||
| version: 1 | ||
| categories: | ||
| - name: Door | ||
| - id: door1 | ||
| optional: true | ||
| capabilities: | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: Door | ||
| - id: door2 | ||
| optional: true | ||
| capabilities: | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: Door | ||
| - id: door3 | ||
| optional: true | ||
| capabilities: | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: Door | ||
| - id: door4 | ||
| optional: true | ||
| capabilities: | ||
| - id: level | ||
| version: 1 | ||
| optional: true | ||
| categories: | ||
| - name: Door | ||
| preferences: | ||
| - preferenceId: reverse | ||
| explicit: true |
97 changes: 97 additions & 0 deletions
97
drivers/SmartThings/matter-window-covering/src/embedded_clusters/ClosureControl/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,97 @@ | ||
| local cluster_base = require "st.matter.cluster_base" | ||
| local ClosureControlServerAttributes = require "embedded_clusters.ClosureControl.server.attributes" | ||
| local ClosureControlServerCommands = require "embedded_clusters.ClosureControl.server.commands" | ||
| local ClosureControlTypes = require "embedded_clusters.ClosureControl.types" | ||
|
|
||
| local ClosureControl = {} | ||
|
|
||
| ClosureControl.ID = 0x0104 | ||
| ClosureControl.NAME = "ClosureControl" | ||
| ClosureControl.server = {} | ||
| ClosureControl.client = {} | ||
| ClosureControl.server.attributes = ClosureControlServerAttributes:set_parent_cluster(ClosureControl) | ||
| ClosureControl.server.commands = ClosureControlServerCommands:set_parent_cluster(ClosureControl) | ||
| ClosureControl.types = ClosureControlTypes | ||
|
|
||
| function ClosureControl:get_attribute_by_id(attr_id) | ||
| local attr_id_map = { | ||
| [0x0000] = "CountdownTime", | ||
| [0x0001] = "MainState", | ||
| [0x0002] = "CurrentErrorList", | ||
| [0x0003] = "OverallCurrentState", | ||
| [0x0004] = "OverallTargetState", | ||
| [0x0005] = "LatchControlModes", | ||
| [0xFFF9] = "AcceptedCommandList", | ||
| [0xFFFB] = "AttributeList", | ||
| } | ||
| local attr_name = attr_id_map[attr_id] | ||
| if attr_name ~= nil then | ||
| return self.attributes[attr_name] | ||
| end | ||
| return nil | ||
| end | ||
|
|
||
| function ClosureControl:get_server_command_by_id(command_id) | ||
| local server_id_map = { | ||
| [0x0000] = "Stop", | ||
| [0x0001] = "MoveTo", | ||
| [0x0002] = "Calibrate", | ||
| } | ||
| if server_id_map[command_id] ~= nil then | ||
| return self.server.commands[server_id_map[command_id]] | ||
| end | ||
| return nil | ||
| end | ||
|
|
||
|
|
||
| ClosureControl.attribute_direction_map = { | ||
| ["CountdownTime"] = "server", | ||
| ["MainState"] = "server", | ||
| ["CurrentErrorList"] = "server", | ||
| ["OverallCurrentState"] = "server", | ||
| ["OverallTargetState"] = "server", | ||
| ["LatchControlModes"] = "server", | ||
| ["AcceptedCommandList"] = "server", | ||
| ["AttributeList"] = "server", | ||
| } | ||
|
|
||
| ClosureControl.command_direction_map = { | ||
| ["Stop"] = "server", | ||
| ["MoveTo"] = "server", | ||
| ["Calibrate"] = "server", | ||
| } | ||
|
|
||
| ClosureControl.FeatureMap = ClosureControl.types.Feature | ||
|
|
||
| function ClosureControl.are_features_supported(feature, feature_map) | ||
| if (ClosureControl.FeatureMap.bits_are_valid(feature)) then | ||
| return (feature & feature_map) == feature | ||
| end | ||
| return false | ||
| end | ||
|
|
||
| local attribute_helper_mt = {} | ||
| attribute_helper_mt.__index = function(self, key) | ||
| local direction = ClosureControl.attribute_direction_map[key] | ||
| if direction == nil then | ||
| error(string.format("Referenced unknown attribute %s on cluster %s", key, ClosureControl.NAME)) | ||
| end | ||
| return ClosureControl[direction].attributes[key] | ||
| end | ||
| ClosureControl.attributes = {} | ||
| setmetatable(ClosureControl.attributes, attribute_helper_mt) | ||
|
|
||
| local command_helper_mt = {} | ||
| command_helper_mt.__index = function(self, key) | ||
| local direction = ClosureControl.command_direction_map[key] | ||
| if direction == nil then | ||
| error(string.format("Referenced unknown command %s on cluster %s", key, ClosureControl.NAME)) | ||
| end | ||
| return ClosureControl[direction].commands[key] | ||
| end | ||
| ClosureControl.commands = {} | ||
| setmetatable(ClosureControl.commands, command_helper_mt) | ||
|
|
||
| setmetatable(ClosureControl, {__index = cluster_base}) | ||
|
|
||
| return ClosureControl |
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.
Why are there multiple components in each of these profiles, and why are there 4 in each? Is 4 an arbitrarily selection?
Uh oh!
There was an error while loading. Please reload this page.
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.
Right, 4 is arbitrary since i wasn't sure how many closure panels to typically expect (the spec just says 0+). The example devices I've seen so far have only had up to 2 so I think 4 should be good however I will define this as a constant as you suggested in another comment
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.
To clarify, a closure consists of 1 endpoint implementing the ClosureControl cluster and then any number of endpoints of the Closure Panel device type that each implement the ClosureDimension cluster. So the number of components in these profiles that are used would reflect the number of ClosureDimension endpoints.