summaryrefslogtreecommitdiff
path: root/smart_home/lights.py
diff options
context:
space:
mode:
authorScott <[email protected]>2022-01-11 13:33:24 -0800
committerScott <[email protected]>2022-01-11 13:33:24 -0800
commitb454ad295eb3024a238d32bf2aef1ebc3c496b44 (patch)
tree89368a7cdad571da9e2c7297190fdce48eb3feb9 /smart_home/lights.py
parentd2478310649d51e14f8ece57651ca9d925d98793 (diff)
Start using warnings from stdlib.
Diffstat (limited to 'smart_home/lights.py')
-rw-r--r--smart_home/lights.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/smart_home/lights.py b/smart_home/lights.py
index e23569a..44b3634 100644
--- a/smart_home/lights.py
+++ b/smart_home/lights.py
@@ -11,6 +11,7 @@ import re
import subprocess
import sys
from typing import Any, Dict, List, Optional, Tuple
+import warnings
from overrides import overrides
import tinytuya as tt
@@ -46,14 +47,18 @@ def tplink_light_command(command: str) -> bool:
result = os.system(command)
signal = result & 0xFF
if signal != 0:
- logger.warning(f'{command} died with signal {signal}')
- logging_utils.hlog("%s died with signal %d" % (command, signal))
+ msg = f'{command} died with signal {signal}'
+ logger.warning(msg)
+ warnings.warn(msg)
+ logging_utils.hlog(msg)
return False
else:
exit_value = result >> 8
if exit_value != 0:
- logger.warning(f'{command} failed, exited {exit_value}')
- logging_utils.hlog("%s failed, exit %d" % (command, exit_value))
+ msg = f'{command} failed, exited {exit_value}'
+ logger.warning(msg)
+ warnings.warn(msg)
+ logging_utils.hlog(msg)
return False
logger.debug(f'{command} succeeded.')
return True