diff --git a/README.md b/README.md index 6aeeef6..367cb44 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ To configure manually, add to the `accessories` section of homebridge's `config. "deviceId": "", "localKey": "", "hideFindButton": "", + "useSwitchService": "", "debugLog": "" } ``` diff --git a/config.schema.json b/config.schema.json index 5cfcbae..b46c583 100644 --- a/config.schema.json +++ b/config.schema.json @@ -28,6 +28,12 @@ "required": false, "default": false }, + "useSwitchService": { + "title": "Use Switch for Vacuum (Default is Fan)", + "type": "boolean", + "required": false, + "default": false + }, "debugLog": { "title": "Enable Debug Log", "type": "boolean", diff --git a/src/index.ts b/src/index.ts index 16d2d52..df5290e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,7 +27,7 @@ class EufyRoboVacAccessory { services: any[]; name: string; - fanService: any; + vacuumService: any; batteryService: any; serviceInfo: any; findRobot: any; @@ -57,14 +57,14 @@ class EufyRoboVacAccessory { this.services.push(this.serviceInfo); - this.fanService = new Service.Fan(this.name); + this.vacuumService = config.useSwitchService ? new Service.Switch(this.name) : new Service.Fan(this.name); - this.fanService + this.vacuumService .getCharacteristic(Characteristic.On) .on('get', this.getCleanState.bind(this)) .on('set', this.setCleanState.bind(this)); - this.services.push(this.fanService); + this.services.push(this.vacuumService); this.batteryService = new Service.BatteryService(this.name + ' Battery'); this.batteryService @@ -126,7 +126,7 @@ class EufyRoboVacAccessory { updateCleaningState(state: boolean) { this.log.debug('Cleaning State -> %s', state); - this.fanService.getCharacteristic(Characteristic.On).updateValue(state) + this.vacuumService.getCharacteristic(Characteristic.On).updateValue(state) } async getCleanState(callback: Function) {