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", "dot-notation": "off",
"eqeqeq": "warn", "eqeqeq": "warn",
"curly": ["warn", "all"], "curly": ["warn", "all"],
"brace-style": ["warn", "allman"],
"prefer-arrow-callback": ["warn"], "prefer-arrow-callback": ["warn"],
"max-len": ["warn", 200], "max-len": ["warn", 200],
"no-console": ["warn"], // use the provided Homebridge log method instead "no-console": ["warn"], // use the provided Homebridge log method instead

View File

@ -120,3 +120,20 @@
## 0.7.3 ## 0.7.3
* Fixed warnings since homebridge 1.3.0 * 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", "name": "homebridge-neato",
"displayName": "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.", "description": "A Neato vacuum robot plugin for homebridge.",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [

View File

@ -21,8 +21,7 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
public readonly config: PlatformConfig, public readonly config: PlatformConfig,
public readonly api: API) public readonly api: API)
{ {
this.api.on("didFinishLaunching", () => this.api.on("didFinishLaunching", () => {
{
this.discoverRobots(); this.discoverRobots();
}); });
} }
@ -44,8 +43,7 @@ export class HomebridgeNeatoPlatform implements DynamicPlatformPlugin
try try
{ {
// Login // Login
client.authorize((this.config)["email"], (this.config)["password"], false, (error) => client.authorize((this.config)["email"], (this.config)["password"], false, (error) => {
{
if (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("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 // Get all robots from account
client.getRobots((error, robots) => client.getRobots((error, robots) => {
{
if (error) if (error)
{ {
this.log.error("Successful login but can't connect to your neato robot: " + 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) for (const robot of robots)
{ {
// Get additional information for the robot // Get additional information for the robot
robot.getState((error, state) => robot.getState((error, state) => {
{
if (error) if (error)
{ {
this.log.error("Error getting robot meta information: " + error + ": " + state); this.log.error("Error getting robot meta information: " + error + ": " + state);
return;
} }
else
try
{ {
robot.meta = state.meta; try
const uuid = this.api.hap.uuid.generate(robot._serial);
const existingAccessory = this.robotAccessories.find(accessory => accessory.UUID === uuid);
// the accessory already exists
if (existingAccessory)
{ {
this.log.info("[" + robot.name + "] Robot loaded from cache"); robot.meta = state.meta;
// TODO update maps
existingAccessory.context.robot = robot; const uuid = this.api.hap.uuid.generate(robot._serial);
this.api.updatePlatformAccessories([existingAccessory]); 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"); this.log.error("Error creating robot accessory: " + robot.name);
const accessory = new this.api.platformAccessory(robot.name, uuid); this.log.error(error);
throw new this.api.hap.HapStatusError(this.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE);
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
} }
}
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 // // Get all maps for each robot
// robot.getPersistentMaps((error, maps) => { // robot.getPersistentMaps((error, maps) => {