diff options
Diffstat (limited to 'ShellyPy/gen2.py')
-rw-r--r-- | ShellyPy/gen2.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ShellyPy/gen2.py b/ShellyPy/gen2.py index 96747c9..199fb84 100644 --- a/ShellyPy/gen2.py +++ b/ShellyPy/gen2.py @@ -6,6 +6,7 @@ else: JSONDecodeError = ValueError from requests import post +from requests.auth import HTTPDigestAuth from .error import BadLogin, NotFound, BadResponse @@ -23,9 +24,9 @@ class ShellyGen2(ShellyBase): @param init calls the update method on init """ + self.payload_id = 1 super().__init__(ip, port, *args, **kwargs) self.__generation__ = 2 - self.payload_id = 1 def update(self): status = self.settings() @@ -50,7 +51,13 @@ class ShellyGen2(ShellyBase): if values: payload["params"] = values - response = post(url, auth=self.__credentials__, + credentials = None + try: + credentials = auth=HTTPDigestAuth('admin', self.__credentials__[1]) + except IndexError: + pass + + response = post(url, auth=credentials, json=payload, timeout=self.__timeout__) |