Skip to content

Instantly share code, notes, and snippets.

@danieledwardgeorgehitchcock
Last active November 2, 2022 14:14
Show Gist options
  • Save danieledwardgeorgehitchcock/744950f11aa50428396ec88301a62963 to your computer and use it in GitHub Desktop.
Save danieledwardgeorgehitchcock/744950f11aa50428396ec88301a62963 to your computer and use it in GitHub Desktop.
Zigbee2MQTT Install Code Extension
const constants = require('zigbee-herdsman/dist/adapter/z-stack/unpi/constants');
const {Buffer} = require('buffer');
console.log(Buffer);
const Subsystem = constants.Subsystem;
class MyExampleExtension {
constructor(zigbee, mqtt, state, publishEntityState, eventBus, settings, logger) {
this.zigbee = zigbee;
this.mqtt = mqtt;
this.state = state;
this.publishEntityState = publishEntityState;
this.eventBus = eventBus;
this.settings = settings;
this.logger = logger;
}
/**
* This method is called by the controller once Zigbee2MQTT has been started.
*/
async start() {
console.log('Adding install code!');
const payload = {
installCodeFormat: 1,
ieeeaddr: '0x000D6FFFFEC6A8A1',
installCode: Buffer.from([0x1C, 0x28, 0x17, 0x05, 0x1E, 0x36, 0x26, 0x13, 0x41, 0x1F, 0x7F, 0x67, 0x6A, 0xB2, 0xE4, 0x53, 0x13, 0x79]),
};
const k = await this.zigbee.herdsman.adapter.znp.request(Subsystem.APP_CNF, 'bdbAddInstallCode', payload);
console.log(k);
console.log('Added install code');
}
}
module.exports = MyExampleExtension;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment