From 2d6c9411912b94e28ecf2273dec87b90d12994ef Mon Sep 17 00:00:00 2001 From: Henry Stern Date: Wed, 16 Dec 2020 20:05:16 -0400 Subject: [PATCH 1/2] Fix UnboundLocalError in API._send_request Addresses a symptom of #53 --- pymyq/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymyq/api.py b/pymyq/api.py index 71aff58..4556d4c 100644 --- a/pymyq/api.py +++ b/pymyq/api.py @@ -92,6 +92,7 @@ async def _send_request( return data except ClientError as err: _LOGGER.debug(f"Attempt {attempt} request failed with exception: {str(err)}") + message = f"Error requesting data from {url}: {data.get('description', str(err))}" if hasattr(err, "status") and err.status == 401: if login_request: self._credentials = {} @@ -111,7 +112,6 @@ async def _send_request( attempt = 0 continue - message = f"Error requesting data from {url}: {data.get('description', str(err))}" _LOGGER.error(message) raise RequestError(message) From 5af95a8b3858d844e7b8380629541d4e7e315b40 Mon Sep 17 00:00:00 2001 From: Henry Stern Date: Wed, 16 Dec 2020 20:48:55 -0400 Subject: [PATCH 2/2] Change User-Agent to pymyq Chamberlain is blocking the User-Agent "okhttp/3.10.0" Root cause of #53 --- pymyq/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymyq/api.py b/pymyq/api.py index 4556d4c..b52b8c3 100644 --- a/pymyq/api.py +++ b/pymyq/api.py @@ -17,7 +17,7 @@ API_BASE = "https://api.myqdevice.com/api/v{0}" DEFAULT_APP_ID = "JVM/G9Nwih5BwKgNCjLxiFUQxQijAebyyg8QUHr7JOrP+tuPb8iHfRHKwTmDzHOu" -DEFAULT_USER_AGENT = "okhttp/3.10.0" +DEFAULT_USER_AGENT = 'pymyq' DEFAULT_BRAND_ID = 2 DEFAULT_REQUEST_RETRIES = 5 DEFAULT_CULTURE = "en"