Skip to content

Commit 4b76b1c

Browse files
Add support for ResetCondition command
This commit adds support for the ResetCondition command for the ActivatedCarbonFilterMonitoring and HepaFilterMonitoring clusters. Also, thermostatOperatingState is removed from air-purifier-hepa-ac-rock-wind-thermostat-humidity-fan-heating-only-nostate-nobattery-aqs-pm10-pm25-ch2o-meas-pm10-pm25-ch2o-no2-tvoc-level, which should not have included this capability.
1 parent 8a15a34 commit 4b76b1c

13 files changed

+329
-221
lines changed

drivers/SmartThings/matter-thermostat/profiles/air-purifier-hepa-ac-rock-wind-thermostat-humidity-fan-heating-only-nostate-nobattery-aqs-pm10-pm25-ch2o-meas-pm10-pm25-ch2o-no2-tvoc-level.yml

-8
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ components:
3535
version: 1
3636
- id: tvocHealthConcern
3737
version: 1
38-
- id: thermostatOperatingState
39-
version: 1
40-
config:
41-
values:
42-
- key: "thermostatOperatingState.value"
43-
enabledValues:
44-
- idle
45-
- heating
4638
- id: firmwareUpdate
4739
version: 1
4840
- id: refresh

drivers/SmartThings/matter-thermostat/src/ActivatedCarbonFilterMonitoring/init.lua

+23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
local cluster_base = require "st.matter.cluster_base"
22
local ActivatedCarbonFilterMonitoringServerAttributes = require "ActivatedCarbonFilterMonitoring.server.attributes"
3+
local ActivatedCarbonFilterMonitoringServerCommands = require "ActivatedCarbonFilterMonitoring.server.commands"
34
local ActivatedCarbonFilterMonitoringTypes = require "ActivatedCarbonFilterMonitoring.types"
45

56
local ActivatedCarbonFilterMonitoring = {}
@@ -9,6 +10,7 @@ ActivatedCarbonFilterMonitoring.NAME = "ActivatedCarbonFilterMonitoring"
910
ActivatedCarbonFilterMonitoring.server = {}
1011
ActivatedCarbonFilterMonitoring.client = {}
1112
ActivatedCarbonFilterMonitoring.server.attributes = ActivatedCarbonFilterMonitoringServerAttributes:set_parent_cluster(ActivatedCarbonFilterMonitoring)
13+
ActivatedCarbonFilterMonitoring.server.commands = ActivatedCarbonFilterMonitoringServerCommands:set_parent_cluster(ActivatedCarbonFilterMonitoring)
1214
ActivatedCarbonFilterMonitoring.types = ActivatedCarbonFilterMonitoringTypes
1315

1416
function ActivatedCarbonFilterMonitoring:get_attribute_by_id(attr_id)
@@ -52,6 +54,9 @@ ActivatedCarbonFilterMonitoring.attribute_direction_map = {
5254
["AttributeList"] = "server",
5355
}
5456

57+
ActivatedCarbonFilterMonitoring.command_direction_map = {
58+
["ResetCondition"] = "server",
59+
}
5560

5661
ActivatedCarbonFilterMonitoring.FeatureMap = ActivatedCarbonFilterMonitoring.types.Feature
5762

@@ -73,6 +78,24 @@ end
7378
ActivatedCarbonFilterMonitoring.attributes = {}
7479
setmetatable(ActivatedCarbonFilterMonitoring.attributes, attribute_helper_mt)
7580

81+
local command_helper_mt = {}
82+
command_helper_mt.__index = function(self, key)
83+
local direction = ActivatedCarbonFilterMonitoring.command_direction_map[key]
84+
if direction == nil then
85+
error(string.format("Referenced unknown command %s on cluster %s", key, ActivatedCarbonFilterMonitoring.NAME))
86+
end
87+
return ActivatedCarbonFilterMonitoring[direction].commands[key]
88+
end
89+
ActivatedCarbonFilterMonitoring.commands = {}
90+
setmetatable(ActivatedCarbonFilterMonitoring.commands, command_helper_mt)
91+
92+
local event_helper_mt = {}
93+
event_helper_mt.__index = function(self, key)
94+
return ActivatedCarbonFilterMonitoring.server.events[key]
95+
end
96+
ActivatedCarbonFilterMonitoring.events = {}
97+
setmetatable(ActivatedCarbonFilterMonitoring.events, event_helper_mt)
98+
7699
setmetatable(ActivatedCarbonFilterMonitoring, {__index = cluster_base})
77100

