Skip to content
Snippets Groups Projects
Commit 697635d1 authored by jkerdreu's avatar jkerdreu
Browse files

Concurency issues: That's should be Ok now, next step xAAL schema :)

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2404 b32b6428-25c9-4566-ad07-03861ab6144f
parent a3c49f11
Branches
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ class YeelightDev(object):
self.addr = addr
self.dev = None
self.setup()
self.get_properties()
self.set_properties()
def set_properties(self):
......@@ -62,6 +63,9 @@ class RGBW(YeelightDev):
def debug(self):
import pdb;pdb.set_trace()
def get_properties(self):
self.spawn(self._get_properties)
def on(self):
self.bulb.duration = 200
self.spawn(self._on)
......@@ -93,47 +97,49 @@ class RGBW(YeelightDev):
#===================================================
# Yeelight API
#===================================================
def _get_properties(self):
time.sleep(0.1)
def __get_properties(self):
properties = self.bulb.get_properties()
self.on_properties(properties)
def on_properties(self,properties):
print(properties)
@tenacity.retry(stop=TENACITY_RETRY)
def _get_properties(self):
self.__get_properties()
@tenacity.retry(stop=TENACITY_RETRY)
def _on(self):
self.bulb.turn_on()
self._get_properties()
self.__get_properties()
@tenacity.retry(stop=TENACITY_RETRY)
def _off(self):
self.bulb.turn_off()
self._get_properties()
self.__get_properties()
@tenacity.retry(stop=TENACITY_RETRY)
def _toggle(self):
self.bulb.toggle()
self._get_properties()
self.__get_properties()
@tenacity.retry(stop=TENACITY_RETRY)
def _dim(self,val):
self.bulb.turn_on()
self.bulb.set_brightness(val)
self._get_properties()
self.__get_properties()
@tenacity.retry(stop=TENACITY_RETRY)
def _set_color_temp(self,val):
self.bulb.turn_on()
self.bulb.set_color_temp(val)
self._get_properties()
self.__get_properties()
@tenacity.retry(stop=TENACITY_RETRY)
def _set_color(self,r,g,b):
self.bulb.turn_on()
self.bulb.duration = 5000
self.bulb.set_rgb(r,g,b)
self._get_properties()
self.__get_properties()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment