-
Notifications
You must be signed in to change notification settings - Fork 485
Matter Thermostat: Fix issues found during testing #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
Merged
nickolas-deboom
merged 2 commits into
main
from
fix/matter-thermostat-component-to-endpoint-mapping-improvement
May 12, 2025
Merged
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
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
91 changes: 91 additions & 0 deletions
91
.../matter-thermostat/src/ActivatedCarbonFilterMonitoring/server/commands/ResetCondition.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,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 | ||
|
23 changes: 23 additions & 0 deletions
23
...martThings/matter-thermostat/src/ActivatedCarbonFilterMonitoring/server/commands/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,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 | ||
|
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.
Is this meant to be included in this PR?
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.
we could pull it into a separate one, but yes, this is also part of the improvements found by testing the same device