78101
return ActivatedCarbonFilterMonitoring

drivers/SmartThings/matter-thermostat/src/ActivatedCarbonFilterMonitoring/server/attributes/AttributeList.lua

-50
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,26 @@
1-
-- Copyright 2022 SmartThings
2-
--
3-
-- Licensed under the Apache License, Version 2.0 (the "License");
4-
-- you may not use this file except in compliance with the License.
5-
-- You may obtain a copy of the License at
6-
--
7-
-- http://www.apache.org/licenses/LICENSE-2.0
8-
--
9-
-- Unless required by applicable law or agreed to in writing, software
10-
-- distributed under the License is distributed on an "AS IS" BASIS,
11-
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
-- See the License for the specific language governing permissions and
13-
-- limitations under the License.
14-
15-
-- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator.
16-
171
local cluster_base = require "st.matter.cluster_base"
182
local data_types = require "st.matter.data_types"
193
local TLVParser = require "st.matter.TLV.TLVParser"
204

21-
--- @class st.matter.clusters.ActivatedCarbonFilterMonitoring.AttributeList
22-
--- @alias AttributeList
23-
---
24-
--- @field public ID number 0xFFFB the ID of this attribute
25-
--- @field public NAME string "AttributeList" the name of this attribute
26-
--- @field public data_type st.matter.data_types.Array the data type of this attribute
27-
285
local AttributeList = {
296
ID = 0xFFFB,
307
NAME = "AttributeList",
318
base_type = require "st.matter.data_types.Array",
329
element_type = require "st.matter.data_types.Uint32",
3310
}
3411

35-
--- Add additional functionality to the base type object
36-
---
37-
--- @param base_type_obj st.matter.data_types.Array the base data type object to add functionality to
3812
function AttributeList:augment_type(data_type_obj)
3913
for i, v in ipairs(data_type_obj.elements) do
4014
data_type_obj.elements[i] = data_types.validate_or_build_type(v, AttributeList.element_type)
4115
end
4216
end
4317

44-
--- Create a Array object of this attribute with any additional features provided for the attribute
45-
--- This is also usable with the AttributeList(...) syntax
46-
---
47-
--- @vararg vararg the values needed to construct a Array
48-
--- @return st.matter.data_types.Array
4918
function AttributeList:new_value(...)
5019
local o = self.base_type(table.unpack({...}))
5120

5221
return o
5322
end
5423

