Browse Source

Make requested_oadr_poll_freq optional when receiving registration confirmation

Stan Janssen 4 years ago
parent
commit
26300b502b
1 changed files with 3 additions and 2 deletions
  1. 3 2
      openleadr/client.py

+ 3 - 2
openleadr/client.py

@@ -221,7 +221,7 @@ class OpenADRClient:
             print(f"Got error on Create Party Registration: {status_code} {status_description}")
             print(f"Got error on Create Party Registration: {status_code} {status_description}")
             return
             return
         self.ven_id = response_payload['ven_id']
         self.ven_id = response_payload['ven_id']
-        self.poll_frequency = response_payload['requested_oadr_poll_freq']
+        self.poll_frequency = response_payload.get('requested_oadr_poll_freq', timedelta(seconds=10))
         print(f"VEN is now registered with ID {self.ven_id}")
         print(f"VEN is now registered with ID {self.ven_id}")
         print(f"The polling frequency is {self.poll_frequency}")
         print(f"The polling frequency is {self.poll_frequency}")
         return response_type, response_payload
         return response_type, response_payload
@@ -345,8 +345,9 @@ class OpenADRClient:
             return None, {}
             return None, {}
         try:
         try:
             message_type, message_payload = self._parse_message(content)
             message_type, message_payload = self._parse_message(content)
-        except:
+        except Exception as err:
             warnings.warn(f"The incoming message could not be parsed or validated: {content}.")
             warnings.warn(f"The incoming message could not be parsed or validated: {content}.")
+            raise err
             return None, {}
             return None, {}
         return message_type, message_payload
         return message_type, message_payload