from custom_components.xiaomi_gateway3.core.devices import *
# from custom_components.xiaomi_gateway3.core.converters.devices import * 这行是旧版本代码,不要使用
DEVICES = [{
# pdid <厂商名称> <设备名称> <设备识别符>
20448: ["GranwinIoT", "Mesh Smart Triple Wall Switch", "giot.switch.v83ksm"],
"spec": [
# 开关设置
# 开关用BaseConv定义
# 实体名称 实体类型 设备信号(详情见下)
BaseConv("左键", "switch", mi="2.p.1"),
BaseConv("中键", "switch", mi="3.p.1"),
BaseConv("右键", "switch", mi="4.p.1"),
# 开关模式设置
# 模式默认是数字,需要匹配转换成文本显示,用MapConV定义
MapConv("左键开关模式", "select", mi="2.p.2", map={
0: "普通开关",
1: "无线开关",
2: "快速断通",
3: "点动开关",
4: "普通+无线"
}),
MapConv("中键开关模式", "select", mi="3.p.2", map={
0: "普通开关",
1: "无线开关",
2: "快速断通",
3: "点动开关",
4: "普通+无线"
}),
MapConv("右键开关模式", "select", mi="4.p.2", map={
0: "普通开关",
1: "无线开关",
2: "快速断通",
3: "点动开关",
4: "普通+无线"
}),
# 灯光设置
MapConv("普通开关模式灯光", "select", mi="16.p.1", map={
0: "跟随",
1: "相反",
2: "常灭",
3: "常亮"
}),
MapConv("非普通开关模式灯光", "select", mi="16.p.2", map={
0: "跟随",
1: "相反",
2: "常灭",
3: "常亮"
}),
BaseConv("背光开关", "switch", mi="22.p.1"),
# 无线信号设置
# 单键的无线开关如下设置
# BaseConv("action", "sensor"), # 必须要先定义这行,ha里才会出现Action实体来显示信号
# ConstConv("action", mi="12.e.1", value=BUTTON_SINGLE),
# ConstConv("action", mi="12.e.2", value=BUTTON_DOUBLE),
# ConstConv("action", mi="12.e.3", value=BUTTON_HOLD),
# 多键的无线开关如下设置
# BaseConv和ConstConv定义的名称需要对上;value值不可以随意更改,意思分别代表:单击、双击、长按
BaseConv("Left Botton Action", "sensor"), # 每个键单独设置一个sensor
ConstConv("Left Botton Action", mi="12.e.1", value=BUTTON_SINGLE),
ConstConv("Left Botton Action", mi="12.e.2", value=BUTTON_DOUBLE),
ConstConv("Left Botton Action", mi="12.e.3", value=BUTTON_HOLD),
BaseConv("Middle Botton Action", "sensor"), # 每个键单独设置一个sensor
ConstConv("Middle Botton Action", mi="13.e.1", value=BUTTON_SINGLE),
ConstConv("Middle Botton Action", mi="13.e.2", value=BUTTON_DOUBLE),
ConstConv("Middle Botton Action", mi="13.e.3", value=BUTTON_HOLD),
BaseConv("Right Botton Action", "sensor"), # 每个键单独设置一个sensor
ConstConv("Right Botton Action", mi="14.e.1", value=BUTTON_SINGLE),
ConstConv("Right Botton Action", mi="14.e.2", value=BUTTON_DOUBLE),
ConstConv("Right Botton Action", mi="14.e.3", value=BUTTON_HOLD),
],
}]+ DEVICES
最后贴上我自己的教程链接(Hassbian的排版也太复古了)