mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-08-27 21:20:03 +00:00
Refactor multiple foundation.
This commit is contained in:
+1
-1
@@ -541,7 +541,7 @@ class Controller {
|
||||
}
|
||||
};
|
||||
|
||||
this.zigbee.publish(deviceID, message.cid, message.cmd, message.zclData, ep, callback);
|
||||
this.zigbee.publish(deviceID, message.cid, message.cmd, message.zclData, ep, message.type, callback);
|
||||
|
||||
published.push({message: message, converter: converter});
|
||||
});
|
||||
|
||||
+10
-21
@@ -183,7 +183,7 @@ class Zigbee {
|
||||
return this.shepherd.find(device.ieeeAddr, 1);
|
||||
}
|
||||
|
||||
publish(deviceID, cid, cmd, zclData, ep, callback) {
|
||||
publish(deviceID, cid, cmd, zclData, ep, type, callback) {
|
||||
const device = this._findDevice(deviceID, ep);
|
||||
if (!device) {
|
||||
logger.error(`Zigbee cannot publish message to device because '${deviceID}' not known by zigbee-shepherd`);
|
||||
@@ -191,27 +191,16 @@ class Zigbee {
|
||||
}
|
||||
|
||||
logger.info(`Zigbee publish to '${deviceID}', ${cid} - ${cmd} - ${JSON.stringify(zclData)} - ${ep}`);
|
||||
if (zclData['foudation']!==true) {
|
||||
device.functional(cid, cmd, zclData, (error) => {
|
||||
if (error) {
|
||||
logger.error(
|
||||
`Zigbee publish to '${deviceID}', ${cid} - ${cmd} - ${JSON.stringify(zclData)} - ${ep} ` +
|
||||
`failed with error ${error}`);
|
||||
}
|
||||
|
||||
callback(error);
|
||||
});
|
||||
} else { // use foundation command
|
||||
device.foundation(cid, cmd, [{attrId: zclData['attrId'], dataType: zclData['dataType'],
|
||||
attrData: zclData['attrData']}], function(error, rsp) {
|
||||
if (error) {
|
||||
logger.error(
|
||||
`Zigbee publish to '${deviceID}', ${cid} - ${cmd} - ${JSON.stringify(zclData)} - ${ep} ` +
|
||||
`failed with error ${error}, respond ${rsp}`);
|
||||
}
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
device[type](cid, cmd, zclData, (error) => {
|
||||
if (error) {
|
||||
logger.error(
|
||||
`Zigbee publish to '${deviceID}', ${cid} - ${cmd} - ${JSON.stringify(zclData)} - ${ep} ` +
|
||||
`failed with error ${error}`);
|
||||
}
|
||||
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
|
||||
read(deviceID, cid, attr, ep, callback) {
|
||||
|
||||
Reference in New Issue
Block a user