knuckleheadsmiff / homebridge-garagedoor-ryobi

Homebridge plugin for Ryobi GDO (Garage Door Opener)
4 stars 4 forks source link

Missing JSON in return results! Need to debug to determine is OK or if a real problem. #8

Closed knuckleheadsmiff closed 4 years ago

knuckleheadsmiff commented 4 years ago

I am seeing more transient errors in the logs I've noticed but Im not sure if it is something flaky with the ryobi website. I'm getting responses with invalid JSON but then it works after retrying a few times.

I should fix the logging to show the HTTP return code and debug this more. This seems to only be an issue with Andy's change to use cookies to maintain auth.

I do minimal work on this so if someone else wants to take a look than great!

here is what I am seeing in the logs a lot:

May 25 14:45:24 raspberrypi homebridge[2413]: [5/25/2020, 2:45:24 PM] [Garage Door] State of Garage Door is: CLOSED
May 25 14:47:55 raspberrypi homebridge[2413]: [5/25/2020, 2:47:55 PM] [Garage Door] Error update 1 - retrieving ryobi GDO status
May 25 14:47:55 raspberrypi homebridge[2413]: [5/25/2020, 2:47:55 PM] [Garage Door] Error Message: SyntaxError: Unexpected token < in JSON at position 0
May 25 14:49:41 raspberrypi homebridge[2413]: [5/25/2020, 2:49:41 PM] [Garage Door] State of Garage Door is: CLOSED
May 25 14:52:11 raspberrypi homebridge[2413]: [5/25/2020, 2:52:11 PM] [Garage Door] Error update 1 - retrieving ryobi GDO status
May 25 14:52:11 raspberrypi homebridge[2413]: [5/25/2020, 2:52:11 PM] [Garage Door] Error Message: SyntaxError: Unexpected token < in JSON at position 0
May 25 14:54:42 raspberrypi homebridge[2413]: [5/25/2020, 2:54:42 PM] [Garage Door] Error update 1 - retrieving ryobi GDO status
May 25 14:54:42 raspberrypi homebridge[2413]: [5/25/2020, 2:54:42 PM] [Garage Door] Error Message: SyntaxError: Unexpected token < in JSON at position 0
May 25 14:56:12 raspberrypi homebridge[2413]: [5/25/2020, 2:56:12 PM] [Garage Door] State of Garage Door is: CLOSED
knuckleheadsmiff commented 4 years ago

Should log the 'response' here under the debug_sensitive flag:

            var queryUri = deviceURL + '/' + deviceID;
            request(queryUri, function (err, response, body) {
                this.debug("GetStatus responded: ");
                if (!err) {
                    if (this.debug_sensitive) this.debug("body: "+ body);

                    try {
knuckleheadsmiff commented 4 years ago

Oddly the error has gone away with no changes. I'm assuming it was an issue on the server end. I'd like to add better logging for this case behaves and put out a better error but for now I'll just close the bug. Im trying to maintain this as little as possible,