mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-02 10:01:37 +00:00
+9
-3
@@ -42,7 +42,7 @@ class Controller {
|
||||
if (error) {
|
||||
logger.error('Failed to start');
|
||||
} else {
|
||||
// Log zigbee clients on startup.
|
||||
// Log zigbee clients on startup and configure.
|
||||
const devices = this.zigbee.getAllClients();
|
||||
logger.info(`Currently ${devices.length} devices are joined:`);
|
||||
devices.forEach((device) => {
|
||||
@@ -145,8 +145,14 @@ class Controller {
|
||||
if (ieeeAddr && device.modelId && !this.configuredReport.includes(ieeeAddr)) {
|
||||
const mappedModel = zigbeeShepherdConverters.findByZigbeeModel(device.modelId);
|
||||
|
||||
if (mappedModel && mappedModel.report) {
|
||||
this.zigbee.configureReport(ieeeAddr, mappedModel.report);
|
||||
if (mappedModel && mappedModel.configure) {
|
||||
mappedModel.configure(ieeeAddr, this.zigbee.shepherd, this.zigbee.getCoordinator(), (ok, msg) => {
|
||||
if (ok) {
|
||||
logger.info(`Succesfully configured ${ieeeAddr}`);
|
||||
} else {
|
||||
logger.error(`Failed to configure ${ieeeAddr}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.configuredReport.push(ieeeAddr);
|
||||
|
||||
+5
-17
@@ -124,27 +124,15 @@ class Zigbee {
|
||||
}
|
||||
}
|
||||
|
||||
configureReport(ieeeAddr, reports) {
|
||||
reports.forEach((r) => {
|
||||
const device = this.shepherd.find(ieeeAddr, r.ep);
|
||||
if (device) {
|
||||
device.report(r.cid, r.attr, r.minInt, r.maxInt, r.repChange, (error) => {
|
||||
if (error) {
|
||||
logger.warn(`Failed to configure reporting for ${ieeeAddr} ${r.cid} ${r.attr}`);
|
||||
} else {
|
||||
logger.info(`Configured reporting for ${ieeeAddr} ${r.cid} ${r.attr}`);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
logger.warn(`Failed to configure reporting for ${ieeeAddr} ${r.cid} ${r.attr} (device not found)`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getDevice(deviceID) {
|
||||
return this.shepherd.list().find((d) => d.ieeeAddr === deviceID);
|
||||
}
|
||||
|
||||
getCoordinator() {
|
||||
const device = this.shepherd.list().find((d) => d.type === 'Coordinator');
|
||||
return this.shepherd.find(device.ieeeAddr, 1);
|
||||
}
|
||||
|
||||
publish(deviceID, cid, cmd, zclData, ep, callback) {
|
||||
const device = this._findDevice(deviceID, ep);
|
||||
if (!device) {
|
||||
|
||||
Generated
+3
-3
@@ -2810,9 +2810,9 @@
|
||||
}
|
||||
},
|
||||
"zigbee-shepherd-converters": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-1.0.0.tgz",
|
||||
"integrity": "sha512-+n2XO7l/4AEQbmHsipqY+Epu7B3UdneMxcYBN1lb5mzFtnIBUMBKr5ANw+HOEEBLFIXz82/6L5KU5RGorSZatg==",
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/zigbee-shepherd-converters/-/zigbee-shepherd-converters-1.0.1.tgz",
|
||||
"integrity": "sha512-o9z3xqThXSOddIHtInMnzj3lPiUh8259UVlHRFmUg4eKgSgRRip8LekI33t05fi+XysuBnd9LTEu1hBnnPjT9w==",
|
||||
"dependencies": {
|
||||
"acorn": {
|
||||
"version": "5.5.3",
|
||||
|
||||
Reference in New Issue
Block a user