88from requests .exceptions import HTTPError
99
1010from .. import query as q
11+ from ..__about__ import __version__
1112from ..utils import _camel_to_snake_case , _sanitize_session_id
1213from .decorators import require_lock , require_session
1314from .exceptions import (
@@ -48,6 +49,7 @@ def __init__(self, base_url=None, domain=None, session_id=None):
4849 self ._panel = None
4950 self ._lock = Lock ()
5051 # Debug
52+ _LOGGER .debug (f"Client | Library version: { __version__ } " )
5153 _LOGGER .debug (f"Client | Router: { self ._router ._base_url } " )
5254 _LOGGER .debug (f"Client | Domain: { self ._domain } " )
5355
@@ -174,6 +176,7 @@ def lock(self, code, user_id=1):
174176 # Main units that do not require a userId param, expects userId to be "1"
175177 payload = {"userId" : user_id , "password" : code , "sessionId" : self ._session_id }
176178 response = self ._session .post (self ._router .lock , data = payload )
179+ _LOGGER .debug (f"Client | Lock response: { response .text } " )
177180
178181 try :
179182 response .raise_for_status ()
@@ -192,7 +195,7 @@ def lock(self, code, user_id=1):
192195 raise CodeError
193196
194197 self ._lock .acquire ()
195- _LOGGER .debug (f "Client | Lock acquired with response { body } " )
198+ _LOGGER .debug ("Client | Lock successful " )
196199 try :
197200 yield self
198201 finally :
@@ -216,9 +219,10 @@ def unlock(self):
216219 """
217220 payload = {"sessionId" : self ._session_id }
218221 response = self ._session .post (self ._router .unlock , data = payload )
222+ _LOGGER .debug (f"Client | Unlock response: { response .text } " )
219223 response .raise_for_status ()
220224
221- _LOGGER .debug (f "Client | Lock released with response { response . text } " )
225+ _LOGGER .debug ("Client | Unlock successful " )
222226 # Release the lock only in case of success, so that if it fails
223227 # the owner of the lock can properly unlock the system again
224228 # (maybe with a retry)
@@ -267,15 +271,15 @@ def arm(self, sectors=None):
267271
268272 # Send the payload to arm sectors
269273 response = self ._session .post (self ._router .send_command , data = payload )
274+ _LOGGER .debug (f"Client | Arm response: { response .text } " )
270275 response .raise_for_status ()
271276 body = response .json ()
272277
273278 # Errors returns 200 with "Successful == False" JSON key
274279 if not body [0 ]["Successful" ]:
275- _LOGGER .error (f"Client | Arming response: { body } " )
276280 raise CommandError
277281
278- _LOGGER .debug (f "Client | Arming successful with response: { body } " )
282+ _LOGGER .debug ("Client | Arm successful" )
279283 return True
280284
281285 @require_session
@@ -321,15 +325,15 @@ def disarm(self, sectors=None):
321325
322326 # Send the payload to disarm sectors
323327 response = self ._session .post (self ._router .send_command , data = payload )
328+ _LOGGER .debug (f"Client | Disarm response: { response .text } " )
324329 response .raise_for_status ()
325330 body = response .json ()
326331
327332 # Errors returns 200 with "Successful == False" JSON key
328333 if not body [0 ]["Successful" ]:
329- _LOGGER .error (f"Client | Disarming response: { body } " )
330334 raise CommandError
331335
332- _LOGGER .debug (f "Client | Disarming successful with response: { body } " )
336+ _LOGGER .debug ("Client | Disarm successful" )
333337 return True
334338
335339 @require_session
0 commit comments