-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add version branching to support AttributeList reads during configure
This also adds an AttributeList attribute class to the driver which may not be present in Lua library api versions <=2
- Loading branch information
Showing
4 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
119 changes: 119 additions & 0 deletions
119
drivers/SmartThings/matter-thermostat/src/AttributeList.lua
This file contains 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,119 @@ | ||
-- Copyright 2022 SmartThings | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the "License"); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- http://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an "AS IS" BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
|
||
-- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator. | ||
|
||
|
||
--Note this file is present in the driver package in case it is not available in the lua libs on | ||
-- the hub. It will be required for any API version <= 2. It will be removed by SmartThings once | ||
-- all hub platforms running the driver support an API version greater than 2 | ||
local cluster_base = require "st.matter.cluster_base" | ||
local data_types = require "st.matter.data_types" | ||
local TLVParser = require "st.matter.TLV.TLVParser" | ||
|
||
--- @class st.matter.clusters.Thermostat.AttributeList | ||
--- @alias AttributeList | ||
--- | ||
--- @field public ID number 0xFFFB the ID of this attribute | ||
--- @field public NAME string "AttributeList" the name of this attribute | ||
--- @field public data_type st.matter.data_types.Array the data type of this attribute | ||
|
||
local AttributeList = { | ||
ID = 0xFFFB, | ||
NAME = "AttributeList", | ||
base_type = data_types.Array, | ||
} | ||
--- Create a Array object of this attribute with any additional features provided for the attribute | ||
--- This is also usable with the AttributeList(...) syntax | ||
--- | ||
--- @vararg vararg the values needed to construct a Array | ||
--- @return st.matter.data_types.Array | ||
function AttributeList:new_value(...) | ||
local o = self.base_type(table.unpack({...})) | ||
|
||
return o | ||
end | ||
|
||
--- Constructs an st.matter.interaction_model.InteractionRequest to read | ||
--- this attribute from a device | ||
--- @param device st.matter.Device | ||
--- @param endpoint_id number|nil | ||
--- @return st.matter.interaction_model.InteractionRequest containing an Interaction Request | ||
function AttributeList:read(device, endpoint_id) | ||
return cluster_base.read( | ||
device, | ||
endpoint_id, | ||
self._cluster.ID, | ||
self.ID, | ||
nil --event_id | ||
) | ||
end | ||
|
||
|
||
--- Reporting policy: AttributeList => true => mandatory | ||
|
||
--- Sets up a Subscribe Interaction | ||
--- | ||
--- @param device any | ||
--- @param endpoint_id number|nil | ||
--- @return any | ||
function AttributeList:subscribe(device, endpoint_id) | ||
return cluster_base.subscribe( | ||
device, | ||
endpoint_id, | ||
self._cluster.ID, | ||
self.ID, | ||
nil --event_id | ||
) | ||
end | ||
|
||
function AttributeList:set_parent_cluster(cluster) | ||
self._cluster = cluster | ||
return self | ||
end | ||
|
||
--- Builds an AttributeList test attribute reponse for the driver integration testing framework | ||
--- | ||
--- @param device st.matter.Device the device to build this message for | ||
--- @param endpoint_id number|nil | ||
--- @param value any | ||
--- @param status string Interaction status associated with the path | ||
--- @return st.matter.interaction_model.InteractionResponse of type REPORT_DATA | ||
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}) | ||
return AttributeList | ||
|
This file contains 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 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 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