Skip to content

Improve Matter Thermostat component to endpoint mapping #2099

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
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ components:
version: 1
- id: tvocHealthConcern
version: 1
- id: thermostatOperatingState
version: 1
config:
values:
- key: "thermostatOperatingState.value"
enabledValues:
- idle
- heating
- id: firmwareUpdate
version: 1
- id: refresh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local cluster_base = require "st.matter.cluster_base"
local ActivatedCarbonFilterMonitoringServerAttributes = require "ActivatedCarbonFilterMonitoring.server.attributes"
local ActivatedCarbonFilterMonitoringServerCommands = require "ActivatedCarbonFilterMonitoring.server.commands"
local ActivatedCarbonFilterMonitoringTypes = require "ActivatedCarbonFilterMonitoring.types"

local ActivatedCarbonFilterMonitoring = {}
Expand All @@ -9,6 +10,7 @@ ActivatedCarbonFilterMonitoring.NAME = "ActivatedCarbonFilterMonitoring"
ActivatedCarbonFilterMonitoring.server = {}
ActivatedCarbonFilterMonitoring.client = {}
ActivatedCarbonFilterMonitoring.server.attributes = ActivatedCarbonFilterMonitoringServerAttributes:set_parent_cluster(ActivatedCarbonFilterMonitoring)
ActivatedCarbonFilterMonitoring.server.commands = ActivatedCarbonFilterMonitoringServerCommands:set_parent_cluster(ActivatedCarbonFilterMonitoring)
ActivatedCarbonFilterMonitoring.types = ActivatedCarbonFilterMonitoringTypes

function ActivatedCarbonFilterMonitoring:get_attribute_by_id(attr_id)
Expand Down Expand Up @@ -52,6 +54,9 @@ ActivatedCarbonFilterMonitoring.attribute_direction_map = {
["AttributeList"] = "server",
}

ActivatedCarbonFilterMonitoring.command_direction_map = {
["ResetCondition"] = "server",
}

ActivatedCarbonFilterMonitoring.FeatureMap = ActivatedCarbonFilterMonitoring.types.Feature

Expand All @@ -73,6 +78,24 @@ end
ActivatedCarbonFilterMonitoring.attributes = {}
setmetatable(ActivatedCarbonFilterMonitoring.attributes, attribute_helper_mt)

local command_helper_mt = {}
command_helper_mt.__index = function(self, key)
local direction = ActivatedCarbonFilterMonitoring.command_direction_map[key]
if direction == nil then
error(string.format("Referenced unknown command %s on cluster %s", key, ActivatedCarbonFilterMonitoring.NAME))
end
return ActivatedCarbonFilterMonitoring[direction].commands[key]
end
ActivatedCarbonFilterMonitoring.commands = {}
setmetatable(ActivatedCarbonFilterMonitoring.commands, command_helper_mt)

local event_helper_mt = {}
event_helper_mt.__index = function(self, key)
return ActivatedCarbonFilterMonitoring.server.events[key]
end
ActivatedCarbonFilterMonitoring.events = {}
setmetatable(ActivatedCarbonFilterMonitoring.events, event_helper_mt)

setmetatable(ActivatedCarbonFilterMonitoring, {__index = cluster_base})

return ActivatedCarbonFilterMonitoring
Expand Down
Original file line number Diff line number Diff line change
@@ -1,62 +1,26 @@
-- 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.

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.ActivatedCarbonFilterMonitoring.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 = require "st.matter.data_types.Array",
element_type = require "st.matter.data_types.Uint32",
}

--- Add additional functionality to the base type object
---
--- @param base_type_obj st.matter.data_types.Array the base data type object to add functionality to
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

