tlyakhov / python-decora_wifi

Python Library for Interacting with Leviton Decora Smart WiFi Switches & Dimmers
MIT License
37 stars 21 forks source link

REST API capacity limit? 502 Bad Gateway #16

Open 7ooL opened 3 years ago

7ooL commented 3 years ago

I have a fork of this project in my own project and I'm pulling the decora system for statuses every 10 seconds. I'm wondering if there is a REST API capacity limit being hit?

it appears to be almost arandom the the login to the system for switch status failes with a bad gateway (502) every so often, 2-4 time a day.

The traceback:

File "/home/ha/web_home_auto/homeauto/decora.py", line 90, in sync_decora
    session.login(getattr(decoraAcct, 'username'), getattr(decoraAcct, 'password'))
  File "/home/ha/web_home_auto/homeauto/api_decora/decora_wifi/__init__.py", line 75, in login
    login_json = Person.login(self, payload)
  File "/home/ha/web_home_auto/homeauto/api_decora/decora_wifi/models/person.py", line 569, in login
    return session.call_api(api, attribs, 'post')
  File "/home/ha/web_home_auto/homeauto/api_decora/decora_wifi/__init__.py", line 59, in call_api
    raise ValueError(msg)
ValueError: myLeviton API call (/Person/login) failed: 502, <html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
</body>
</html>

Frequency of error: image

adifelice-godaddy commented 3 years ago

It stopped working for me few days ago. It's timing out now:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/admin/git/python-decora_wifi/decora_wifi/__init__.py", line 77, in login
    login_json = Person.login(self, payload)
  File "/Users/admin/git/python-decora_wifi/decora_wifi/models/person.py", line 569, in login
    return session.call_api(api, attribs, 'post')
  File "/Users/admin/git/python-decora_wifi/decora_wifi/__init__.py", line 53, in call_api
    if self.login(self._email, self._password) is None:
  File "/Users/admin/git/python-decora_wifi/decora_wifi/__init__.py", line 77, in login
    login_json = Person.login(self, payload)
  File "/Users/admin/git/python-decora_wifi/decora_wifi/models/person.py", line 569, in login
    return session.call_api(api, attribs, 'post')
  File "/Users/admin/git/python-decora_wifi/decora_wifi/__init__.py", line 61, in call_api
    raise ValueError(msg)
ValueError: myLeviton API call (/Person/login) failed: 504, <html>
<head><title>504 Gateway Time-out</title></head>
<body>
<center><h1>504 Gateway Time-out</h1></center>
</body>
</html>