Added retrying mechanism

This commit is contained in:
Arne Blumentritt 2021-05-06 10:15:53 +02:00
parent 94b3cc143f
commit 7a0758f883
5 changed files with 27 additions and 13 deletions

View File

@ -121,10 +121,11 @@
## 0.7.3
* Fixed warnings since homebridge 1.3.0
## 1.0.0-beta.1
## 1.0.0-beta.4
* Added bin full sensor
* Added config-ui support for all options
* Added config parameter **prefix** to use robot name as prefix for service names
* Retrying mechanism if a robot is not available on homebridge launch
* 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
@ -136,4 +137,3 @@
## TODO until 1.0.0 release
* Room cleaning
* Spot size
* Retrying when no connection

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "homebridge-neato",
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,7 +1,7 @@
{
"name": "homebridge-neato",
"displayName": "Homebridge Neato",
"version": "1.0.0-beta.3",
"version": "1.0.0-beta.4",
"description": "A Neato vacuum robot plugin for homebridge.",
"license": "MIT",
"keywords": [

View File

@ -67,6 +67,8 @@ export class NeatoVacuumRobotAccessory
// Identify
this.accessory.on(PlatformAccessoryEvent.IDENTIFY, () => {
this.robot.findMe();
this.robot.getState((error, result) => {
this.log.info("[" + this.robot.name + "] Identified");
if (error)
@ -329,7 +331,7 @@ export class NeatoVacuumRobotAccessory
{
this.goToDockService.updateCharacteristic(this.platform.Characteristic.On, false);
}
}, 1000);
}, 10000);
try
{

View File

@ -36,10 +36,11 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
this.cachedRobotAccessories.push(accessory);
}
discoverRobots()
{
const client = new NeatoApi.Client();
this.log.debug("blub");
try
{
@ -47,9 +48,12 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
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.");
this.log.warn(error);
// TODO retry after x min
this.log.error("Cannot connect to neato server. No new robots will be found and existing robots will be unresponsive. Retrying in 5 minutes.");
this.log.error("Error: " + error);
setTimeout(() => {
this.discoverRobots();
}, 5 * 60 * 1000);
return;
}
@ -57,8 +61,12 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
client.getRobots((error, robots) => {
if (error)
{
this.log.error("Successful login but can't list your neato robots. Error: " + error);
// TODO retry after x min
this.log.error("Successful login but can't list the robots in your neato robots. Retrying in 5 minutes.");
this.log.error("Error: " + error);
setTimeout(() => {
this.discoverRobots();
}, 5 * 60 * 1000);
return;
}
@ -107,7 +115,11 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
robot.getState((error, state) => {
if (error)
{
this.log.error("[" + robot.name + "] Cannot connect to robot. Is the robot connected to the internet? Error: " + error + ". State: " + state);
this.log.error("[" + robot.name + "] Cannot connect to robot. Is the robot connected to the internet? Retrying in 5 minutes.");
this.log.error("Error: " + error);
setTimeout(() => {
this.discoverRobots();
}, 5 * 60 * 1000);
}
else
{