From e53bb3d77767834580ad312b4c880520a6a663d2 Mon Sep 17 00:00:00 2001 From: Arne Blumentritt Date: Tue, 4 May 2021 14:29:36 +0200 Subject: [PATCH] Fixed issue with non smart robots --- .eslintrc | 1 - CHANGELOG.md | 19 ++++++++- package.json | 2 +- src/homebridgeNeatoPlatform.ts | 77 ++++++++++++++++------------------ 4 files changed, 56 insertions(+), 43 deletions(-) diff --git a/.eslintrc b/.eslintrc index 4ef49bb..edd1da8 100644 --- a/.eslintrc +++ b/.eslintrc @@ -20,7 +20,6 @@ "dot-notation": "off", "eqeqeq": "warn", "curly": ["warn", "all"], - "brace-style": ["warn", "allman"], "prefer-arrow-callback": ["warn"], "max-len": ["warn", 200], "no-console": ["warn"], // use the provided Homebridge log method instead diff --git a/CHANGELOG.md b/CHANGELOG.md index d5d35f7..35c8745 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -119,4 +119,21 @@ * Fixed homebridge crash with multiple robots per account ## 0.7.3 -* Fixed warnings since homebridge 1.3.0 \ No newline at end of file +* Fixed warnings since homebridge 1.3.0 + +## 1.0.0-beta.1 +* Added bin full sensor +* Added config-ui support for all options +* Added config parameter **prefix** to use robot name as prefix for service names +* Changed service names to not include robot name as prefix by default +* Changed background update to use better default intervals (1 minute while cleaning, 30 minutes while idle) +* Changed config parameter **refresh**. Renamed to **backgroundUpdate**, unit changed to minute and will only be used during idle +* Changed config parameter **hidden**. Renamed to **services**, now takes list of services that should be _visible_. Default are all available services. +* Fixed robots no longer disappear or change the room after connection issues with the Neato API +* Fixed plugin no longer crashes if non smart robot is assigned in neato account +* Fixed options for eco, nogo lines, extra care are now saved in homebridge and will no longer be overridden by Neato API + +## TODO until 1.0.0 release +* Room cleaning +* Spot size +* Retrying when no connection \ No newline at end of file diff --git a/package.json b/package.json index c1b0f62..d94278d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "homebridge-neato", "displayName": "Homebridge Neato", - "version": "1.0.0-beta.1", + "version": "1.0.0-beta.2", "description": "A Neato vacuum robot plugin for homebridge.", "license": "MIT", "keywords": [ diff --git a/src/homebridgeNeatoPlatform.ts b/src/homebridgeNeatoPlatform.ts index 370e4f7..b6d52ee 100644 --- a/src/homebridgeNeatoPlatform.ts +++ b/src/homebridgeNeatoPlatform.ts @@ -21,8 +21,7 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin public readonly config: PlatformConfig, public readonly api: API) { - this.api.on("didFinishLaunching", () => - { + this.api.on("didFinishLaunching", () => { this.discoverRobots(); }); } @@ -44,8 +43,7 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin try { // Login - client.authorize((this.config)["email"], (this.config)["password"], false, (error) => - { + client.authorize((this.config)["email"], (this.config)["password"], false, (error) => { if (error) { this.log.warn("Cannot connect to neato server. No new robots will be found and existing robots will be unresponsive."); @@ -55,8 +53,7 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin } // Get all robots from account - client.getRobots((error, robots) => - { + client.getRobots((error, robots) => { if (error) { this.log.error("Successful login but can't connect to your neato robot: " + error); @@ -75,52 +72,52 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin for (const robot of robots) { // Get additional information for the robot - robot.getState((error, state) => - { + robot.getState((error, state) => { if (error) { this.log.error("Error getting robot meta information: " + error + ": " + state); - return; } - - try + else { - robot.meta = state.meta; - - const uuid = this.api.hap.uuid.generate(robot._serial); - const existingAccessory = this.robotAccessories.find(accessory => accessory.UUID === uuid); - - // the accessory already exists - if (existingAccessory) + try { - this.log.info("[" + robot.name + "] Robot loaded from cache"); - // TODO update maps + robot.meta = state.meta; - existingAccessory.context.robot = robot; - this.api.updatePlatformAccessories([existingAccessory]); + const uuid = this.api.hap.uuid.generate(robot._serial); + const existingAccessory = this.robotAccessories.find(accessory => accessory.UUID === uuid); - new NeatoVacuumRobotAccessory(this, existingAccessory, this.config); + // the accessory already exists + if (existingAccessory) + { + this.log.info("[" + robot.name + "] Robot loaded from cache"); + // TODO update maps + + existingAccessory.context.robot = robot; + this.api.updatePlatformAccessories([existingAccessory]); + + new NeatoVacuumRobotAccessory(this, existingAccessory, this.config); + } + else + { + this.log.info("[" + robot.name + "] Robot created"); + const accessory = new this.api.platformAccessory(robot.name, uuid); + + accessory.context.robot = robot; + new NeatoVacuumRobotAccessory(this, accessory, this.config); + + // link the accessory to your platform + this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]); + // TODO get maps + } } - else + catch (error) { - this.log.info("[" + robot.name + "] Robot created"); - const accessory = new this.api.platformAccessory(robot.name, uuid); - - accessory.context.robot = robot; - new NeatoVacuumRobotAccessory(this, accessory, this.config); - - // link the accessory to your platform - this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]); - // TODO get maps + this.log.error("Error creating robot accessory: " + robot.name); + this.log.error(error); + throw new this.api.hap.HapStatusError(this.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE); } - } - catch (error) - { - this.log.error("Error creating robot accessory: " + robot.name); - this.log.error(error); - throw new this.api.hap.HapStatusError(this.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE); - } + } // // Get all maps for each robot // robot.getPersistentMaps((error, maps) => {