Fixed issue with non smart robots

This commit is contained in:
Arne Blumentritt 2021-05-04 14:29:36 +02:00
parent 552e360f6f
commit e53bb3d777
4 changed files with 56 additions and 43 deletions

View File

@ -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

View File

@ -120,3 +120,20 @@
## 0.7.3
* 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

View File

@ -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": [

View File

@ -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) => {