index.js
//Handle device deletion, addition, status update
Handle device deletion, addition, status update
Handle device deletion addition status update
async onMQTTMessage(message){
    if(message.bizCode){
      if(message.bizCode == 'delete'){
        const uuid = this.api.hap.uuid.generate(message.devId);
        const homebridgeAccessory = this.accessories.get(uuid);
        this.removeAccessory(homebridgeAccessory)
      }else if(message.bizCode == 'bindUser'){
        let deviceInfo = await this.tuyaOpenApi.getDeviceInfo(message.bizData.devId)
        let functions = await this.tuyaOpenApi.getDeviceFunctions(message.bizData.devId)
        this.log('accessory  bindUser functions', functions);
        let device = Object.assign(deviceInfo, functions);
        this.addAccessory(device) 
        this.log('accessory getDeviceInfo', device);
      }
    }else{
      this.refreshDeviceStates(message)
    }
  }
async onMQTTMessage ( message ) { if ( message . bizCode ) { if ( message . bizCode == 'delete' ) { const uuid = this . api . hap . uuid . generate ( message . devId ) ; const homebridgeAccessory = this . accessories . get ( uuid ) ; this . removeAccessory ( homebridgeAccessory ) } else if ( message . bizCode == 'bindUser' ) { let deviceInfo = await this . tuyaOpenApi . getDeviceInfo ( message . bizData . devId ) let functions = await this . tuyaOpenApi . getDeviceFunctions ( message . bizData . devId ) this . log ( 'accessory  bindUser functions' , functions ) ; let device = Object . assign ( deviceInfo , functions ) ; this . addAccessory ( device ) this . log ( 'accessory getDeviceInfo' , device ) ; } } else { this . refreshDeviceStates ( message ) } }
Handle device deletion, addition, status update
Handle device deletion addition status update