Skip to content

Commit

Permalink
Fix too many call causing disconnecting loop
Browse files Browse the repository at this point in the history
  • Loading branch information
moifort committed Jan 17, 2025
1 parent dc72fdc commit f3dfffb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"private": false,
"displayName": "Hombridge Create Ceiling Fan",
"name": "homebridge-create-ceiling-fan",
"version": "0.0.93",
"version": "0.0.94",
"description": "Free the full potential of your ceiling fan with Homebridge",
"license": "Apache-2.0",
"repository": {
Expand Down
4 changes: 4 additions & 0 deletions src/indext.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
process.env.DEBUG = '*';

describe('Ceiling Fan Accessory', () => {
// const device = new TuyAPI({
// id: accessory.context.device.id,
// key: accessory.context.device.key,
// });
jest.setTimeout(30000);
});
23 changes: 9 additions & 14 deletions src/platformAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import TuyaDevice, {DPSObject} from 'tuyapi';
export class CeilingFanAccessory {
private fanService!: Service;
private lightService!: Service;
private lightToggleService!: Service;
private fanToggleService!: Service;
private isConnecting = false;

private state = {
Expand All @@ -27,11 +25,8 @@ export class CeilingFanAccessory {
const device = new TuyAPI({
id: accessory.context.device.id,
key: accessory.context.device.key,
ip: accessory.context.device.ip,
version: accessory.context.device.version,
nullPayloadOnJSONError: true,
issueRefreshOnConnect: true,
issueRefreshOnPing: true,
// ip: accessory.context.device.ip,
// version: accessory.context.device.version,
});


Expand All @@ -42,8 +37,8 @@ export class CeilingFanAccessory {

device.on('error', error => {
this.platform.log.info('Error :', error);
this.platform.log.info('Try to connect');
this.connect(device);
// this.platform.log.info('Try to connect');
// this.connect(device);
});


Expand Down Expand Up @@ -74,7 +69,7 @@ export class CeilingFanAccessory {
this.fanService.updateCharacteristic(this.platform.Characteristic.On, this.state.fanOn);
}
};
device.on('dp-refresh', stateHook);
// device.on('dp-refresh', stateHook);
device.on('data', stateHook);

// Fan rotation
Expand All @@ -94,7 +89,7 @@ export class CeilingFanAccessory {
this.fanService.updateCharacteristic(this.platform.Characteristic.RotationDirection, this.state.fanRotation);
}
};
device.on('dp-refresh', rotationHook);
// device.on('dp-refresh', rotationHook);
device.on('data', rotationHook);

// Fan speed
Expand All @@ -117,7 +112,7 @@ export class CeilingFanAccessory {
this.fanService.updateCharacteristic(this.platform.Characteristic.RotationSpeed, this.state.fanSpeed);
}
};
device.on('dp-refresh', speedHook);
// device.on('dp-refresh', speedHook);
device.on('data', speedHook);

if (accessory.context.device.hasLight) {
Expand All @@ -141,7 +136,7 @@ export class CeilingFanAccessory {
this.lightService.updateCharacteristic(this.platform.Characteristic.On, this.state.lightOn);
}
};
device.on('dp-refresh', lightStateHook);
// device.on('dp-refresh', lightStateHook);
device.on('data', lightStateHook);

// Fan Light Brightness
Expand All @@ -164,7 +159,7 @@ export class CeilingFanAccessory {
this.lightService.updateCharacteristic(this.platform.Characteristic.Brightness, this.state.lightBrightness);
}
};
device.on('dp-refresh', lightBrightnessHook);
// device.on('dp-refresh', lightBrightnessHook);
device.on('data', lightBrightnessHook);


Expand Down

0 comments on commit f3dfffb

Please sign in to comment.