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
57 changes: 57 additions & 0 deletions drivers/SmartThings/matter-switch/profiles/mode-only.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: mode-only
components:
- id: main
capabilities:
- id: mode
version: 1
- id: refresh
version: 1
- id: firmwareUpdate
version: 1
categories:
- name: Thermostat
deviceConfig:
detailView:
- component: main
capability: mode
version: 1
patch:
- op: replace
path: /0/list/command/supportedValues
value: supportedArguments.value
- component: main
capability: refresh
version: 1
automation:
conditions:
- component: main
capability: mode
version: 1
patch:
- op: replace
path: /0/displayType
value: dynamicList
- op: add
path: /0/dynamicList
value:
value: mode.value
supportedValues:
value: supportedArguments.value
- op: remove
path: /0/list
actions:
- component: main
capability: mode
version: 1
patch:
- op: replace
path: /0/displayType
value: dynamicList
- op: add
path: /0/dynamicList
value:
value: mode.value
supportedValues:
value: supportedArguments.value
- op: remove
path: /0/list
68 changes: 68 additions & 0 deletions drivers/SmartThings/matter-switch/profiles/switch-binary-mode.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: switch-binary-mode
components:
- id: main
capabilities:
- id: switch
version: 1
- id: mode
version: 1
- id: firmwareUpdate
version: 1
- id: refresh
version: 1
categories:
- name: Switch
deviceConfig:
detailView:
- component: main
capability: switch
version: 1
- component: main
capability: mode
version: 1
patch:
- op: replace
path: /0/list/command/supportedValues
value: supportedArguments.value
- component: main
capability: refresh
version: 1
automation:
conditions:
- component: main
capability: switch
version: 1
- component: main
capability: mode
version: 1
patch:
- op: replace
path: /0/displayType
value: dynamicList
- op: add
path: /0/dynamicList
value:
value: mode.value
supportedValues:
value: supportedArguments.value
- op: remove
path: /0/list
actions:
- component: main
capability: switch
version: 1
- component: main
capability: mode
version: 1
patch:
- op: replace
path: /0/displayType
value: dynamicList
- op: add
path: /0/dynamicList
value:
value: mode.value
supportedValues:
value: supportedArguments.value
- op: remove
path: /0/list
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
-- Copyright © 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local cluster_base = require "st.matter.cluster_base"
local ModeSelectServerAttributes = require "embedded_clusters.ModeSelect.server.attributes"
local ModeSelectServerCommands = require "embedded_clusters.ModeSelect.server.commands"
local ModeSelectTypes = require "embedded_clusters.ModeSelect.types"

local ModeSelect = {}

ModeSelect.ID = 0x0050
ModeSelect.NAME = "ModeSelect"
ModeSelect.server = {}
ModeSelect.client = {}
ModeSelect.server.attributes = ModeSelectServerAttributes:set_parent_cluster(ModeSelect)
ModeSelect.server.commands = ModeSelectServerCommands:set_parent_cluster(ModeSelect)
ModeSelect.types = ModeSelectTypes

function ModeSelect:get_attribute_by_id(attr_id)
local attr_id_map = {
[0x0000] = "Description",
[0x0001] = "StandardNamespace",
[0x0002] = "SupportedModes",
[0x0003] = "CurrentMode",
[0x0004] = "StartUpMode",
[0x0005] = "OnMode",
[0xFFF9] = "AcceptedCommandList",
[0xFFFA] = "EventList",
[0xFFFB] = "AttributeList",
}
local attr_name = attr_id_map[attr_id]
if attr_name ~= nil then
return self.attributes[attr_name]
end
return nil
end

function ModeSelect:get_server_command_by_id(command_id)
local server_id_map = {
[0x0000] = "ChangeToMode",
}
if server_id_map[command_id] ~= nil then
return self.server.commands[server_id_map[command_id]]
end
return nil
end

ModeSelect.attribute_direction_map = {
["Description"] = "server",
["StandardNamespace"] = "server",
["SupportedModes"] = "server",
["CurrentMode"] = "server",
["StartUpMode"] = "server",
["OnMode"] = "server",
["AcceptedCommandList"] = "server",
["EventList"] = "server",
["AttributeList"] = "server",
}

ModeSelect.command_direction_map = {
["ChangeToMode"] = "server",
}

ModeSelect.FeatureMap = ModeSelect.types.Feature

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

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

setmetatable(ModeSelect, {__index = cluster_base})

return ModeSelect
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
-- Copyright © 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local cluster_base = require "st.matter.cluster_base"
local data_types = require "st.matter.data_types"
local TLVParser = require "st.matter.TLV.TLVParser"

local CurrentMode = {
ID = 0x0003,
NAME = "CurrentMode",
base_type = require "st.matter.data_types.Uint8",
}

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

return o
end

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

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

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

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

return data
end

setmetatable(CurrentMode, {__call = CurrentMode.new_value, __index = CurrentMode.base_type})
return CurrentMode
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
-- Copyright © 2025 SmartThings, Inc.
-- Licensed under the Apache License, Version 2.0

local cluster_base = require "st.matter.cluster_base"
local data_types = require "st.matter.data_types"
local TLVParser = require "st.matter.TLV.TLVParser"

local SupportedModes = {
ID = 0x0002,
NAME = "SupportedModes",
base_type = require "st.matter.data_types.Array",
element_type = require "embedded_clusters.ModeSelect.types.ModeOptionStruct",
}

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

function SupportedModes:new_value(...)
local o = self.base_type(table.unpack({...}))
self:augment_type(o)
return o
end

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

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

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

function SupportedModes:build_test_report_data(
device,
endpoint_id,
value,
status
)
local data = data_types.validate_or_build_type(value, self.base_type)
self:augment_type(data)
return cluster_base.build_test_report_data(
device,
endpoint_id,
self._cluster.ID,
self.ID,
data,
status
)
end

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

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