Compare commits
16 Commits
v0.7.0
...
feature-la
Author | SHA1 | Date | |
---|---|---|---|
|
0767779172 | ||
|
bdb5807aeb | ||
|
010e177306 | ||
|
3af668399b | ||
|
877c3d7d26 | ||
|
77945f8420 | ||
|
5ff3951668 | ||
|
b83d30cfad | ||
|
b53ef4ff2f | ||
|
d8ca308338 | ||
|
75180b27cb | ||
|
b8971b64a9 | ||
|
32e47d0a8f | ||
|
f0dd89353e | ||
|
d809be5b03 | ||
|
6e5b0d522c |
11
CHANGELOG.md
11
CHANGELOG.md
@@ -110,4 +110,13 @@
|
||||
* Added logic to be able to change the currently cleaned room
|
||||
* Improved number of requests when having multiple rooms
|
||||
* Fixed room switches not taking eco and extraCare mode into account
|
||||
* Fixed room switches to support pause/resume
|
||||
* Fixed room switches not supporting pause/resume
|
||||
|
||||
## 0.7.1
|
||||
* Fixed robot not shown before setting up a floor plan
|
||||
|
||||
## 0.7.2
|
||||
* Fixed homebridge crash with multiple robots per account
|
||||
|
||||
## 0.7.3
|
||||
* Fixed warnings since homebridge 1.3.0
|
34
README.md
34
README.md
@@ -7,7 +7,7 @@ This is a plugin for [homebridge](https://github.com/nfarina/homebridge) to cont
|
||||
|
||||
If you like this plugin and find it useful, I would be forever grateful for your support:
|
||||
|
||||
<a href="https://www.buymeacoffee.com/2D1nUuK36" target="_blank"><img width="140" src="https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png" alt="Buy Me A Coffee"></a>
|
||||
<a href="https://www.buymeacoffee.com/naofireblade" target="_blank"><img width="140" src="https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/orange_img.png" alt="Buy Me A Coffee"></a>
|
||||
|
||||
Feel free to leave any feedback [here](https://github.com/naofireblade/homebridge-neato/issues).
|
||||
|
||||
@@ -17,10 +17,10 @@ Feel free to leave any feedback [here](https://github.com/naofireblade/homebridg
|
||||
- Eco mode
|
||||
- Extra care navigation
|
||||
- Nogo lines
|
||||
- Zone cleaning* (only D7)
|
||||
- Zone cleaning <sup>[1](#d7)</sup><sup>, </sup><sup>[2](#change-room)</sup>
|
||||
- Spot cleaning
|
||||
- Individual spot size (only D7)
|
||||
- Clean twice
|
||||
- Individual spot size <sup>[1](#d7)</sup><sup>, </sup><sup>[3](#eve)</sup>
|
||||
- Clean twice <sup>[3](#eve)</sup>
|
||||
- Return to dock
|
||||
- Find the robot
|
||||
- Schedule (de)activation
|
||||
@@ -31,8 +31,15 @@ Feel free to leave any feedback [here](https://github.com/naofireblade/homebridg
|
||||
- Model and firmware version
|
||||
- Automatic or periodic refresh of robot state
|
||||
- Multiple robots
|
||||
- Multiple language support (en, de, fr)
|
||||
|
||||
> <b name="d7">1</b> Only available on the Neato D7.
|
||||
|
||||
> <b name="change-room">2</b> You can send the robot from one room to another as well. He will return to the base, wait there some seconds and then starts cleaning the next room.
|
||||
|
||||
> <b name="eve">3</b> You need a third party app like eve to access these features.
|
||||
|
||||
|
||||
>*You can also send the robot from one room to another. He will return to the base, wait there some seconds and then starts cleaning the other room.
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -52,18 +59,24 @@ Add the following information to your config file. Change the values for email a
|
||||
{
|
||||
"platform": "NeatoVacuumRobot",
|
||||
"email": "YourEmail",
|
||||
"password": "YourPassword"
|
||||
"password": "YourPassword",
|
||||
"language": "de"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Advanced
|
||||
|
||||
The following config contains advanced optional settings.
|
||||
Below are explanations for advanced parameters to adjust the plugin to your needs. All parameters are *optional*.
|
||||
|
||||
The parameter **refresh** is default set to `auto` and updates the robot state when a cleaning was started via homekit so that you can activate automations based on a successful cleaning. If you want to get robot state updates after starting the cleaning from outside of homekit as well (neato app or schedule), you have to set refresh to a static value in seconds e.g. `120`. You can disable background updates completely by setting this to `0`.
|
||||
**refresh**
|
||||
Timer for periodic refresh of robot state. The default is `auto`. The options are:
|
||||
`auto` Updates the robot state when a cleaning was started via homekit so that you can activate automations based on a successful cleaning.
|
||||
`120` Or any other time in seconds (minimum `60`) is required if you want to receive robot state updates after starting the cleaning from outside of homekit (e.g. neato app or schedule).
|
||||
`0` Disables background updates completely.
|
||||
|
||||
The parameter **hidden** accepts a list of switches/sensors that can be hidden from homekit (e.g. `dock`, `dockstate`, `eco`, `nogolines`, `extracare`, `schedule`, `find`, `spot`).
|
||||
**hidden**
|
||||
List of plugin features that you don't want to use in homekit (e.g. `dock`, `dockstate`, `eco`, `nogolines`, `extracare`, `schedule`, `find`, `spot`).
|
||||
|
||||
```json
|
||||
"platforms": [
|
||||
@@ -71,6 +84,7 @@ The parameter **hidden** accepts a list of switches/sensors that can be hidden f
|
||||
"platform": "NeatoVacuumRobot",
|
||||
"email": "YourEmail",
|
||||
"password": "YourPassword",
|
||||
"language": "de",
|
||||
"refresh": "120",
|
||||
"hidden": ["dock", "dockstate", "eco", "nogolines", "extracare", "schedule", "find", "spot"]
|
||||
}
|
||||
@@ -86,4 +100,4 @@ Many thanks go to
|
||||
- [ghulands](https://github.com/ghulands) for finding and fixing a bug when no robot is associated with the neato account
|
||||
- [Berkay](https://github.com/btutal) for adding the schema file to use the plugin with homebridge-config-ui-x
|
||||
- [Antoine de Maleprade](https://github.com/az0uz) for adding the zone cleaning feature
|
||||
- [DJay](https://github.com/DJay-X) for testing out tons of new beta versions
|
||||
- [DJay](https://github.com/DJay-X) for testing out tons of new beta versions
|
||||
|
@@ -17,6 +17,9 @@ module.exports = function (_Service, _Characteristic)
|
||||
{
|
||||
Service = _Service;
|
||||
Characteristic = _Characteristic;
|
||||
SpotWidthCharacteristic = require('../characteristics/spotWidth')(Characteristic, CustomUUID);
|
||||
SpotHeightCharacteristic = require('../characteristics/spotHeight')(Characteristic, CustomUUID);
|
||||
SpotRepeatCharacteristic = require('../characteristics/spotRepeat')(Characteristic, CustomUUID);
|
||||
|
||||
return NeatoVacuumRobotAccessory;
|
||||
};
|
||||
@@ -32,9 +35,51 @@ function NeatoVacuumRobotAccessory(platform, robotObject)
|
||||
this.robotObject = robotObject;
|
||||
this.robot = robotObject.device;
|
||||
this.meta = robotObject.meta;
|
||||
this.availableServices = robotObject.availableServices;
|
||||
this.spotPlusFeatures = ((typeof robotObject.availableServices.spotCleaning !== 'undefined') && robotObject.availableServices.spotCleaning.includes("basic"));
|
||||
this.boundary = (typeof robotObject.boundary === 'undefined') ? null : robotObject.boundary;
|
||||
|
||||
this.dict = {
|
||||
'en': {
|
||||
"clean": "Clean",
|
||||
"clean the": "Clean the",
|
||||
"goToDock": "Go to Dock",
|
||||
"dockState": "Dock",
|
||||
"eco": "Eco Mode",
|
||||
"noGoLines": "NoGo Lines",
|
||||
"extraCare": "Extra Care",
|
||||
"schedule": "Schedule",
|
||||
"findMe": "Find me",
|
||||
"cleanSpot": "Clean Spot",
|
||||
"battery": "Battery"
|
||||
},
|
||||
'de': {
|
||||
"clean": "Sauge",
|
||||
"clean the": "Sauge",
|
||||
"goToDock": "Zur Basis",
|
||||
"dockState": "In der Basis",
|
||||
"eco": "Eco Modus",
|
||||
"noGoLines": "NoGo Linien",
|
||||
"extraCare": "Extra Care",
|
||||
"schedule": "Zeitplan",
|
||||
"findMe": "Finde mich",
|
||||
"cleanSpot": "Spot Reinigung",
|
||||
"battery": "Batterie"
|
||||
},
|
||||
'fr': {
|
||||
"clean": "Aspirer",
|
||||
"clean the": "Aspirer",
|
||||
"goToDock": "Retour à la base",
|
||||
"dockState": "Sur la base",
|
||||
"eco": "Eco mode",
|
||||
"noGoLines": "Lignes NoGo",
|
||||
"extraCare": "Extra Care",
|
||||
"schedule": "Planifier",
|
||||
"findMe": "Me retrouver",
|
||||
"cleanSpot": "Nettoyage local",
|
||||
"battery": "Batterie"
|
||||
}
|
||||
}[this.platform.language]
|
||||
|
||||
if (this.boundary == null)
|
||||
{
|
||||
this.name = this.robot.name;
|
||||
@@ -61,45 +106,34 @@ function NeatoVacuumRobotAccessory(platform, robotObject)
|
||||
this.name = this.robot.name + ' - ' + this.boundary.name;
|
||||
}
|
||||
|
||||
this.batteryService = new Service.BatteryService("Battery", "battery");
|
||||
this.batteryService = new Service.BatteryService(this.name + " " + this.dict["battery"], "battery");
|
||||
|
||||
if (this.boundary == null)
|
||||
{
|
||||
this.cleanService = new Service.Switch(this.name + " Clean", "clean");
|
||||
this.goToDockService = new Service.Switch(this.name + " Go to Dock", "goToDock");
|
||||
this.dockStateService = new Service.OccupancySensor(this.name + " Dock", "dockState");
|
||||
this.ecoService = new Service.Switch(this.name + " Eco Mode", "eco");
|
||||
this.noGoLinesService = new Service.Switch(this.name + " NoGo Lines", "noGoLines");
|
||||
this.extraCareService = new Service.Switch(this.name + " Extra Care", "extraCare");
|
||||
this.scheduleService = new Service.Switch(this.name + " Schedule", "schedule");
|
||||
this.findMeService = new Service.Switch(this.name + " Find Me", "findMe");
|
||||
this.cleanService = new Service.Switch(this.name + " " + this.dict["clean"], "clean");
|
||||
this.goToDockService = new Service.Switch(this.name + " " + this.dict["goToDock"], "goToDock");
|
||||
this.dockStateService = new Service.OccupancySensor(this.name + " " + this.dict["dockState"], "dockState");
|
||||
this.ecoService = new Service.Switch(this.name + " " + this.dict["eco"], "eco");
|
||||
this.noGoLinesService = new Service.Switch(this.name + " " + this.dict["noGoLines"], "noGoLines");
|
||||
this.extraCareService = new Service.Switch(this.name + " " + this.dict["extraCare"], "extraCare");
|
||||
this.scheduleService = new Service.Switch(this.name + " " + this.dict["schedule"], "schedule");
|
||||
this.findMeService = new Service.Switch(this.name + " " + this.dict["findMe"], "findMe");
|
||||
|
||||
SpotWidthCharacteristic = require('../characteristics/spotWidth')(Characteristic, CustomUUID);
|
||||
SpotHeightCharacteristic = require('../characteristics/spotHeight')(Characteristic, CustomUUID);
|
||||
SpotRepeatCharacteristic = require('../characteristics/spotRepeat')(Characteristic, CustomUUID);
|
||||
|
||||
// Spot cleaning with advanced options
|
||||
if ((typeof this.availableServices.spotCleaning !== 'undefined') && this.availableServices.spotCleaning.includes("basic"))
|
||||
this.spotCleanService = new Service.Switch(this.name + " " + this.dict["cleanSpot"], "cleanSpot");
|
||||
this.spotCleanService.addCharacteristic(SpotRepeatCharacteristic);
|
||||
if (this.spotPlusFeatures)
|
||||
{
|
||||
this.spotCleanAdvancedService = new Service.Switch(this.name + " Clean Spot", "cleanSpot");
|
||||
this.spotCleanAdvancedService.addCharacteristic(SpotRepeatCharacteristic);
|
||||
this.spotCleanAdvancedService.addCharacteristic(SpotWidthCharacteristic);
|
||||
this.spotCleanAdvancedService.addCharacteristic(SpotHeightCharacteristic);
|
||||
}
|
||||
// Spot cleaning without advanced options
|
||||
else
|
||||
{
|
||||
this.spotCleanSimpleService = new Service.Switch(this.name + " Clean Spot", "cleanSpot");
|
||||
this.spotCleanSimpleService.addCharacteristic(SpotRepeatCharacteristic);
|
||||
this.spotCleanService.addCharacteristic(SpotWidthCharacteristic);
|
||||
this.spotCleanService.addCharacteristic(SpotHeightCharacteristic);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const splitName = this.boundary.name.split(' ');
|
||||
let serviceName = "Clean the " + this.boundary.name;
|
||||
let serviceName = this.dict["clean the"] + " " + this.boundary.name;
|
||||
if (splitName.length >= 2 && splitName[splitName.length - 2].match(/[']s$/g))
|
||||
{
|
||||
serviceName = "Clean " + this.boundary.name;
|
||||
serviceName = this.dict["clean"] + " " + this.boundary.name;
|
||||
}
|
||||
this.cleanService = new Service.Switch(serviceName, "cleanBoundary:" + this.boundary.id);
|
||||
}
|
||||
@@ -166,29 +200,22 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
this.findMeService.getCharacteristic(Characteristic.On).on('set', this.setFindMe.bind(this));
|
||||
this.findMeService.getCharacteristic(Characteristic.On).on('get', this.getFindMe.bind(this));
|
||||
|
||||
if (typeof this.spotCleanAdvancedService !== 'undefined')
|
||||
{
|
||||
this.spotCleanAdvancedService.getCharacteristic(Characteristic.On).on('set', this.setSpotClean.bind(this));
|
||||
this.spotCleanAdvancedService.getCharacteristic(Characteristic.On).on('get', this.getSpotClean.bind(this));
|
||||
this.spotCleanAdvancedService.getCharacteristic(SpotRepeatCharacteristic).on('set', this.setSpotRepeat.bind(this));
|
||||
this.spotCleanAdvancedService.getCharacteristic(SpotRepeatCharacteristic).on('get', this.getSpotRepeat.bind(this));
|
||||
this.spotCleanAdvancedService.getCharacteristic(SpotWidthCharacteristic).on('set', this.setSpotWidth.bind(this));
|
||||
this.spotCleanAdvancedService.getCharacteristic(SpotWidthCharacteristic).on('get', this.getSpotWidth.bind(this));
|
||||
this.spotCleanAdvancedService.getCharacteristic(SpotHeightCharacteristic).on('set', this.setSpotHeight.bind(this));
|
||||
this.spotCleanAdvancedService.getCharacteristic(SpotHeightCharacteristic).on('get', this.getSpotHeight.bind(this));
|
||||
this.spotCleanService.getCharacteristic(Characteristic.On).on('set', this.setSpotClean.bind(this));
|
||||
this.spotCleanService.getCharacteristic(Characteristic.On).on('get', this.getSpotClean.bind(this));
|
||||
this.spotCleanService.getCharacteristic(SpotRepeatCharacteristic).on('set', this.setSpotRepeat.bind(this));
|
||||
this.spotCleanService.getCharacteristic(SpotRepeatCharacteristic).on('get', this.getSpotRepeat.bind(this));
|
||||
|
||||
if (this.hiddenServices.indexOf('spot') === -1)
|
||||
this.services.push(this.spotCleanAdvancedService);
|
||||
if (this.spotPlusFeatures)
|
||||
{
|
||||
this.spotCleanService.getCharacteristic(SpotWidthCharacteristic).on('set', this.setSpotWidth.bind(this));
|
||||
this.spotCleanService.getCharacteristic(SpotWidthCharacteristic).on('get', this.getSpotWidth.bind(this));
|
||||
this.spotCleanService.getCharacteristic(SpotHeightCharacteristic).on('set', this.setSpotHeight.bind(this));
|
||||
this.spotCleanService.getCharacteristic(SpotHeightCharacteristic).on('get', this.getSpotHeight.bind(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.spotCleanSimpleService.getCharacteristic(Characteristic.On).on('set', this.setSpotClean.bind(this));
|
||||
this.spotCleanSimpleService.getCharacteristic(Characteristic.On).on('get', this.getSpotClean.bind(this));
|
||||
this.spotCleanSimpleService.getCharacteristic(SpotRepeatCharacteristic).on('set', this.setSpotRepeat.bind(this));
|
||||
this.spotCleanSimpleService.getCharacteristic(SpotRepeatCharacteristic).on('get', this.getSpotRepeat.bind(this));
|
||||
|
||||
if (this.hiddenServices.indexOf('spot') === -1)
|
||||
this.services.push(this.spotCleanSimpleService);
|
||||
if (this.hiddenServices.indexOf('spot') === -1)
|
||||
{
|
||||
this.services.push(this.spotCleanService);
|
||||
}
|
||||
|
||||
// Add optional services
|
||||
@@ -246,13 +273,15 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
if (this.robot.canResume)
|
||||
{
|
||||
debug(this.name + ": ## Resume cleaning");
|
||||
this.robot.resumeCleaning(callback);
|
||||
this.robot.resumeCleaning((error) =>
|
||||
{
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
// Start cleaning
|
||||
else if (this.robot.canStart)
|
||||
{
|
||||
debug(this.name + ": ## Start cleaning");
|
||||
this.clean(callback, this.boundary);
|
||||
this.clean(callback);
|
||||
}
|
||||
// Cannot start
|
||||
else
|
||||
@@ -278,7 +307,7 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
else
|
||||
{
|
||||
debug(this.name + ": ## Start cleaning of new room");
|
||||
this.clean(callback, this.boundary);
|
||||
this.clean(callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,7 +317,10 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
if (this.robot.canPause)
|
||||
{
|
||||
debug(this.name + ": ## Pause cleaning");
|
||||
this.robot.pauseCleaning(callback);
|
||||
this.robot.pauseCleaning((error) =>
|
||||
{
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -324,12 +356,8 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
if (error)
|
||||
{
|
||||
this.log.error("Cannot start cleaning. " + error + ": " + JSON.stringify(result));
|
||||
callback(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback();
|
||||
}
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
// Room cleaning
|
||||
@@ -340,12 +368,8 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
if (error)
|
||||
{
|
||||
this.log.error("Cannot start room cleaning. " + error + ": " + JSON.stringify(result));
|
||||
callback(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback();
|
||||
}
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
// Spot cleaning
|
||||
@@ -356,12 +380,8 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
if (error)
|
||||
{
|
||||
this.log.error("Cannot start spot cleaning. " + error + ": " + JSON.stringify(result));
|
||||
callback(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback();
|
||||
}
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
},
|
||||
@@ -385,14 +405,20 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
setTimeout(() =>
|
||||
{
|
||||
debug(this.name + ": ## Go to dock");
|
||||
this.robot.sendToBase(callback);
|
||||
this.robot.sendToBase(() =>
|
||||
{
|
||||
callback();
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
else if (this.robot.canGoToBase)
|
||||
{
|
||||
debug(this.name + ": ## Go to dock");
|
||||
this.robot.sendToBase(callback);
|
||||
this.robot.sendToBase(() =>
|
||||
{
|
||||
callback();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -471,12 +497,18 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
if (on)
|
||||
{
|
||||
debug(this.name + ": " + "Enabled".brightGreen + " Schedule");
|
||||
this.robot.enableSchedule(callback);
|
||||
this.robot.enableSchedule((error) =>
|
||||
{
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
debug(this.name + ": " + "Disabled".red + " Schedule");
|
||||
this.robot.disableSchedule(callback);
|
||||
this.robot.disableSchedule((error) =>
|
||||
{
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -496,23 +528,24 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
this.findMeService.setCharacteristic(Characteristic.On, false);
|
||||
}, 1000);
|
||||
|
||||
this.robot.findMe(callback);
|
||||
this.robot.findMe((error) =>
|
||||
{
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
getSpotClean: function (callback)
|
||||
{
|
||||
callback();
|
||||
callback(false, this.spotCleanService.getCharacteristic(Characteristic.On).value);
|
||||
},
|
||||
|
||||
setSpotClean: function (on, callback)
|
||||
{
|
||||
let spotCleanService = (typeof this.spotCleanAdvancedService !== 'undefined') ? this.spotCleanAdvancedService : this.spotCleanSimpleService;
|
||||
|
||||
let spot = {
|
||||
width: spotCleanService.getCharacteristic(SpotWidthCharacteristic).value,
|
||||
height: spotCleanService.getCharacteristic(SpotHeightCharacteristic).value,
|
||||
repeat: spotCleanService.getCharacteristic(SpotRepeatCharacteristic).value
|
||||
width: this.spotPlusFeatures ? this.spotCleanService.getCharacteristic(SpotWidthCharacteristic).value : null,
|
||||
height: this.spotPlusFeatures ? this.spotCleanService.getCharacteristic(SpotHeightCharacteristic).value : null,
|
||||
repeat: this.spotCleanService.getCharacteristic(SpotRepeatCharacteristic).value
|
||||
};
|
||||
|
||||
this.platform.updateRobot(this.robot._serial, (error, result) =>
|
||||
@@ -544,7 +577,10 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
if (this.robot.canPause)
|
||||
{
|
||||
debug(this.name + ": ## Pause cleaning");
|
||||
this.robot.pauseCleaning(callback);
|
||||
this.robot.pauseCleaning((error) =>
|
||||
{
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -658,15 +694,17 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
this.noGoLinesService.setCharacteristic(Characteristic.On, this.robot.noGoLines);
|
||||
this.extraCareService.setCharacteristic(Characteristic.On, this.robot.navigationMode == 2 ? true : false);
|
||||
|
||||
if (typeof this.spotCleanAdvancedService !== 'undefined')
|
||||
this.spotCleanService.setCharacteristic(SpotRepeatCharacteristic, this.robot.spotRepeat);
|
||||
|
||||
if (this.spotPlusFeatures)
|
||||
{
|
||||
this.spotCleanAdvancedService.setCharacteristic(SpotWidthCharacteristic, this.robot.spotWidth);
|
||||
this.spotCleanAdvancedService.setCharacteristic(SpotHeightCharacteristic, this.robot.spotHeight);
|
||||
this.spotCleanAdvancedService.setCharacteristic(SpotRepeatCharacteristic, this.robot.spotRepeat);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.spotCleanSimpleService.setCharacteristic(SpotRepeatCharacteristic, this.robot.spotRepeat);
|
||||
let widthProps = this.spotCleanService.getCharacteristic(SpotWidthCharacteristic).props;
|
||||
let heightProps = this.spotCleanService.getCharacteristic(SpotHeightCharacteristic).props;
|
||||
|
||||
this.spotCleanService.setCharacteristic(SpotWidthCharacteristic,
|
||||
this.robot.spotWidth >= widthProps.minValue && this.robot.spotWidth <= widthProps.maxValue ? this.robot.spotWidth : widthProps.minValue);
|
||||
this.spotCleanService.setCharacteristic(SpotHeightCharacteristic,
|
||||
this.robot.spotHeight >= heightProps.minValue && this.robot.spotHeight <= heightProps.maxValue ? this.robot.spotHeight : heightProps.minValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -683,4 +721,4 @@ NeatoVacuumRobotAccessory.prototype = {
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@@ -17,7 +17,33 @@
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"description": "Your Password"
|
||||
},
|
||||
"language": {
|
||||
"title": "language",
|
||||
"type": "string",
|
||||
"default": "en",
|
||||
"oneOf": [
|
||||
{
|
||||
"title": "English",
|
||||
"enum": [
|
||||
"en"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "German",
|
||||
"enum": [
|
||||
"de"
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "French",
|
||||
"enum": [
|
||||
"fr"
|
||||
]
|
||||
}
|
||||
],
|
||||
"required": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
180
index.js
180
index.js
@@ -4,12 +4,14 @@ let inherits = require('util').inherits,
|
||||
botvac = require('node-botvac'),
|
||||
|
||||
Service,
|
||||
Characteristic;
|
||||
Characteristic,
|
||||
NeatoVacuumRobotAccessory;
|
||||
|
||||
module.exports = function (homebridge)
|
||||
{
|
||||
Service = homebridge.hap.Service;
|
||||
Characteristic = homebridge.hap.Characteristic;
|
||||
NeatoVacuumRobotAccessory = require('./accessories/neatoVacuumRobot')(Service, Characteristic);
|
||||
homebridge.registerPlatform("homebridge-neato", "NeatoVacuumRobot", NeatoVacuumRobotPlatform);
|
||||
};
|
||||
|
||||
@@ -19,6 +21,7 @@ function NeatoVacuumRobotPlatform(log, config)
|
||||
this.serial = "1-3-3-7";
|
||||
this.email = config['email'];
|
||||
this.password = config['password'];
|
||||
this.language = config['language'];
|
||||
this.hiddenServices = '';
|
||||
this.hiddenServices = ('disabled' in config ? config['disabled'] : this.hiddenServices);
|
||||
this.hiddenServices = ('hidden' in config ? config['hidden'] : this.hiddenServices);
|
||||
@@ -54,50 +57,70 @@ NeatoVacuumRobotPlatform.prototype = {
|
||||
debug("Get robots");
|
||||
let accessories = [];
|
||||
this.boundaryNames = [];
|
||||
|
||||
this.getRobots(() =>
|
||||
{
|
||||
this.robots.forEach((robot, i) =>
|
||||
{
|
||||
this.log("Found robot #" + (i + 1) + " named \"" + robot.device.name + "\" with serial \"" + robot.device._serial.substring(0,9) + "XXXXXXXXXXXX\"");
|
||||
// // MOCK MULTIPLE ROBOTS START
|
||||
// let client = new botvac.Client();
|
||||
// client.authorize(this.email, this.password, false, (error) =>
|
||||
// {
|
||||
// client.getRobots((error, robs) =>
|
||||
// {
|
||||
// let testRobot = robs[0];
|
||||
// testRobot.getState((error, result) =>
|
||||
// {
|
||||
// testRobot.name = "Testrobot";
|
||||
// this.robots.push({device: testRobot, meta: result.meta, availableServices: result.availableServices});
|
||||
// // MOCK MULTIPLE ROBOTS END
|
||||
|
||||
// Start Update Intervall
|
||||
this.updateRobotTimer(robot.device._serial);
|
||||
|
||||
let NeatoVacuumRobotAccessory = require('./accessories/neatoVacuumRobot')(Service, Characteristic);
|
||||
let mainAccessory = new NeatoVacuumRobotAccessory(this, robot);
|
||||
accessories.push(mainAccessory);
|
||||
|
||||
robot.mainAccessory = mainAccessory;
|
||||
robot.roomAccessories = [];
|
||||
|
||||
// For testing purposes only
|
||||
// robot.boundary = {name: "Testroom", id: "1"};
|
||||
// let roomAccessory = new NeatoVacuumRobotAccessory(this, robot);
|
||||
// accessories.push(roomAccessory);
|
||||
// robot.roomAccessories.push(roomAccessory);
|
||||
|
||||
if (robot.device.maps)
|
||||
{
|
||||
robot.device.maps.forEach((map) =>
|
||||
{
|
||||
if (map.boundaries)
|
||||
this.robots.forEach((robot, i) =>
|
||||
{
|
||||
map.boundaries.forEach((boundary) =>
|
||||
{
|
||||
if (boundary.type === "polygon")
|
||||
{
|
||||
robot.boundary = boundary;
|
||||
let roomAccessory = new NeatoVacuumRobotAccessory(this, robot);
|
||||
accessories.push(roomAccessory);
|
||||
this.log("Found robot #" + (i + 1) + " named \"" + robot.device.name + "\" with serial \"" + robot.device._serial.substring(0, 9) + "XXXXXXXXXXXX\"");
|
||||
|
||||
robot.roomAccessories.push(roomAccessory);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
callback(accessories);
|
||||
let mainAccessory = new NeatoVacuumRobotAccessory(this, robot);
|
||||
accessories.push(mainAccessory);
|
||||
|
||||
robot.mainAccessory = mainAccessory;
|
||||
robot.roomAccessories = [];
|
||||
|
||||
// Start Update Intervall
|
||||
this.updateRobotTimer(robot.device._serial);
|
||||
|
||||
// // MOCK ZONE CLEANING START
|
||||
// robot.boundary = {name: "Testroom", id: "1"};
|
||||
// let roomAccessory = new NeatoVacuumRobotAccessory(this, robot);
|
||||
// accessories.push(roomAccessory);
|
||||
// robot.roomAccessories.push(roomAccessory);
|
||||
// // MOCK ZONE CLEANING END
|
||||
|
||||
if (robot.device.maps)
|
||||
{
|
||||
robot.device.maps.forEach((map) =>
|
||||
{
|
||||
if (map.boundaries)
|
||||
{
|
||||
map.boundaries.forEach((boundary) =>
|
||||
{
|
||||
if (boundary.type === "polygon")
|
||||
{
|
||||
robot.boundary = boundary;
|
||||
let roomAccessory = new NeatoVacuumRobotAccessory(this, robot);
|
||||
accessories.push(roomAccessory);
|
||||
|
||||
robot.roomAccessories.push(roomAccessory);
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
callback(accessories);
|
||||
|
||||
// // MOCK MULTIPLE ROBOTS START
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// // MOCK MULTIPLE ROBOTS END
|
||||
});
|
||||
},
|
||||
|
||||
@@ -116,7 +139,7 @@ NeatoVacuumRobotPlatform.prototype = {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get robots
|
||||
// Get all robots
|
||||
client.getRobots((error, robots) =>
|
||||
{
|
||||
if (error)
|
||||
@@ -133,67 +156,72 @@ NeatoVacuumRobotPlatform.prototype = {
|
||||
else
|
||||
{
|
||||
debug("Found " + robots.length + " robots");
|
||||
let requestedRobot = 0;
|
||||
let loadedRobots = 0;
|
||||
|
||||
robots.forEach((robot) =>
|
||||
{
|
||||
// Get Maps for each robot
|
||||
robot.getPersistentMaps((error, result) =>
|
||||
// Get additional information for the robot
|
||||
robot.getState((error, state) =>
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
this.log.error("Error updating persistent maps: " + error + ": " + result);
|
||||
callback();
|
||||
}
|
||||
else if (result.length === 0)
|
||||
{
|
||||
robot.maps = [];
|
||||
this.log.error("Error getting robot meta information: " + error + ": " + state);
|
||||
callback();
|
||||
}
|
||||
else
|
||||
{
|
||||
robot.maps = result;
|
||||
let requestedMap = 0;
|
||||
robot.maps.forEach((map) =>
|
||||
// Get all maps for each robot
|
||||
robot.getPersistentMaps((error, maps) =>
|
||||
{
|
||||
// Get Map Boundary Lines
|
||||
robot.getMapBoundaries(map.id, (error, result) =>
|
||||
if (error)
|
||||
{
|
||||
if (error)
|
||||
this.log.error("Error updating persistent maps: " + error + ": " + maps);
|
||||
callback();
|
||||
}
|
||||
// Robot has no maps
|
||||
else if (maps.length === 0)
|
||||
{
|
||||
robot.maps = [];
|
||||
this.robots.push({device: robot, meta: state.meta, availableServices: state.availableServices});
|
||||
loadedRobots++;
|
||||
if (loadedRobots === robots.length)
|
||||
{
|
||||
this.log.error("Error getting boundaries: " + error + ": " + result)
|
||||
callback();
|
||||
}
|
||||
else
|
||||
}
|
||||
// Robot has maps
|
||||
else
|
||||
{
|
||||
robot.maps = maps;
|
||||
let loadedMaps = 0;
|
||||
robot.maps.forEach((map) =>
|
||||
{
|
||||
map.boundaries = result.boundaries;
|
||||
}
|
||||
requestedMap++;
|
||||
|
||||
// Robot is completely requested if all maps are requested
|
||||
if (requestedMap === robot.maps.length)
|
||||
{
|
||||
// Get additional information
|
||||
robot.getState((error, result) =>
|
||||
// Save zones in each map
|
||||
robot.getMapBoundaries(map.id, (error, result) =>
|
||||
{
|
||||
if (error)
|
||||
{
|
||||
this.log.error("Error getting robot meta information: " + error + ": " + result);
|
||||
callback();
|
||||
this.log.error("Error getting boundaries: " + error + ": " + result)
|
||||
}
|
||||
else
|
||||
{
|
||||
this.robots.push({device: robot, meta: result.meta, availableServices: result.availableServices});
|
||||
requestedRobot++;
|
||||
map.boundaries = result.boundaries;
|
||||
}
|
||||
loadedMaps++;
|
||||
|
||||
// Initial request is complete if all robots are requested.
|
||||
if (requestedRobot === robots.length)
|
||||
// Robot is completely requested if zones for all maps are loaded
|
||||
if (loadedMaps === robot.maps.length)
|
||||
{
|
||||
this.robots.push({device: robot, meta: state.meta, availableServices: state.availableServices});
|
||||
loadedRobots++;
|
||||
if (loadedRobots === robots.length)
|
||||
{
|
||||
callback();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "homebridge-neato",
|
||||
"version": "0.7.0",
|
||||
"version": "0.7.3",
|
||||
"description": "A Neato vacuum robot plugin for homebridge.",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
Reference in New Issue
Block a user