summaryrefslogtreecommitdiff
path: root/smart_home/lights.py
diff options
context:
space:
mode:
Diffstat (limited to 'smart_home/lights.py')
-rw-r--r--smart_home/lights.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/smart_home/lights.py b/smart_home/lights.py
index 76b1500..dd211eb 100644
--- a/smart_home/lights.py
+++ b/smart_home/lights.py
@@ -78,6 +78,10 @@ class BaseLight(dev.Device):
return ansi.COLOR_NAMES_TO_RGB.get(color, None)
@abstractmethod
+ def status(self) -> str:
+ pass
+
+ @abstractmethod
def turn_on(self) -> bool:
pass
@@ -131,6 +135,12 @@ class GoogleLight(BaseLight):
)
@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?")
if not r.success:
@@ -212,6 +222,13 @@ class TuyaLight(BaseLight):
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()
return True
@@ -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: