コード例 #1
0
ファイル: __init__.py プロジェクト: builderjer/jarbas_house
 def color(self):
     if self.is_off:
         return Color.from_name("black")
     if self._bulb.is_color:
         h, s, v = tplink_hsv_to_hsv(*self._bulb.hsv)
         return Color.from_hsv(h, s, v)
     return Color.from_name("white")
コード例 #2
0
 def change_color(self, color="white"):
     if isinstance(color, Color):
         if color.rgb == (0, 0, 0):
             self.turn_off()
         else:
             if self.is_off:
                 self.turn_on()
             if Color.from_name("white") != color:
                 print("ERROR: bulb does not support color change")
     else:
         color = Color.from_name(color)
         self.change_color(color)
コード例 #3
0
 def change_color(self, color="violet"):
     if isinstance(color, Color):
         if color.rgb == (0, 0, 0):
             self.turn_off()
         else:
             if self.is_off:
                 self.turn_on()
             if Color.from_name("violet") != color:
                 print(
                     "ERROR: mosquito killer does not support color change")
     else:
         color = Color.from_name(color)
         self.change_color(color)
コード例 #4
0
ファイル: __init__.py プロジェクト: builderjer/jarbas_house
 def change_color(self, color):
     if isinstance(color, Color):
         color = color.rgb
         if color == (0, 0, 0):
             self.turn_off()
         else:
             if self.is_off:
                 self.turn_on()
             self._bulb.set_rgb(*color)
     else:
         color = Color.from_name(color)
         self.change_color(color)
コード例 #5
0
ファイル: __init__.py プロジェクト: builderjer/jarbas_house
 def change_color(self, name):
     if isinstance(name, Color):
         if name.rgb == (0, 0, 0):
             self.turn_off()
         else:
             if self.is_off:
                 self.turn_on()
             if self._bulb.is_color:
                 self._bulb.hsv = hsv_to_tplink_hsv(*name.hsv)
     else:
         color = Color.from_name(name)
         self.change_color(color)
コード例 #6
0
 def color(self):
     if self.is_off:
         return Color.from_name("black")
     return Color.from_name("white")
コード例 #7
0
 def random_color(self):
     color = Color(random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
     self.change_color(color)
コード例 #8
0
 def change_color_rgb(self, r, g, b):
     self.change_color(Color(r, g, b))
コード例 #9
0
 def change_color_hsv(self, h, s, v):
     self.change_color(Color.from_hsv(h, s, v))
コード例 #10
0
 def change_color_hex(self, hexcolor):
     self.change_color(Color.from_hex(hexcolor))
コード例 #11
0
ファイル: __init__.py プロジェクト: builderjer/jarbas_house
 def color(self):
     if self.is_off:
         return Color.from_name("black")
     return Color(*self._bulb.rgb)
コード例 #12
0
 def color(self):
     if self.is_off:
         return Color.from_name("black")
     return Color.from_name("violet")