Small bugfixes; also, add a new machine to the remote executor pool.
[python_utils.git] / smart_home / lights.py
index 76b1500d5490693c939a025a49ecf886f2e38dab..dd211eb13cdb23361cc17e9129bfcf613dbb154e 100644 (file)
@@ -77,6 +77,10 @@ class BaseLight(dev.Device):
         color = color.lower()
         return ansi.COLOR_NAMES_TO_RGB.get(color, None)
 
+    @abstractmethod
+    def status(self) -> str:
+        pass
+
     @abstractmethod
     def turn_on(self) -> bool:
         pass
@@ -130,6 +134,12 @@ class GoogleLight(BaseLight):
             ask_google(f"turn {self.goog_name()} off")
         )
 
+    @overrides
+    def status(self) -> str:
+        if self.is_on():
+            return 'ON'
+        return 'off'
+
     @overrides
     def is_on(self) -> bool:
         r = ask_google(f"is {self.goog_name()} on?")
@@ -211,6 +221,13 @@ class TuyaLight(BaseLight):
     def get_status(self) -> Dict[str, Any]:
         return self.bulb.status()
 
+    @overrides
+    def status(self) -> str:
+        ret = ''
+        for k, v in self.bulb.status().items():
+            ret += f'{k} = {v}\n'
+        return ret
+
     @overrides
     def turn_on(self) -> bool:
         self.bulb.turn_on()
@@ -237,12 +254,14 @@ class TuyaLight(BaseLight):
 
     @overrides
     def set_dimmer_level(self, level: int) -> bool:
+        logger.debug(f'Setting brightness to {level}')
         self.bulb.set_brightness(level)
         return True
 
     @overrides
     def make_color(self, color: str) -> bool:
         rgb = BaseLight.parse_color_string(color)
+        logger.debug(f'Light color: {color} -> {rgb}')
         if rgb is not None:
             self.bulb.set_colour(rgb[0], rgb[1], rgb[2])
             return True
@@ -328,6 +347,13 @@ class TPLinkLight(BaseLight):
             self.info_ts = None
             return None
 
+    @overrides
+    def status(self) -> str:
+        ret = ''
+        for k, v in self.get_info().items():
+            ret += f'{k} = {v}\n'
+        return ret
+
     def get_on_duration_seconds(self, child: str = None) -> int:
         self.info = self.get_info()
         if child is None: