Skip to content
Snippets Groups Projects
Commit 2e53d1c1 authored by jkerdreu's avatar jkerdreu
Browse files

Backport from trunk

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2400 b32b6428-25c9-4566-ad07-03861ab6144f
parent b47ee261
No related branches found
No related tags found
No related merge requests found
......@@ -27,7 +27,7 @@ setup(
install_requires=[
'xaal.lib',
'bottle',
'gevent',
'gevent==1.4.0',
'gevent-websocket',
'python-engineio',
'python-socketio',
......
......@@ -25,7 +25,7 @@ setup(
include_package_data=True,
install_requires=[
'xaal.lib',
'gevent',
'gevent==1.4.0',
'pycrypto',
]
)
......@@ -25,7 +25,7 @@ setup(
include_package_data=True,
install_requires=[
'xaal.lib',
'gevent',
'gevent==1.4.0',
'pyserial',
]
)
......@@ -25,6 +25,6 @@ setup(
include_package_data=True,
install_requires=[
'xaal.lib',
'gevent',
'gevent==1.4.0',
]
)
......@@ -25,6 +25,6 @@ setup(
include_package_data=True,
install_requires=[
'xaal.lib',
'gevent',
'gevent==1.4.0',
]
)
......@@ -19,7 +19,7 @@ setup(
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules',
],
keywords=['xaal', 'aqara'],
keywords=['xaal', 'tuya'],
platforms='any',
packages=find_packages(),
include_package_data=True,
......@@ -28,8 +28,10 @@ setup(
],
install_requires=[
'xaal.lib',
'gevent',
'pytuya',
'gevent==1.4.0',
'pytuya==7.0.5',
'pyaes',
'pycrypto',
'tenacity',
]
)
......@@ -25,7 +25,7 @@ setup(
include_package_data=True,
install_requires=[
'xaal.lib',
'gevent',
'gevent==1.4.0',
'yeelight',
'tenacity',
]
......
......@@ -23,17 +23,6 @@ def split_color(color):
return (r,g,b)
import wrapt
@wrapt.decorator
def async_call(wrapped,instance,args, kwargs):
print(f"{args} ,{kwargs}")
#gevent.spawn(wrapped,args,kwargs)
return wrapped(*args, **kwargs)
#return gevent.spawn(func,*args,**kwargs)
class YeelightDev(object):
def __init__(self,bulb,addr):
logger.info('New device at %s : %s' % (bulb._ip,addr))
......@@ -51,6 +40,9 @@ class YeelightDev(object):
def setup(self):
logger.warning('Please overide setup()')
def spawn(self,func,*args,**kwargs):
gevent.spawn(wrap_errors(Exception,func),*args,**kwargs)
class RGBW(YeelightDev):
def setup(self):
......@@ -61,55 +53,87 @@ class RGBW(YeelightDev):
dev.methods['dim'] = self.dim
dev.methods['setRGB'] = self.set_color
dev.methods['setWhite'] = self.set_white
dev.methods['debug'] = self.debug
dev.info = 'RGBW / %s' % self.addr
self.dev = dev
def spawn(self,func,*args,**kwargs):
gevent.spawn(wrap_errors(Exception,func),*args,**kwargs)
def debug(self):
import pdb;pdb.set_trace()
def on(self):
self.bulb.turn_on()
self.dev.attributes['light'] = True
self.bulb.duration = 200
self.spawn(self._on)
def off(self):
self.bulb.turn_off()
self.dev.attributes['light'] = False
self.bulb.duration = 5000
self.spawn(self._off)
def toggle(self):
self.spawn(self.toggle_)
@tenacity.retry(stop=TENACITY_RETRY)
def toggle_(self):
self.bulb.toggle()
self.spawn(self._toggle)
def dim(self,_target):
val = int(_target)
self.spawn(self.dim_,val)
@tenacity.retry(stop=TENACITY_RETRY)
def dim_(self,val):
self.on()
self.bulb.set_brightness(val)
self.spawn(self._dim,val)
def set_color(self,_target):
print(_target)
r,g,b = split_color(_target)
self.on()
self.bulb.set_rgb(r,g,b)
self.spawn(self._set_color,r,g,b)
self.dev.attributes['mode'] = 'RGB'
self.dev.attributes['rgb'] = _target
def set_white(self,_target):
val = int(_target)
self.on()
self.bulb.set_color_temp(val)
self.spawn(self._set_color_temp,val)
self.dev.attributes['mode'] = 'WHITE'
self.dev.attributes['white_temperature'] = _target
#===================================================
# Yeelight API
#===================================================
def _get_properties(self):
time.sleep(0.1)
properties = self.bulb.get_properties()
self.on_properties(properties)
def on_properties(self,properties):
print(properties)
@tenacity.retry(stop=TENACITY_RETRY)
def _on(self):
self.bulb.turn_on()
self._get_properties()
@tenacity.retry(stop=TENACITY_RETRY)
def _off(self):
self.bulb.turn_off()
self._get_properties()
@tenacity.retry(stop=TENACITY_RETRY)
def _toggle(self):
self.bulb.toggle()
self._get_properties()
@tenacity.retry(stop=TENACITY_RETRY)
def _dim(self,val):
self.bulb.turn_on()
self.bulb.set_brightness(val)
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()
@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()
......@@ -26,6 +26,6 @@ setup(
install_requires=[
'xaal.lib',
'bugone',
'gevent'
'gevent==1.4.0'
]
)
set -g default-terminal "screen-256color" # colors!
# cssh
bind-key = set-window-option synchronize-panes \; display 'Switching synchronize'
# interface
#------------
# pane
#------------
set -g pane-border-fg black
set -g pane-active-border-fg blue
set -g pane-border-status top
set -g pane-border-style fg=blue
set -g pane-active-border-style fg=colour39
#------------
......@@ -17,6 +19,7 @@ set -g pane-border-status top
setw -g window-status-format "#[fg=white]#[bg=blue]#I #[bg=blue]#[fg=white]#W "
setw -g window-status-current-format "#[bg=red]#[fg=white,bold][#I #[fg=white,bold]#[bg=red]#W]"
#------------
# status bar
#------------
......@@ -40,7 +43,13 @@ set -g mouse on
bind-key m set-option -g mouse on \; display 'Mouse: ON'
bind-key M set-option -g mouse off \; display 'Mouse: OFF'
#-----------------
# pane navigation
#-----------------
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
#-------------------
# window navigation
#-------------------
......@@ -50,10 +59,9 @@ bind -r C-p previous-window # select previous window
bind -r C-n next-window # select next window
bind Tab choose-window # move to last active window
bind -r C-s setw synchronize-panes \; display 'Switching synchronize'
bind -r k kill-pane
bind -r § source ~/.tmux.conf \; display 'Loaded config file'
bind -r r source ~/.tmux.conf \; display 'Loaded config file'
# enable activity alerts
......@@ -61,7 +69,7 @@ bind -r § source ~/.tmux.conf \; display 'Loaded config file'
# set -g visual-activity on
#set -g status-interval 300
set -g status-interval 20
setw -g xterm-keys on
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment