Unable to initialise onNodeInit

Hi,

I can achieve logging of onIniti, but no log for onNodeInit. Looking for expert’s assistance in debugging my code, please.

Thanks.

'use strict';

const { Homey } = require('homey');
const { ZigBeeDevice } = require('homey-zigbeedriver');
const { CLUSTER } = require('zigbee-clusters');

// For debugging only
const { debug } = require('zigbee-clusters');
// Enable debug logging of all relevant Zigbee communication
debug(true);

class MyZigBeeDevice extends ZigBeeDevice {

  /**
   * onInit is called when the device is initialized.
   */
  async onInit() {
    this.log('MyDevice has been initialized');
}

// onNodeInit is called when the device is initialised.
  async onNodeInit({zclNode}) {
    this.log('Zigbee node has been initialised');

      // Check if the ZigBee node is available
    if (this.zclNode) {
      this.log('ZCL Node available:', this.zclNode);
      
      // Log the available endpoints and clusters
      Object.keys(this.zclNode.endpoints).forEach(endpoint => {
        this.log(`Endpoint ${endpoint}:`, this.zclNode.endpoints[endpoint].clusters);
      });

      await this.readOnOffAttribute();
    } else {
      this.error('ZCL Node is not available');
    }
}

I’ve tried to re-pair my device. Did not work

As developer you should know that “did not work” isn’t nearly enough information for others to be able to help you.

Hi,

I’m looking for assistance in my code and as I explained in the first paragraph, the logging under onInit was ok but no logging was seen under onNodeInit.

After searching online before posting, what I realised is onNodeInit did not intialize.

One of the solutions I found online was to repair my ZigBee device, which did not work. It is meant to say I’ve already tried this rectification method.

You’re still not being very clear. What do you mean by “repair”? Repairing, or completely deleting it and pairing it again?

And what “did not work”? The pairing process? The log in onNodeInit?

Since debugging is turned on, what do the debug logs say?

Hi,

I apologise for not being sufficiently clear.
By re-pair, i meant completing deleting the device then pairing it again.

What did not work was the log did not work for onNodeInit. With no log of ‘Zigbee node has been initialised’, I would assume onNodeInit did not work as well.

Log:
MyApp has been initialized.
MyDriver has been initialized.
MyDevice has been initialized.

Are you sure that your driver is being used for your device? It sounds like it’s not, which could explain why onNodeInit isn’t being called.