mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2024-11-16 10:28:33 -07:00
Support QBKG04LM. #4
This commit is contained in:
parent
0ee1d27099
commit
78b0e00d14
@ -157,6 +157,7 @@ class Controller {
|
||||
|
||||
handleMQTTMessageDevice(topic, message) {
|
||||
const friendlyName = topic.split('/')[1];
|
||||
const topicPostfix = '';
|
||||
|
||||
// Map friendlyName to deviceID.
|
||||
const deviceID = Object.keys(settings.get().devices).find((id) => settings.getDevice(id).friendly_name === friendlyName);
|
||||
@ -174,6 +175,10 @@ class Controller {
|
||||
json = {state: message.toString()};
|
||||
}
|
||||
|
||||
// Find ep for this device
|
||||
const mappedModel = deviceMapping[this.zigbee.getDevice(deviceID).modelId];
|
||||
const ep = mappedModel.ep && mappedModel.ep[topicPostfix] ? mappedModel.ep[topicPostfix] : null;
|
||||
|
||||
Object.keys(json).forEach((key) => {
|
||||
// Find converter for this key.
|
||||
const converter = mqtt2zigbee[key];
|
||||
@ -190,7 +195,7 @@ class Controller {
|
||||
}
|
||||
};
|
||||
|
||||
this.zigbee.publish(deviceID, message.cId, message.cmd, message.zclData, callback);
|
||||
this.zigbee.publish(deviceID, message.cId, message.cmd, message.zclData, ep, callback);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -218,10 +218,20 @@ const parsers = [
|
||||
type: 'attReport',
|
||||
convert: (msg) => {return {power: precisionRound(msg.data.data['presentValue'], 2)}}
|
||||
},
|
||||
{
|
||||
devices: ['QBKG04LM'],
|
||||
cid: 'genOnOff',
|
||||
type: 'attReport',
|
||||
convert: (msg) => {
|
||||
if (msg.data.data['61440']) {
|
||||
return {state: msg.data.data['onOff'] === 1 ? "ON" : "OFF"}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Ignore parsers (these message dont need parsing).
|
||||
{
|
||||
devices: ['WXKG11LM', 'MCCGQ11LM', 'MCCGQ01LM', 'WXKG01LM', 'LED1545G12', '7146060PH', 'LED1537R6', 'ZNCZ02LM', 'QBCZ11LM'],
|
||||
devices: ['WXKG11LM', 'MCCGQ11LM', 'MCCGQ01LM', 'WXKG01LM', 'LED1545G12', '7146060PH', 'LED1537R6', 'ZNCZ02LM', 'QBCZ11LM', 'QBKG04LM'],
|
||||
cid: 'genOnOff',
|
||||
type: 'devChange',
|
||||
convert: () => null
|
||||
|
@ -30,6 +30,14 @@ const devices = {
|
||||
supports: 'left, right and both click',
|
||||
homeassistant: [homeassistant.sensor_button]
|
||||
},
|
||||
'lumi.ctrl_neutral1': {
|
||||
model: 'QBKG04LM',
|
||||
vendor: 'Xiaomi',
|
||||
description: 'Aqara single key wired wall switch',
|
||||
supports: 'on/off',
|
||||
ep: {'': 2},
|
||||
homeassistant: [homeassistant.switch]
|
||||
},
|
||||
'lumi.sens': {
|
||||
model: 'WSDCGQ01LM',
|
||||
vendor: 'Xiaomi',
|
||||
|
@ -103,22 +103,27 @@ class Zigbee {
|
||||
return `${friendlyName} (${device.ieeeAddr}): ${friendlyDevice.model} - ${friendlyDevice.vendor} ${friendlyDevice.description}`;
|
||||
}
|
||||
|
||||
publish(deviceID, cId, cmd, zclData, callback) {
|
||||
getDevice(deviceID) {
|
||||
return this.shepherd.list().find((d) => d.ieeeAddr === deviceID);
|
||||
}
|
||||
|
||||
publish(deviceID, cId, cmd, zclData, ep, callback) {
|
||||
// Find device in zigbee-shepherd
|
||||
let device = this.shepherd.list().find((d) => d.ieeeAddr === deviceID);
|
||||
if (!device || !device.epList || !device.epList[0]) {
|
||||
let device = this.getDevice(deviceID);
|
||||
if (!device || !device.epList || !device.epList.length) {
|
||||
logger.error(`Zigbee cannot determine endpoint for '${deviceID}'`);
|
||||
return;
|
||||
}
|
||||
|
||||
device = this.shepherd.find(deviceID, device.epList[0]);
|
||||
ep = ep ? ep : device.epList[0];
|
||||
device = this.shepherd.find(deviceID, ep);
|
||||
|
||||
if (!device) {
|
||||
logger.error(`Zigbee cannot publish message to device because '${deviceID}' is not known by zigbee-shepherd`);
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info(`Zigbee publish to '${deviceID}', ${cId} - ${cmd} - ${JSON.stringify(zclData)}`);
|
||||
logger.info(`Zigbee publish to '${deviceID}', ${cId} - ${cmd} - ${JSON.stringify(zclData)} - ${ep}`);
|
||||
device.functional(cId, cmd, zclData, callback);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user