|
|
@ -27,11 +27,19 @@ class HueLight:
|
|
|
|
if 'bri' in keys:
|
|
|
|
if 'bri' in keys:
|
|
|
|
self.m_bri: int = data_slice['bri']
|
|
|
|
self.m_bri: int = data_slice['bri']
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.m_bri: int = 0
|
|
|
|
self.m_bri: int = -1
|
|
|
|
if 'ct' in keys:
|
|
|
|
if 'ct' in keys:
|
|
|
|
self.m_ct: int = data_slice['ct']
|
|
|
|
self.m_ct: int = data_slice['ct']
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.m_ct: int = 0
|
|
|
|
self.m_ct: int = -1
|
|
|
|
|
|
|
|
if 'hue' in keys:
|
|
|
|
|
|
|
|
self.m_hue: int = data_slice['hue']
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.m_hue: int = -1
|
|
|
|
|
|
|
|
if 'sat' in keys:
|
|
|
|
|
|
|
|
self.m_sat: int = data_slice['sat']
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
self.m_sat: int = -1
|
|
|
|
self.m_alert: str = data_slice['alert']
|
|
|
|
self.m_alert: str = data_slice['alert']
|
|
|
|
if 'colormode' in keys:
|
|
|
|
if 'colormode' in keys:
|
|
|
|
self.m_colormode: str = data_slice['colormode']
|
|
|
|
self.m_colormode: str = data_slice['colormode']
|
|
|
@ -44,7 +52,7 @@ class HueLight:
|
|
|
|
"""Get current brightness of the light
|
|
|
|
"""Get current brightness of the light
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Returns:
|
|
|
|
int: 0-254
|
|
|
|
int: -1-254
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return self.m_bri
|
|
|
|
return self.m_bri
|
|
|
|
|
|
|
|
|
|
|
@ -52,10 +60,26 @@ class HueLight:
|
|
|
|
"""Get current color temp of the light
|
|
|
|
"""Get current color temp of the light
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Returns:
|
|
|
|
int: 0, 153-500, 0 means it cant do color temp
|
|
|
|
int: -1, 153-500, -1 means it cant do color temp
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return self.m_ct
|
|
|
|
return self.m_ct
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_hue(self) -> int:
|
|
|
|
|
|
|
|
"""Get current hue of the light
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
int: -1-65535
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self.m_hue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_sat(self):
|
|
|
|
|
|
|
|
"""Get current saturation of the light
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
int: -1-254
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self.m_hue
|
|
|
|
|
|
|
|
|
|
|
|
def is_on(self) -> bool:
|
|
|
|
def is_on(self) -> bool:
|
|
|
|
"""Is this thing on?
|
|
|
|
"""Is this thing on?
|
|
|
|
|
|
|
|
|
|
|
@ -107,17 +131,17 @@ class HueLight:
|
|
|
|
if 'min' in keys:
|
|
|
|
if 'min' in keys:
|
|
|
|
self.m_min: int = data_slice['min']
|
|
|
|
self.m_min: int = data_slice['min']
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.m_min: int = 0
|
|
|
|
self.m_min: int = -1
|
|
|
|
if 'max' in keys:
|
|
|
|
if 'max' in keys:
|
|
|
|
self.m_max: int = data_slice['max']
|
|
|
|
self.m_max: int = data_slice['max']
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.m_max: int = 0
|
|
|
|
self.m_max: int = -1
|
|
|
|
|
|
|
|
|
|
|
|
def get_max(self) -> int:
|
|
|
|
def get_max(self) -> int:
|
|
|
|
"""Get the max colortemp of this light
|
|
|
|
"""Get the max colortemp of this light
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Returns:
|
|
|
|
int: Max colortemp of this light, 0 means you can't change colortemp
|
|
|
|
int: Max colortemp of this light, -1 means you can't change colortemp
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return self.m_max
|
|
|
|
return self.m_max
|
|
|
|
|
|
|
|
|
|
|
@ -131,11 +155,11 @@ class HueLight:
|
|
|
|
if 'mindimlevel' in keys:
|
|
|
|
if 'mindimlevel' in keys:
|
|
|
|
self.m_mindimlevel: int = data_slice['mindimlevel']
|
|
|
|
self.m_mindimlevel: int = data_slice['mindimlevel']
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.m_mindimlevel: int = 0
|
|
|
|
self.m_mindimlevel: int = -1
|
|
|
|
if 'maxlumen' in keys:
|
|
|
|
if 'maxlumen' in keys:
|
|
|
|
self.m_maxlumen: int = data_slice['maxlumen']
|
|
|
|
self.m_maxlumen: int = data_slice['maxlumen']
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.m_maxlumen: int = 0
|
|
|
|
self.m_maxlumen: int = -1
|
|
|
|
if 'ct' in data_slice.keys():
|
|
|
|
if 'ct' in data_slice.keys():
|
|
|
|
self.m_ct = HueLight.Capabilites.Control.ColorTemp(data_slice['ct'])
|
|
|
|
self.m_ct = HueLight.Capabilites.Control.ColorTemp(data_slice['ct'])
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -246,7 +270,23 @@ class HueLight:
|
|
|
|
Returns:
|
|
|
|
Returns:
|
|
|
|
bool: True if we can, otherwise False
|
|
|
|
bool: True if we can, otherwise False
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return self.get_ct() > 0
|
|
|
|
return self.get_ct() > -1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def can_set_hue(self) -> bool:
|
|
|
|
|
|
|
|
"""Check if we can set hue for this light
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
bool: True if we can, otherwise False
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self.get_hue() != -1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def can_set_sat(self) -> bool:
|
|
|
|
|
|
|
|
"""Check if we can set saturation for this light
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
bool: True if we can, otherwise False
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self.get_sat() != -1
|
|
|
|
|
|
|
|
|
|
|
|
def get_state(self):
|
|
|
|
def get_state(self):
|
|
|
|
"""Get the state object for this light
|
|
|
|
"""Get the state object for this light
|
|
|
@ -315,6 +355,26 @@ class HueLight:
|
|
|
|
state = '{{"ct":{0}}}'.format(colortemp)
|
|
|
|
state = '{{"ct":{0}}}'.format(colortemp)
|
|
|
|
self.set_state(state)
|
|
|
|
self.set_state(state)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_hue(self, hue: int):
|
|
|
|
|
|
|
|
"""Set the hue of the light, if possible
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
|
|
|
hue (int): 0-65535
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if self.can_set_hue():
|
|
|
|
|
|
|
|
state = '{{"hue":{0}}}'.format(hue)
|
|
|
|
|
|
|
|
self.set_state(state)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_sat(self, sat: int):
|
|
|
|
|
|
|
|
"""Set the saturation of the light, if possible
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
|
|
|
sat (int): 0-254
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
if self.can_set_sat():
|
|
|
|
|
|
|
|
state = '{{"sat":{0}}}'.format(sat)
|
|
|
|
|
|
|
|
self.set_state(state)
|
|
|
|
|
|
|
|
|
|
|
|
def toggle(self):
|
|
|
|
def toggle(self):
|
|
|
|
"""Toggle light
|
|
|
|
"""Toggle light
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -343,6 +403,22 @@ class HueLight:
|
|
|
|
"""Get current colortemp
|
|
|
|
"""Get current colortemp
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Returns:
|
|
|
|
int: 0,153-500
|
|
|
|
int: -1,153-500
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return self.get_state().get_ct()
|
|
|
|
return self.get_state().get_ct()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_hue(self) -> int:
|
|
|
|
|
|
|
|
"""Get current hue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
int: -1-65535
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self.get_state().get_hue()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_sat(self):
|
|
|
|
|
|
|
|
"""Get current saturation
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
|
|
|
int: -1-254
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
return self.get_state().get_sat()
|
|
|
|