diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b26d6a..6da6f0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,8 @@ ## 0.3.0 -* Added periodic refresh of robot state +* Added periodic refresh of robot state while cleaning +* Added optional periodic refresh of robot state while not cleaning * Improved go to dock switch to be enabled as soon as possible without manual refresh -* Improved switches to indicate the time an action lasts -* Improved eco mode to not be overwritten by robot state \ No newline at end of file +* Improved switches to indicate the time an action needs to complete +* Improved eco mode to not be overwritten by robot state update \ No newline at end of file diff --git a/README.md b/README.md index 04e4125..ee79d65 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Feel free to leave any feedback [here](https://github.com/naofireblade/homebridg - Enable and disable eco mode - Get battery info - Get dock info +- Periodic refresh of robot state \* The robot needs to clean for some seconds before he knows where his dock is. After this time the switch to send him home will be automatically available. @@ -28,7 +29,7 @@ Feel free to leave any feedback [here](https://github.com/naofireblade/homebridg Add the following information to your config file. Change the values for name, email and password. -The parameter **refresh** is optional (default 120 seconds) and adjusts in what interval changes in the robot state will be pushed to homekit (e.g. when starting the robot with the neato app). The minimum is 60 seconds. You can disable this by entering 0. +The parameter **refresh** is optional (default off) and adjusts in what interval changes in the robot state will be pushed to homekit (e.g. when starting the robot with the neato app). The minimum refresh time is 60 seconds. ```json "accessories": [ diff --git a/index.js b/index.js index 3cded9c..409a9e9 100644 --- a/index.js +++ b/index.js @@ -26,13 +26,13 @@ function NeatoVacuumRobot(log, config) { this.serial = "1-3-3-7"; this.email = config['email']; this.password = config['password']; - - // default 120s - this.refresh = ('refresh' in config ? parseInt(config['refresh']) : 120); + + // default off + this.refresh = ('refresh' in config ? parseInt(config['refresh']) : 0); // must be integer and positive this.refresh = (typeof this.refresh !=='number' || (this.refresh%1)!==0 || this.refresh < 0) ? 0 : this.refresh; // minimum 60s - this.refresh = (this.refresh != 0 && this.refresh < 60) ? 60 : this.refresh; + this.refresh = (0 < this.refresh < 60) ? 60 : this.refresh; this.vacuumRobotCleanService = new Service.Switch(this.name + " Clean", "clean"); this.vacuumRobotGoToDockService = new Service.Switch(this.name + " Go to Dock", "goToDock"); @@ -141,11 +141,7 @@ NeatoVacuumRobot.prototype = { callback(); } } else { - // dont allow manual setting the switch to off - setTimeout(function() { - that.vacuumRobotGoToDockService.setCharacteristic(Characteristic.On, true); - callback(); - },1000); + callback(); } }); }, @@ -279,8 +275,8 @@ NeatoVacuumRobot.prototype = { // dont update eco, because we cant write that value onto the robot and dont want it to be overwritten in our plugin if (that.robot.canPause) { - debug("Short timer set: 10s"); - that.timer = setTimeout(that.getStateTimer.bind(that), 10 * 1000); + debug("Short timer set: 30s"); + that.timer = setTimeout(that.getStateTimer.bind(that), 30 * 1000); } else if (that.refresh != 0) { debug("Long timer set: " + that.refresh + "s");