How to use the zigbee-herdsman.Controller function in zigbee-herdsman

To help you get started, we’ve selected a few zigbee-herdsman examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Koenkk / zigbee2mqtt / lib / zigbee.js View on Github external
async start() {
        logger.info(`Starting zigbee-herdsman...`);
        const herdsmanSettingsLog = objectAssignDeep.noMutate(herdsmanSettings);
        herdsmanSettingsLog.network.networkKey = 'HIDDEN';
        logger.debug(`Using zigbee-herdsman with settings: '${JSON.stringify(herdsmanSettingsLog)}'`);

        try {
            herdsmanSettings.acceptJoiningDeviceHandler = this.acceptJoiningDeviceHandler;
            this.herdsman = new ZigbeeHerdsman.Controller(herdsmanSettings);
            await this.herdsman.start();
        } catch (error) {
            logger.error(`Error while starting zigbee-herdsman`);
            throw error;
        }

        this.herdsman.on('adapterDisconnected', () => this.emit('adapterDisconnected'));
        this.herdsman.on('deviceAnnounce', (data) => this.emit('event', 'deviceAnnounce', data));
        this.herdsman.on('deviceInterview', (data) => this.emit('event', 'deviceInterview', data));
        this.herdsman.on('deviceJoined', (data) => this.emit('event', 'deviceJoined', data));
        this.herdsman.on('deviceLeave', (data) => this.emit('event', 'deviceLeave', data));
        this.herdsman.on('message', (data) => this.emit('event', 'message', data));

        logger.info('zigbee-herdsman started');
        logger.info(`Coordinator firmware version: '${JSON.stringify(await this.getCoordinatorVersion())}'`);
        logger.debug(`Zigbee network parameters: ${JSON.stringify(await this.herdsman.getNetworkParameters())}`);
github hobbyquaker / node-red-contrib-zigbee / nodes / shepherd.js View on Github external
this.proxy.emit('devices');
                        setTimeout(() => {
                            this.configure(data.device);
                        }, 5000);
                    } else {
                        this.log(`deviceInterview ${data.status} ${data.device.ieeeAddr}`);
                    }
                },
                message: message => {
                    this.messageHandler(message);
                }
            };

            if (!herdsmanInstances[this.id]) {
                this.debug('creating new herdsman instance');
                herdsmanInstances[this.id] = new ZigbeeHerdsman.Controller(this.herdsmanOptions);
            }

            this.herdsman = herdsmanInstances[this.id];
            this.proxy = new HerdsmanProxy(this);

            this.connect();

            this.on('close', done => {
                this.debug('stopping');
                clearInterval(this.checkOverdueInterval);
                clearInterval(this.pingInterval);
                this.status = 'closing';
                this.proxy.emit('nodeStatus', {fill: 'yellow', shape: 'ring', text: 'closing'});

                this.removeListeners();
                this.herdsman.stop().then(() => {

zigbee-herdsman

An open source ZigBee gateway solution with node.js.

MIT
Latest version published 3 days ago

Package Health Score

81 / 100
Full package analysis