--- 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,
Expand All @@ -68,13 +32,6 @@ function AttributeList:read(device, endpoint_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,
Expand All @@ -90,13 +47,6 @@ function AttributeList:set_parent_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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,19 @@
-- 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.

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.ActivatedCarbonFilterMonitoring.ChangeIndication
--- @alias ChangeIndication
---
--- @field public ID number 0x0002 the ID of this attribute
--- @field public NAME string "ChangeIndication" the name of this attribute
--- @field public data_type ActivatedCarbonFilterMonitoring.types.ChangeIndicationEnum the data type of this attribute

local ChangeIndication = {
ID = 0x0002,
NAME = "ChangeIndication",
base_type = require "ActivatedCarbonFilterMonitoring.types.ChangeIndicationEnum",
}

--- Create a ChangeIndicationEnum object of this attribute with any additional features provided for the attribute
--- This is also usable with the ChangeIndication(...) syntax
---
--- @vararg vararg the values needed to construct a ChangeIndicationEnum
--- @return ActivatedCarbonFilterMonitoring.types.ChangeIndicationEnum
function ChangeIndication:new_value(...)
local o = self.base_type(table.unpack({...}))
self:augment_type(o)
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 ChangeIndication:read(device, endpoint_id)
return cluster_base.read(
device,
Expand All @@ -57,14 +24,6 @@ function ChangeIndication:read(device, endpoint_id)
)
end


--- Reporting policy: ChangeIndication => true => mandatory

--- Sets up a Subscribe Interaction
---
--- @param device any
--- @param endpoint_id number|nil
--- @return any
function ChangeIndication:subscribe(device, endpoint_id)
return cluster_base.subscribe(
device,
Expand All @@ -80,13 +39,6 @@ function ChangeIndication:set_parent_cluster(cluster)
return self
end

--- Builds an ChangeIndication 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 ChangeIndication:build_test_report_data(
device,
endpoint_id,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
local data_types = require "st.matter.data_types"
local TLVParser = require "st.matter.TLV.TLVParser"

local ResetCondition = {}

ResetCondition.NAME = "ResetCondition"
ResetCondition.ID = 0x0000
ResetCondition.field_defs = {
}

function ResetCondition:build_test_command_response(device, endpoint_id, status)
return self._cluster:build_test_command_response(
device,
endpoint_id,
self._cluster.ID,
self.ID,
nil,
status
)
end

function ResetCondition:init(device, endpoint_id)
local out = {}
local args = {}
if #args > #self.field_defs then
error(self.NAME .. " received too many arguments")
end
for i,v in ipairs(self.field_defs) do
if v.is_optional and args[i] == nil then
out[v.name] = nil
elseif v.is_nullable and args[i] == nil then
out[v.name] = data_types.validate_or_build_type(args[i], data_types.Null, v.name)
out[v.name].field_id = v.field_id
elseif not v.is_optional and args[i] == nil then
out[v.name] = data_types.validate_or_build_type(v.default, v.data_type, v.name)
out[v.name].field_id = v.field_id
else
out[v.name] = data_types.validate_or_build_type(args[i], v.data_type, v.name)
out[v.name].field_id = v.field_id
end
end
setmetatable(out, {
__index = ResetCondition,
__tostring = ResetCondition.pretty_print
})
return self._cluster:build_cluster_command(
device,
out,
endpoint_id,
self._cluster.ID,
self.ID
)
end

function ResetCondition:set_parent_cluster(cluster)
self._cluster = cluster
return self
end

function ResetCondition:augment_type(base_type_obj)
local elems = {}
for _, v in ipairs(base_type_obj.elements) do
for _, field_def in ipairs(self.field_defs) do
if field_def.field_id == v.field_id and
field_def.is_nullable and
(v.value == nil and v.elements == nil) then
elems[field_def.name] = data_types.validate_or_build_type(v, data_types.Null, field_def.field_name)
elseif field_def.field_id == v.field_id and not
(field_def.is_optional and v.value == nil) then
elems[field_def.name] = data_types.validate_or_build_type(v, field_def.data_type, field_def.field_name)
if field_def.element_type ~= nil then
for i, e in ipairs(elems[field_def.name].elements) do
elems[field_def.name].elements[i] = data_types.validate_or_build_type(e, field_def.element_type)
end
end
end
end
end
base_type_obj.elements = elems
end

function ResetCondition:deserialize(tlv_buf)
local data = TLVParser.decode_tlv(tlv_buf)
self:augment_type(data)
return data
end

setmetatable(ResetCondition, {__call = ResetCondition.init})

return ResetCondition

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
local command_mt = {}
command_mt.__command_cache = {}
command_mt.__index = function(self, key)
if command_mt.__command_cache[key] == nil then
local req_loc = string.format("ActivatedCarbonFilterMonitoring.server.commands.%s", key)
local raw_def = require(req_loc)
local cluster = rawget(self, "_cluster")
command_mt.__command_cache[key] = raw_def:set_parent_cluster(cluster)
end
return command_mt.__command_cache[key]
end

local ActivatedCarbonFilterMonitoringServerCommands = {}

function ActivatedCarbonFilterMonitoringServerCommands:set_parent_cluster(cluster)
self._cluster = cluster
return self
end

setmetatable(ActivatedCarbonFilterMonitoringServerCommands, command_mt)

return ActivatedCarbonFilterMonitoringServerCommands

Loading
Loading