From 993477ff35c04e54324cb933997419f010879a68 Mon Sep 17 00:00:00 2001 From: Kai Wansart Date: Sat, 3 Feb 2018 23:06:42 +0100 Subject: [PATCH] yeelight fixes --- app/devices/yeelight.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/app/devices/yeelight.py b/app/devices/yeelight.py index c4c8267..dd0435b 100644 --- a/app/devices/yeelight.py +++ b/app/devices/yeelight.py @@ -159,6 +159,7 @@ class Yeelight(object): print(device + ": Konnte nicht angesteuert werden") error = True finally: + oldState = self.bulbs[device].get_properties() if(str(oldState['power']) != str(state)): if(state=="on"): self.bulbs[device].turn_on() @@ -173,6 +174,7 @@ class Yeelight(object): except: print(device + ": Konnte nicht angesteuert werden") finally: + oldState = self.bulbs[device].get_properties() if(str(oldState['power']) != str(state)): if(state=="on"): self.bulbs[device].turn_on() @@ -182,10 +184,11 @@ class Yeelight(object): print(device + " turned off") try: oldState = self.bulbs[device].get_properties() - if(oldState['power'] == str(state)): - break except: print(device + " keine Veraenderung") + finally: + if(oldState['power'] == str(state)): + break ##-----------------------------------------------------------------------------------## def brightness(self, device, group, state=None): @@ -215,6 +218,7 @@ class Yeelight(object): print(device + ": Konnte nicht angesteuert werden") error = True finally: + oldState = self.bulbs[device].get_properties() if(str(oldState['bright']) != str(state)): self.bulbs[device].set_brightness(int(state)) print(device + " turned brightness to " + str(state)) @@ -225,15 +229,17 @@ class Yeelight(object): except: print(device + ": Konnte nicht angesteuert werden") 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)) print(device + " turned brightness to " + str(state)) try: oldState = self.bulbs[device].get_properties() - if(oldState['bright'] == str(state)): - break except: print(device + " keine Veraenderung") + finally: + if(oldState['bright'] == str(state)): + break ##-----------------------------------------------------------------------------------## def temperature(self, device, group, state=None): @@ -262,6 +268,7 @@ class Yeelight(object): print(device + ": Konnte nicht angesteuert werden") error = True finally: + oldState = self.bulbs[device].get_properties() if(str(oldState['ct']) != str(state)): self.bulbs[device].set_color_temp(int(state)) print(device + " turned temperature to " + str(state)) @@ -272,15 +279,17 @@ class Yeelight(object): except: print(device + ": Konnte nicht angesteuert werden") finally: + oldState = self.bulbs[device].get_properties() if(str(oldState['ct']) != str(state)): self.bulbs[device].set_color_temp(int(state)) print(device + " turned temperature to " + str(state)) try: oldState = self.bulbs[device].get_properties() - if(oldState['ct'] == str(state)): - break except: print(device + " keine Veraenderung") + finally: + if(oldState['ct'] == str(state)): + break ##-----------------------------------------------------------------------------------## def color(self, device, group, r, g, b):