|
楼主 |
发表于 2020-4-5 09:41:31
|
显示全部楼层
今天才有空,直播增加9楼这个SOS按键.(其实上星期看了一个github上面的代码,已经有人更新支持了,估计这一堆设备都支持了,不过为了以后碰到不支持设备,需要手动添加,还是假装不知道,自己手动增加一次,熟悉一下流程)
How to support new devices:
https://www.zigbee2mqtt.io/how_tos/how_to_support_new_devices.html
其实也就2步.
第1步: 在 node_modules/zigbee-herdsman-converters/devices.js 这个文件里添加新设备,大概格式是这样(根据实际设备更改)
{
zigbeeModel: ['lumi.sens'], // The model ID from: Device with modelID 'lumi.sens' is not supported.
model: 'WSDCGQ01LM', // Vendor model number, look on the device for a model number
vendor: 'Xiaomi', // Vendor of the device (only used for documentation and startup logging)
description: 'MiJia temperature & humidity sensor ', // Description of the device, copy from vendor site. (only used for documentation and startup logging)
supports: 'temperature and humidity', // Actions this device supports (only used for documentation)
fromZigbee: [], // We will add this later
toZigbee: [], // Should be empty, unless device can be controlled (e.g. lights, switches).
},
第2步:在node_modules/zigbee-herdsman-converters/converters/fromZigbee.js 这里面增加从zigbee设备接收数据的解析,如果需要下发数据到zigbee设备的,还要多加一步,在tozigbee.js里面增加往设备发数据的内容.
这也是一个fromZigbee的例子.
xiaomi_temperature: {
cluster: 'msTemperatureMeasurement',
type: 'attributeReport',
convert: (model, msg, publish, options) => {
const temperature = parseFloat(msg.data['measuredValue']) / 100.0;
return {temperature: temperature};
},
},
|
|