Skip to content

Commit

Permalink
Merge pull request #7 from iRayanKhan/Experimental
Browse files Browse the repository at this point in the history
Added bin full notifications
  • Loading branch information
iRayanKhan authored Oct 30, 2020
2 parents aade623 + 5fba5b3 commit 60b2644
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

All notable changes to this project will be documented in this file. This project uses [semantic versioning](https://semver.org/).

## 1.0.0
## 1.1.0 (2020-10-29)
* Added support for bin full notifications.

## 1.0.0 (2020-10-28)
* Plugin verified

## 0.0.2 (2020-10-28)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- Roomba battery level (with low battery warning)
- Roomba docked notifcation
- Roomba running notification
- Roomba bin full notification


<span align="center">
Expand Down
5 changes: 5 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@
"title": "Show running status as a contact sensor",
"required": false
},
"binContactSensor": {
"type": "boolean",
"title": "Show if bin is full as a contact sensor",
"required": false
},
"cacheTTL": {
"type": "number",
"title": "TTL Cache",
Expand Down
25 changes: 21 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const roombaAccessory = function (log, config) {
this.log = log;
this.name = config.name;
this.model = config.model;
this.serialnum = config.serialnum;
this.blid = config.blid;
this.robotpwd = config.robotpwd;
this.ipaddress = config.ipaddress;
Expand All @@ -19,6 +20,7 @@ const roombaAccessory = function (log, config) {
this.autoRefreshEnabled = config.autoRefreshEnabled;
this.showDockAsContactSensor = config.dockContactSensor == undefined ? true : config.dockContactSensor;
this.showRunningAsContactSensor = config.runningContactSensor;
this.showBinStatusAsContactSensor = config.binContactSensor;
this.cacheTTL = config.cacheTTL || 5;
this.disableWait = config.disableWait;
this.roomba = null;
Expand All @@ -33,7 +35,9 @@ const roombaAccessory = function (log, config) {
if (this.showRunningAsContactSensor) {
this.runningService = new Service.ContactSensor(this.name + " Running", "running");
}

if (this.showBinStatusAsContactSensor) {
this.binService = new Service.ContactSensor(this.name + " BinFull", "Full");
}
this.cache = new nodeCache({
stdTTL: this.cacheTTL,
checkperiod: 1,
Expand Down Expand Up @@ -237,6 +241,8 @@ roombaAccessory.prototype = {
});
},



identify(callback) {
this.log("Identify requested. Not supported yet.");

Expand Down Expand Up @@ -348,12 +354,12 @@ roombaAccessory.prototype = {
getServices() {
const services = [];

this.accessoryInfo.setCharacteristic(Characteristic.Manufacturer, "iRobot");
this.accessoryInfo.setCharacteristic(Characteristic.SerialNumber, "See iRobot App");
this.accessoryInfo.setCharacteristic(Characteristic.Manufacturer, "iRayanKhan");
this.accessoryInfo.setCharacteristic(Characteristic.SerialNumber, this.serialnum);
this.accessoryInfo.setCharacteristic(Characteristic.Identify, false);
this.accessoryInfo.setCharacteristic(Characteristic.Name, this.name);
this.accessoryInfo.setCharacteristic(Characteristic.Model, this.model);
this.accessoryInfo.setCharacteristic(Characteristic.FirmwareRevision, this.firmware);
this.accessoryInfo.setCharacteristic(Characteristic.FirmwareRevision, "1.1.0");
services.push(this.accessoryInfo);

this.switchService
Expand Down Expand Up @@ -388,6 +394,12 @@ roombaAccessory.prototype = {
.on("get", this.getRunningStatus.bind(this));
services.push(this.runningService);
}
if (this.showBinStatusAsContactSensor) {
this.binService
.getCharacteristic(Characteristic.ContactSensorState)
.on("get", this.getFilterStatus.bind(this)) ;
services.push(this.binService);
}

return services;
},
Expand Down Expand Up @@ -434,6 +446,11 @@ roombaAccessory.prototype = {
.getCharacteristic(Characteristic.ContactSensorState)
.updateValue(status.running);
}
if (this.showBinStatusAsContactSensor) {
this.binService
.getCharacteristic(Characteristic.ContactSensorState)
.updateValue(status.binStatus);
}
},

enableAutoRefresh() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@
"scripts": {
"getrobotpwd": "cd node_modules/dorita980 && npm install && node ./bin/getpassword.js"
},
"version": "1.0.0"
"version": "1.1.0"
}

0 comments on commit 60b2644

Please sign in to comment.