diff options
Diffstat (limited to 'smart_home/outlets.py')
| -rw-r--r-- | smart_home/outlets.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/smart_home/outlets.py b/smart_home/outlets.py index 8fd0948..6cc8d57 100644 --- a/smart_home/outlets.py +++ b/smart_home/outlets.py @@ -13,6 +13,7 @@ import re import subprocess import sys from typing import Any, Dict, List, Optional +import warnings from meross_iot.http_api import MerossHttpClient from meross_iot.manager import MerossManager @@ -48,14 +49,18 @@ def tplink_outlet_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 |