55-
--- Constructs an st.matter.interaction_model.InteractionRequest to read
56-
--- this attribute from a device
57-
--- @param device st.matter.Device
58-
--- @param endpoint_id number|nil
59-
--- @return st.matter.interaction_model.InteractionRequest containing an Interaction Request
6024
function AttributeList:read(device, endpoint_id)
6125
return cluster_base.read(
6226
device,
@@ -68,13 +32,6 @@ function AttributeList:read(device, endpoint_id)
6832
end
6933

7034

71-
--- Reporting policy: AttributeList => true => mandatory
72-
73-
--- Sets up a Subscribe Interaction
74-
---
75-
--- @param device any
76-
--- @param endpoint_id number|nil
77-
--- @return any
7835
function AttributeList:subscribe(device, endpoint_id)
7936
return cluster_base.subscribe(
8037
device,
@@ -90,13 +47,6 @@ function AttributeList:set_parent_cluster(cluster)
9047
return self
9148
end
9249

93-
--- Builds an AttributeList test attribute reponse for the driver integration testing framework
94-
---
95-
--- @param device st.matter.Device the device to build this message for
96-
--- @param endpoint_id number|nil
97-
--- @param value any
98-
--- @param status string Interaction status associated with the path
99-
--- @return st.matter.interaction_model.InteractionResponse of type REPORT_DATA
10050
function AttributeList:build_test_report_data(
10151
device,
10252
endpoint_id,

drivers/SmartThings/matter-thermostat/src/ActivatedCarbonFilterMonitoring/server/attributes/ChangeIndication.lua

-48
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,19 @@
1-
-- Copyright 2022 SmartThings
2-
--
3-
-- Licensed under the Apache License, Version 2.0 (the "License");
4-
-- you may not use this file except in compliance with the License.
5-
-- You may obtain a copy of the License at
6-
--
7-
-- http://www.apache.org/licenses/LICENSE-2.0
8-
--
9-
-- Unless required by applicable law or agreed to in writing, software
10-
-- distributed under the License is distributed on an "AS IS" BASIS,
11-
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
-- See the License for the specific language governing permissions and
13-
-- limitations under the License.
14-
15-
-- DO NOT EDIT: this code is automatically generated by ZCL Advanced Platform generator.
16-
171
local cluster_base = require "st.matter.cluster_base"
182
local data_types = require "st.matter.data_types"
193
local TLVParser = require "st.matter.TLV.TLVParser"
204

21-
--- @class st.matter.clusters.ActivatedCarbonFilterMonitoring.ChangeIndication
22-
--- @alias ChangeIndication
23-
---
24-
--- @field public ID number 0x0002 the ID of this attribute
25-
--- @field public NAME string "ChangeIndication" the name of this attribute
26-
--- @field public data_type ActivatedCarbonFilterMonitoring.types.ChangeIndicationEnum the data type of this attribute
27-
285
local ChangeIndication = {
296
ID = 0x0002,
307
NAME = "ChangeIndication",
318
base_type = require "ActivatedCarbonFilterMonitoring.types.ChangeIndicationEnum",
329
}
3310

34-
--- Create a ChangeIndicationEnum object of this attribute with any additional features provided for the attribute
35-
--- This is also usable with the ChangeIndication(...) syntax
36-
---
37-
--- @vararg vararg the values needed to construct a ChangeIndicationEnum
38-
--- @return ActivatedCarbonFilterMonitoring.types.ChangeIndicationEnum
3911
function ChangeIndication:new_value(...)
4012
local o = self.base_type(table.unpack({...}))
4113
self:augment_type(o)
4214
return o
4315
end
4416

45-
--- Constructs an st.matter.interaction_model.InteractionRequest to read
46-
--- this attribute from a device
47-
--- @param device st.matter.Device
48-
--- @param endpoint_id number|nil
49-
--- @return st.matter.interaction_model.InteractionRequest containing an Interaction Request
5017
function ChangeIndication:read(device, endpoint_id)
5118
return cluster_base.read(
5219
device,
@@ -57,14 +24,6 @@ function ChangeIndication:read(device, endpoint_id)
5724
)
5825
end
5926

60-
61-
--- Reporting policy: ChangeIndication => true => mandatory
62-
63-
--- Sets up a Subscribe Interaction
64-
---
65-
--- @param device any
66-
--- @param endpoint_id number|nil
67-
--- @return any
6827
function ChangeIndication:subscribe(device, endpoint_id)
6928
return cluster_base.subscribe(
7029
device,
@@ -80,13 +39,6 @@ function ChangeIndication:set_parent_cluster(cluster)
8039
return self
8140
end
8241

83-
--- Builds an ChangeIndication test attribute reponse for the driver integration testing framework
84-
---
85-
--- @param device st.matter.Device the device to build this message for
86-
--- @param endpoint_id number|nil
87-
--- @param value any
88-
--- @param status string Interaction status associated with the path
89-
--- @return st.matter.interaction_model.InteractionResponse of type REPORT_DATA
9042
function ChangeIndication:build_test_report_data(
9143
device,
9244
endpoint_id,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
local data_types = require "st.matter.data_types"
2+
local TLVParser = require "st.matter.TLV.TLVParser"
3+
4+
local ResetCondition = {}
5+
6+
ResetCondition.NAME = "ResetCondition"
7+
ResetCondition.ID = 0x0000
8+
ResetCondition.field_defs = {
9+
}
10+
11+
function ResetCondition:build_test_command_response(device, endpoint_id, status)
12+
return self._cluster:build_test_command_response(
13+
device,
14+
endpoint_id,
15+
self._cluster.ID,
16+
self.ID,
17+
nil, --tlv
18+
status
19+
)
20+
end
21+
22+
function ResetCondition:init(device, endpoint_id)
23+
local out = {}
24+
local args = {}
25+
if #args > #self.field_defs then
26+
error(self.NAME .. " received too many arguments")
27+
end
28+
for i,v in ipairs(self.field_defs) do
29+
if v.is_optional and args[i] == nil then
30+
out[v.name] = nil
31+
elseif v.is_nullable and args[i] == nil then
32+
out[v.name] = data_types.validate_or_build_type(args[i], data_types.Null, v.name)
33+
out[v.name].field_id = v.field_id
34+
elseif not v.is_optional and args[i] == nil then
35+
out[v.name] = data_types.validate_or_build_type(v.default, v.data_type, v.name)
36+
out[v.name].field_id = v.field_id
37+
else
38+
out[v.name] = data_types.validate_or_build_type(args[i], v.data_type, v.name)
39+
out[v.name].field_id = v.field_id
40+
end
41+
end
42+
setmetatable(out, {
43+
__index = ResetCondition,
44+
__tostring = ResetCondition.pretty_print
45+
})
46+
return self._cluster:build_cluster_command(
47+
device,
48+
out,
49+
endpoint_id,
50+
self._cluster.ID,
51+
self.ID
52+
)
53+
end
54+
55+
function ResetCondition:set_parent_cluster(cluster)
56+
self._cluster = cluster
57+
return self
58+
end
59+
60+
function ResetCondition:augment_type(base_type_obj)
61+
local elems = {}
62+
for _, v in ipairs(base_type_obj.elements) do
63+
for _, field_def in ipairs(self.field_defs) do
64+
if field_def.field_id == v.field_id and
65+
field_def.is_nullable and
66+
(v.value == nil and v.elements == nil) then
67+
elems[field_def.name] = data_types.validate_or_build_type(v, data_types.Null, field_def.field_name)
68+
elseif field_def.field_id == v.field_id and not
69+
(field_def.is_optional and v.value == nil) then
70+
elems[field_def.name] = data_types.validate_or_build_type(v, field_def.data_type, field_def.field_name)
71+
if field_def.element_type ~= nil then
72+
for i, e in ipairs(elems[field_def.name].elements) do
73+
elems[field_def.name].elements[i] = data_types.validate_or_build_type(e, field_def.element_type)
74+
end
75+
end
76+
end
77+
end
78+
end
79+
base_type_obj.elements = elems
80+
end
81+
82+
function ResetCondition:deserialize(tlv_buf)
83+
local data = TLVParser.decode_tlv(tlv_buf)
84+
self:augment_type(data)
85+
return data
86+
end
87+
88+
setmetatable(ResetCondition, {__call = ResetCondition.init})
89+
90+
return ResetCondition
91+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
local command_mt = {}
2+
command_mt.__command_cache = {}
3+
command_mt.__index = function(self, key)
4+
if command_mt.__command_cache[key] == nil then
5+
local req_loc = string.format("ActivatedCarbonFilterMonitoring.server.commands.%s", key)
6+
local raw_def = require(req_loc)
7+
local cluster = rawget(self, "_cluster")
8+
command_mt.__command_cache[key] = raw_def:set_parent_cluster(cluster)
9+
end
10+
return command_mt.__command_cache[key]
11+
end
12+
13+
local ActivatedCarbonFilterMonitoringServerCommands = {}
14+
15+
function ActivatedCarbonFilterMonitoringServerCommands:set_parent_cluster(cluster)
16+
self._cluster = cluster
17+
return self
18+
end
19+
20+
setmetatable(ActivatedCarbonFilterMonitoringServerCommands, command_mt)
21+
22+
return ActivatedCarbonFilterMonitoringServerCommands
23+

0 commit comments

Comments
 (0)