Skip to content
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
@@ -0,0 +1,16 @@
name: light-energy-powerConsumption
components:
- id: main
capabilities:
- id: switch
version: 1
- id: energyMeter
version: 1
- id: powerConsumptionReport
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
categories:
- name: Light
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: light-level-energy-powerConsumption
components:
- id: main
capabilities:
- id: switch
version: 1
- id: switchLevel
version: 1
config:
values:
- key: "level.value"
range: [1, 100]
- id: energyMeter
version: 1
- id: powerConsumptionReport
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
categories:
- name: Light
20 changes: 20 additions & 0 deletions drivers/SmartThings/matter-switch/profiles/light-level-power.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: light-level-power
components:
- id: main
capabilities:
- id: switch
version: 1
- id: switchLevel
version: 1
config:
values:
- key: "level.value"
range: [1, 100]
- id: powerMeter
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
categories:
- name: Light
14 changes: 14 additions & 0 deletions drivers/SmartThings/matter-switch/profiles/light-power.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: light-power
components:
- id: main
capabilities:
- id: switch
version: 1
- id: powerMeter
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
categories:
- name: Light
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
local cluster_base = require "st.matter.cluster_base"
local DescriptorServerAttributes = require "embedded_clusters.Descriptor.server.attributes"

local Descriptor = {}

Descriptor.ID = 0x001D
Descriptor.NAME = "Descriptor"
Descriptor.server = {}
Descriptor.client = {}
Descriptor.server.attributes = DescriptorServerAttributes:set_parent_cluster(Descriptor)

function Descriptor:get_attribute_by_id(attr_id)
local attr_id_map = {
[0x0003] = "PartsList",
}
local attr_name = attr_id_map[attr_id]
if attr_name ~= nil then
return self.attributes[attr_name]
end
return nil
end

function Descriptor:get_server_command_by_id(command_id)
local server_id_map = {
}
if server_id_map[command_id] ~= nil then
return self.server.commands[server_id_map[command_id]]
end
return nil
end

Descriptor.attribute_direction_map = {
["PartsList"] = "server",
}

local attribute_helper_mt = {}
attribute_helper_mt.__index = function(self, key)
local direction = Descriptor.attribute_direction_map[key]
if direction == nil then
error(string.format("Referenced unknown attribute %s on cluster %s", key, Descriptor.NAME))
end
return Descriptor[direction].attributes[key]
end
Descriptor.attributes = {}
setmetatable(Descriptor.attributes, attribute_helper_mt)

setmetatable(Descriptor, {__index = cluster_base})

return Descriptor

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
local cluster_base = require "st.matter.cluster_base"
local data_types = require "st.matter.data_types"
local TLVParser = require "st.matter.TLV.TLVParser"

local PartsList = {
ID = 0x0003,
NAME = "PartsList",
base_type = require "st.matter.data_types.Array",
element_type = require "st.matter.data_types.Uint16",
}

function PartsList: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, PartsList.element_type)
end
end

function PartsList:new_value(...)
local o = self.base_type(table.unpack({...}))

return o
end

function PartsList:read(device, endpoint_id)
return cluster_base.read(
device,
endpoint_id,
self._cluster.ID,
self.ID,
nil
)
end

function PartsList:subscribe(device, endpoint_id)
return cluster_base.subscribe(
device,
endpoint_id,
self._cluster.ID,
self.ID,
nil
)
end

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

function PartsList: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 PartsList:deserialize(tlv_buf)
local data = TLVParser.decode_tlv(tlv_buf)

return data
end

setmetatable(PartsList, {__call = PartsList.new_value, __index = PartsList.base_type})
return PartsList

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

local DescriptorServerAttributes = {}

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

setmetatable(DescriptorServerAttributes, attr_mt)

return DescriptorServerAttributes

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
local cluster_base = require "st.matter.cluster_base"
local PowerTopologyServerAttributes = require "embedded_clusters.PowerTopology.server.attributes"
local PowerTopologyTypes = require "embedded_clusters.PowerTopology.types"

local PowerTopology = {}

PowerTopology.ID = 0x009C
PowerTopology.NAME = "PowerTopology"
PowerTopology.server = {}
PowerTopology.client = {}
PowerTopology.server.attributes = PowerTopologyServerAttributes:set_parent_cluster(PowerTopology)
PowerTopology.types = PowerTopologyTypes

function PowerTopology:get_attribute_by_id(attr_id)
local attr_id_map = {
[0x0000] = "AvailableEndpoints",
}
local attr_name = attr_id_map[attr_id]
if attr_name ~= nil then
return self.attributes[attr_name]
end
return nil
end

PowerTopology.attribute_direction_map = {
["AvailableEndpoints"] = "server",
}

PowerTopology.FeatureMap = PowerTopology.types.Feature

function PowerTopology.are_features_supported(feature, feature_map)
if (PowerTopology.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 = PowerTopology.attribute_direction_map[key]
if direction == nil then
error(string.format("Referenced unknown attribute %s on cluster %s", key, PowerTopology.NAME))
end
return PowerTopology[direction].attributes[key]
end
PowerTopology.attributes = {}
setmetatable(PowerTopology.attributes, attribute_helper_mt)

setmetatable(PowerTopology, {__index = cluster_base})

return PowerTopology

Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
local cluster_base = require "st.matter.cluster_base"
local data_types = require "st.matter.data_types"
local TLVParser = require "st.matter.TLV.TLVParser"

local AvailableEndpoints = {
ID = 0x0000,
NAME = "AvailableEndpoints",
base_type = require "st.matter.data_types.Array",
element_type = require "st.matter.data_types.Uint16",
}

function AvailableEndpoints:new_value(...)
local o = self.base_type(table.unpack({...}))

return o
end

function AvailableEndpoints:read(device, endpoint_id)
return cluster_base.read(
device,
endpoint_id,
self._cluster.ID,
self.ID,
nil
)
end

function AvailableEndpoints:subscribe(device, endpoint_id)
return cluster_base.subscribe(
device,
endpoint_id,
self._cluster.ID,
self.ID,
nil
)
end

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

function AvailableEndpoints: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 AvailableEndpoints:deserialize(tlv_buf)
local data = TLVParser.decode_tlv(tlv_buf)

return data
end

setmetatable(AvailableEndpoints, {__call = AvailableEndpoints.new_value, __index = AvailableEndpoints.base_type})
return AvailableEndpoints

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
local attr_mt = {}
attr_mt.__index = function(self, key)
local req_loc = string.format("embedded_clusters.PowerTopology.server.attributes.%s", key)
local raw_def = require(req_loc)
local cluster = rawget(self, "_cluster")
raw_def:set_parent_cluster(cluster)
return raw_def
end

local PowerTopologyServerAttributes = {}

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

setmetatable(PowerTopologyServerAttributes, attr_mt)

return PowerTopologyServerAttributes

Loading
Loading