Since this thing is on the innerwebs I suppose it should have a
[python_utils.git] / smart_home / lights.py
index 096e0de6b6812fc2c8f17110e96f227b8d5fe649..ee23fb08f4e60ef4664338cde7e53bdefd340544 100644 (file)
@@ -1,5 +1,7 @@
 #!/usr/bin/env python3
 
+# © Copyright 2021-2022, Scott Gasch
+
 """Utilities for dealing with the smart lights."""
 
 import datetime
@@ -283,7 +285,7 @@ class TPLinkLight(BaseLight):
         if extra_args is not None:
             cmd += f" {extra_args}"
         logger.debug('About to execute: %s', cmd)
-        return tplink.tplink_command(cmd)
+        return tplink.tplink_command_wrapper(cmd)
 
     @overrides
     def turn_on(self) -> bool:
@@ -315,13 +317,15 @@ class TPLinkLight(BaseLight):
         raise NotImplementedError
 
     def get_info(self) -> Optional[Dict]:
-        cmd = self.get_cmdline() + "-c info"
-        self.info = tplink.tplink_get_info(cmd)
-        if self.info is not None:
-            self.info_ts = datetime.datetime.now()
-        else:
-            self.info_ts = None
-        return self.info
+        ip = self.get_ip()
+        if ip is not None:
+            self.info = tplink.tplink_get_info(ip)
+            if self.info is not None:
+                self.info_ts = datetime.datetime.now()
+            else:
+                self.info_ts = None
+            return self.info
+        return None
 
     @overrides
     def status(self) -> str:
@@ -363,7 +367,7 @@ class TPLinkLight(BaseLight):
             self.get_cmdline()
             + '-j \'{"smartlife.iot.dimmer":{"set_brightness":{"brightness":%d}}}\'' % level
         )
-        return tplink.tplink_command(cmd)
+        return tplink.tplink_command_wrapper(cmd)
 
 
 # class GoogleLightGroup(GoogleLight):