Skip to content

Commit

Permalink
enhance password errors
Browse files Browse the repository at this point in the history
When fixing return errors from the server I noticed that I could give a better message if the name/password were not authorized. So now I post a better error in the logs for this common case.

I foound these erros when ryobi was timing out the other day when getting device info. I hope that was an issue on there end or some and not specfically blocking my request. There whole backend was not down at the time so it is hard to knkow for sure.

If however they start to actually block me from pollig then....i'd have to put this project to rest. :-(
  • Loading branch information
rsonnens committed Sep 13, 2019
1 parent 400366d commit 236b833
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions api/Ryobi_GDO_API.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ class Ryobi_GDO_API {

try {
const jsonObj = JSON.parse(body);

// can see: {"result":"Unauthorized"}
if (jsonObj.result == "Unauthorized") {
throw new Error ("Unauthorized -- check your ryobi username/password");
}

this.apikey = jsonObj.result.auth.apiKey;
if (this.debug_sensitive) this.debug("apiKey: "+ this.apikey);
callback(null, this.apikey);
Expand Down Expand Up @@ -65,6 +71,12 @@ class Ryobi_GDO_API {

try {
const jsonObj = JSON.parse(body);

// can see: {"result":"Unauthorized"}
if (jsonObj.result == "Unauthorized") {
throw new Error ("Unauthorized -- check your ryobi username/password");
}

var deviceModel = jsonObj.result[0].deviceTypeIds[0];
this.deviceid = (deviceModel == 'gda500hub') ? jsonObj.result[1].varName : jsonObj.result[0].varName;
if (this.debug_sensitive) this.debug("deviceModel: " + deviceModel);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-garagedoor-ryobi",
"version": "0.2.4444",
"version": "0.2.6",
"description": "Ryobi Garage Door plugin for homebridge: https://github.com/nfarina/homebridge",
"license": "ISC",

Expand Down

0 comments on commit 236b833

Please sign in to comment.