yeelight fixes

This commit is contained in:
Kai Wansart 2018-02-03 23:06:42 +01:00
parent 179861a133
commit 993477ff35

View File

@ -159,6 +159,7 @@ class Yeelight(object):
print(device + ": Konnte nicht angesteuert werden") print(device + ": Konnte nicht angesteuert werden")
error = True error = True
finally: finally:
oldState = self.bulbs[device].get_properties()
if(str(oldState['power']) != str(state)): if(str(oldState['power']) != str(state)):
if(state=="on"): if(state=="on"):
self.bulbs[device].turn_on() self.bulbs[device].turn_on()
@ -173,6 +174,7 @@ class Yeelight(object):
except: except:
print(device + ": Konnte nicht angesteuert werden") print(device + ": Konnte nicht angesteuert werden")
finally: finally:
oldState = self.bulbs[device].get_properties()
if(str(oldState['power']) != str(state)): if(str(oldState['power']) != str(state)):
if(state=="on"): if(state=="on"):
self.bulbs[device].turn_on() self.bulbs[device].turn_on()
@ -182,10 +184,11 @@ class Yeelight(object):
print(device + " turned off") print(device + " turned off")
try: try:
oldState = self.bulbs[device].get_properties() oldState = self.bulbs[device].get_properties()
if(oldState['power'] == str(state)):
break
except: except:
print(device + " keine Veraenderung") print(device + " keine Veraenderung")
finally:
if(oldState['power'] == str(state)):
break
##-----------------------------------------------------------------------------------## ##-----------------------------------------------------------------------------------##
def brightness(self, device, group, state=None): def brightness(self, device, group, state=None):
@ -215,6 +218,7 @@ class Yeelight(object):
print(device + ": Konnte nicht angesteuert werden") print(device + ": Konnte nicht angesteuert werden")
error = True error = True
finally: finally:
oldState = self.bulbs[device].get_properties()
if(str(oldState['bright']) != str(state)): if(str(oldState['bright']) != str(state)):
self.bulbs[device].set_brightness(int(state)) self.bulbs[device].set_brightness(int(state))
print(device + " turned brightness to " + str(state)) print(device + " turned brightness to " + str(state))
@ -225,15 +229,17 @@ class Yeelight(object):
except: except:
print(device + ": Konnte nicht angesteuert werden") print(device + ": Konnte nicht angesteuert werden")
finally: finally:
if(str(oldState['brigh']) != str(state)): oldState = self.bulbs[device].get_properties()
if(str(oldState['bright']) != str(state)):
self.bulbs[device].set_brightness(int(state)) self.bulbs[device].set_brightness(int(state))
print(device + " turned brightness to " + str(state)) print(device + " turned brightness to " + str(state))
try: try:
oldState = self.bulbs[device].get_properties() oldState = self.bulbs[device].get_properties()
if(oldState['bright'] == str(state)):
break
except: except:
print(device + " keine Veraenderung") print(device + " keine Veraenderung")
finally:
if(oldState['bright'] == str(state)):
break
##-----------------------------------------------------------------------------------## ##-----------------------------------------------------------------------------------##
def temperature(self, device, group, state=None): def temperature(self, device, group, state=None):
@ -262,6 +268,7 @@ class Yeelight(object):
print(device + ": Konnte nicht angesteuert werden") print(device + ": Konnte nicht angesteuert werden")
error = True error = True
finally: finally:
oldState = self.bulbs[device].get_properties()
if(str(oldState['ct']) != str(state)): if(str(oldState['ct']) != str(state)):
self.bulbs[device].set_color_temp(int(state)) self.bulbs[device].set_color_temp(int(state))
print(device + " turned temperature to " + str(state)) print(device + " turned temperature to " + str(state))
@ -272,15 +279,17 @@ class Yeelight(object):
except: except:
print(device + ": Konnte nicht angesteuert werden") print(device + ": Konnte nicht angesteuert werden")
finally: finally:
oldState = self.bulbs[device].get_properties()
if(str(oldState['ct']) != str(state)): if(str(oldState['ct']) != str(state)):
self.bulbs[device].set_color_temp(int(state)) self.bulbs[device].set_color_temp(int(state))
print(device + " turned temperature to " + str(state)) print(device + " turned temperature to " + str(state))
try: try:
oldState = self.bulbs[device].get_properties() oldState = self.bulbs[device].get_properties()
if(oldState['ct'] == str(state)):
break
except: except:
print(device + " keine Veraenderung") print(device + " keine Veraenderung")
finally:
if(oldState['ct'] == str(state)):
break
##-----------------------------------------------------------------------------------## ##-----------------------------------------------------------------------------------##
def color(self, device, group, r, g, b): def color(self, device, group, r, g, b):