-
Notifications
You must be signed in to change notification settings - Fork 523
Add support for additional Closure device types #2751
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
1
commit into
migrate-window-covering-driver-to-matter-switch
Choose a base branch
from
support-additional-closure-types
base: migrate-window-covering-driver-to-matter-switch
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
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
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,21 @@ | ||
| name: covering | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: windowShade | ||
| version: 1 | ||
| - id: battery | ||
| version: 1 | ||
| optional: true | ||
| - id: batteryLevel | ||
| version: 1 | ||
| optional: true | ||
| - id: firmwareUpdate | ||
| version: 1 | ||
| - id: refresh | ||
| version: 1 | ||
| categories: | ||
| - name: Blind | ||
| preferences: | ||
| - preferenceId: reverse | ||
| explicit: true |
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,18 @@ | ||
| name: door | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: doorControl | ||
| version: 1 | ||
| - id: battery | ||
| version: 1 | ||
| optional: true | ||
| - id: batteryLevel | ||
| version: 1 | ||
| optional: true | ||
| - id: firmwareUpdate | ||
| version: 1 | ||
| - id: refresh | ||
| version: 1 | ||
| categories: | ||
| - name: Door |
18 changes: 18 additions & 0 deletions
18
drivers/SmartThings/matter-switch/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,18 @@ | ||
| name: garage-door | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: doorControl | ||
| version: 1 | ||
| - id: battery | ||
| version: 1 | ||
| optional: true | ||
| - id: batteryLevel | ||
| version: 1 | ||
| optional: true | ||
| - 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| name: gate | ||
| components: | ||
| - id: main | ||
| capabilities: | ||
| - id: doorControl | ||
| version: 1 | ||
| - id: battery | ||
| version: 1 | ||
| optional: true | ||
| - id: batteryLevel | ||
| version: 1 | ||
| optional: true | ||
| - id: firmwareUpdate | ||
| version: 1 | ||
| - id: refresh | ||
| version: 1 | ||
| categories: | ||
| - name: Door | ||
97 changes: 97 additions & 0 deletions
97
drivers/SmartThings/matter-switch/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 |
74 changes: 74 additions & 0 deletions
74
...ter-switch/src/embedded_clusters/ClosureControl/server/attributes/AcceptedCommandList.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,74 @@ | ||
| local cluster_base = require "st.matter.cluster_base" | ||
| local data_types = require "st.matter.data_types" | ||
| local TLVParser = require "st.matter.TLV.TLVParser" | ||
|
|
||
| local AcceptedCommandList = { | ||
| ID = 0xFFF9, | ||
| NAME = "AcceptedCommandList", | ||
| base_type = require "st.matter.data_types.Array", | ||
| element_type = require "st.matter.data_types.Uint32", | ||
| } | ||
|
|
||
| function AcceptedCommandList:augment_type(data_type_obj) | ||
| for i, v in ipairs(data_type_obj.elements) do | ||
| data_type_obj.elements[i] = data_types.validate_or_build_type(v, AcceptedCommandList.element_type) | ||
| end | ||
| end | ||
|
|
||
| function AcceptedCommandList:new_value(...) | ||
| local o = self.base_type(table.unpack({...})) | ||
|
|
||
| return o | ||
| end | ||
|
|
||
| function AcceptedCommandList:read(device, endpoint_id) | ||
| return cluster_base.read( | ||
| device, | ||
| endpoint_id, | ||
| self._cluster.ID, | ||
| self.ID, | ||
| nil | ||
| ) | ||
| end | ||
|
|
||
| function AcceptedCommandList:subscribe(device, endpoint_id) | ||
| return cluster_base.subscribe( | ||
| device, | ||
| endpoint_id, | ||
| self._cluster.ID, | ||
| self.ID, | ||
| nil | ||
| ) | ||
| end | ||
|
|
||
| function AcceptedCommandList:set_parent_cluster(cluster) | ||
| self._cluster = cluster | ||
| return self | ||
| end | ||
|
|
||
| function AcceptedCommandList:build_test_report_data( | ||
| device, | ||
| endpoint_id, | ||
| value, | ||
| status | ||
| ) | ||
| local data = data_types.validate_or_build_type(value, self.base_type) | ||
|
|
||
| return cluster_base.build_test_report_data( | ||
| device, | ||
| endpoint_id, | ||
| self._cluster.ID, | ||
| self.ID, | ||
| data, | ||
| status | ||
| ) | ||
| end | ||
|
|
||
| function AcceptedCommandList:deserialize(tlv_buf) | ||
| local data = TLVParser.decode_tlv(tlv_buf) | ||
|
|
||
| return data | ||
| end | ||
|
|
||
| setmetatable(AcceptedCommandList, {__call = AcceptedCommandList.new_value, __index = AcceptedCommandList.base_type}) | ||
| return AcceptedCommandList |
74 changes: 74 additions & 0 deletions
74
...gs/matter-switch/src/embedded_clusters/ClosureControl/server/attributes/AttributeList.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,74 @@ | ||
| local cluster_base = require "st.matter.cluster_base" | ||
| local data_types = require "st.matter.data_types" | ||
| local TLVParser = require "st.matter.TLV.TLVParser" | ||
|
|
||
| local AttributeList = { | ||
| ID = 0xFFFB, | ||
| NAME = "AttributeList", | ||
| base_type = require "st.matter.data_types.Array", | ||
| element_type = require "st.matter.data_types.Uint32", | ||
| } | ||
|
|
||
| function AttributeList:augment_type(data_type_obj) | ||
| for i, v in ipairs(data_type_obj.elements) do | ||
| data_type_obj.elements[i] = data_types.validate_or_build_type(v, AttributeList.element_type) | ||
| end | ||
| end | ||
|
|
||
| function AttributeList:new_value(...) | ||
| local o = self.base_type(table.unpack({...})) | ||
|
|
||
| return o | ||
| end | ||
|
|
||
| function AttributeList:read(device, endpoint_id) | ||
| return cluster_base.read( | ||
| device, | ||
| endpoint_id, | ||
| self._cluster.ID, | ||
| self.ID, | ||
| nil | ||
| ) | ||
| end | ||
|
|
||
| function AttributeList:subscribe(device, endpoint_id) | ||
| return cluster_base.subscribe( | ||
| device, | ||
| endpoint_id, | ||
| self._cluster.ID, | ||
| self.ID, | ||
| nil | ||
| ) | ||
| end | ||
|
|
||
| function AttributeList:set_parent_cluster(cluster) | ||
| self._cluster = cluster | ||
| return self | ||
| end | ||
|
|
||
| function AttributeList:build_test_report_data( | ||
| device, | ||
| endpoint_id, | ||
| value, | ||
| status | ||
| ) | ||
| local data = data_types.validate_or_build_type(value, self.base_type) | ||
|
|
||
| return cluster_base.build_test_report_data( | ||
| device, | ||
| endpoint_id, | ||
| self._cluster.ID, | ||
| self.ID, | ||
| data, | ||
| status | ||
| ) | ||
| end | ||
|
|
||
| function AttributeList:deserialize(tlv_buf) | ||
| local data = TLVParser.decode_tlv(tlv_buf) | ||
|
|
||
| return data | ||
| end | ||
|
|
||
| setmetatable(AttributeList, {__call = AttributeList.new_value, __index = AttributeList.base_type}) | ||
| return AttributeList |
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.
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.
A request for a new Gate category has been opened, and once that's published we can update the category here to reflect that