固定标签 Cluster(Fixed Label)
Cluster ID: 0x0040 |
所在 Endpoint: Endpoint 0(Root)或各功能 Endpoint
Fixed Label 存储设备在出厂时写入的标签(键值对),用于描述设备的物理属性或预设分类。 这些标签是只读的 —— 用户和 App 都无法修改,只能读取。 标签内容由制造商在生产阶段确定,比如设备预设的房间、楼层、朝向等信息。
Fixed Label(0x0040)是只读的出厂标签,UserLabel(0x0041)是用户可写的自定义标签。
两者结构完全相同(都用 LabelStruct),区别只在于谁能改 ——
Fixed Label 由制造商在工厂写入后锁定,UserLabel 由用户随时修改。
App 通常会合并读取两者,出厂标签作为默认值,用户标签作为覆盖。
属性总览
Fixed Label 只有一个属性,非常简单。
| ID | 名称 | 类型 | 读写 | 说明 |
|---|---|---|---|---|
0x00 |
LabelList | list<LabelStruct> | 只读 | 出厂标签列表(键值对数组) |
LabelList(出厂标签列表)
一个 LabelStruct 数组,每个元素是一个键值对。列表可以为空(设备没有预设标签),
也可以包含多个条目。标签的键(Label)在同一个列表中不应重复。
这个属性是只读的,设备启动后内容固定不变。如果需要可写的标签,使用 UserLabel Cluster(0x0041)。
并非所有设备都有出厂标签。很多设备的 LabelList 返回空数组 [],
这是完全正常的。App 应当处理空列表的情况,不要假设一定有标签数据。
LabelStruct 结构体
LabelStruct 是 Fixed Label 和 UserLabel 共用的数据结构,定义了一个标签的键和值。
| 字段 | 类型 | 最大长度 | 说明 |
|---|---|---|---|
Label |
string | 16 字符 | 标签键,描述标签的含义(如 "room"、"floor") |
Value |
string | 16 字符 | 标签值,键对应的具体内容(如 "kitchen"、"2") |
常见的出厂标签示例
Matter 规范没有定义标签键的固定列表,上面只是常见用法。 制造商可以使用任意字符串作为键,只要不超过 16 个字符。 App 端不应硬编码对特定键的依赖,而应优雅地展示任何键值对。
命令(Commands)
Fixed Label Cluster 没有任何命令。这是一个纯数据 Cluster ——
只提供只读属性供 App 读取,不接受任何写入或操作指令。
如果需要修改标签,请使用 UserLabel Cluster(0x0041)。
示例数据
读取一个厨房传感器设备的 Fixed Label 属性:
{
// --- 属性 ---
"0x0": [ // LabelList — 出厂标签列表
{
"Label": "room", // 标签键:房间
"Value": "kitchen" // 标签值:厨房
},
{
"Label": "floor", // 标签键:楼层
"Value": "2" // 标签值:2 楼
},
{
"Label": "orientation", // 标签键:朝向
"Value": "N" // 标签值:北
}
]
}
应用场景
场景一:自动归类设备到房间
用户配网完成后,App 读取设备的出厂标签。如果标签中包含 room 键,
App 可以自动将设备归类到对应房间,省去用户手动选择的步骤。
// 场景:App 读取设备的出厂标签,自动归类到对应房间
{
"readRequests": [{
"attributePath": {
"endpointId": 0,
"clusterId": "0x0040",
"attributeId": "0x00" // LabelList
}
}]
}
// 返回结果
{
"attributeReports": [{
"attributeData": {
"dataVersion": 1,
"data": [
{ "Label": "room", "Value": "kitchen" },
{ "Label": "floor", "Value": "2" }
]
}
}]
}
配网完成后自动读取 Fixed Label,用已知的键(room、floor)做初始分组建议, 但始终让用户确认或修改。出厂标签只是参考,用户的实际安装位置可能不同。
场景二:多 Endpoint 设备区分子功能
一个双路开关有两个 Endpoint,每个 Endpoint 上的 Fixed Label 标注了物理位置(左/右)。 App 读取标签后可以直接在 UI 上标注「左开关」「右开关」,而不是显示无意义的 Endpoint 编号。
// 场景:多 Endpoint 设备,每个 Endpoint 有不同的出厂标签
// Endpoint 1 — 左侧开关
{
"readRequests": [{
"attributePath": {
"endpointId": 1,
"clusterId": "0x0040",
"attributeId": "0x00"
}
}]
}
// 返回: [{ "Label": "position", "Value": "left" }]
// Endpoint 2 — 右侧开关
{
"readRequests": [{
"attributePath": {
"endpointId": 2,
"clusterId": "0x0040",
"attributeId": "0x00"
}
}]
}
// 返回: [{ "Label": "position", "Value": "right" }]
对于多 Endpoint 设备,逐个读取每个 Endpoint 的 Fixed Label。
如果标签中有 position 键,用它来标注 UI 中的子设备名称,
给用户更直观的控制界面。