summaryrefslogtreecommitdiff
path: root/smart_home/tplink_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'smart_home/tplink_utils.py')
-rw-r--r--smart_home/tplink_utils.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/smart_home/tplink_utils.py b/smart_home/tplink_utils.py
index 053ce33..30d3bd8 100644
--- a/smart_home/tplink_utils.py
+++ b/smart_home/tplink_utils.py
@@ -54,7 +54,7 @@ commands = {
@timeout(10.0, use_signals=False, error_message="Timed out waiting for tplink.py")
-def tplink_command(command: str) -> bool:
+def tplink_command_wrapper(command: str) -> bool:
result = os.system(command)
signal = result & 0xFF
if signal != 0:
@@ -166,7 +166,7 @@ def communicate_with_device(
if not brief:
raw = ''
for b in encrypted_raw_request:
- raw += '%02X ' % b
+ raw += f'{b:02X} '
logger.debug('Sent raw: "%s"', raw)
# Note: 4 bytes of garbage (the key)
@@ -176,14 +176,16 @@ def communicate_with_device(
if not brief:
raw = ''
for b in raw_response:
- raw += '%02X ' % b
+ raw += f'{b:02X} '
logger.debug('Received raw: "%s"', raw)
- if '"err_code":0' not in decrypted_raw_response:
- if '"err_code": 0' not in decrypted_raw_response:
- logger.error("Did not see clean err_code in response?!")
- return (False, all_responses)
- logger.debug('All commands succeeded, returning True.')
+ if (
+ '"err_code":0' not in decrypted_raw_response
+ and '"err_code": 0' not in decrypted_raw_response
+ ):
+ logger.error("Did not see clean err_code in response?!")
+ return (False, all_responses)
+ logger.debug('All commands succeeded.')
return (True, all_responses)
except socket.error:
logger.error("Cound not connect to host %s:%s", ip, port)