Skip to content
Snippets Groups Projects
Commit 4ffa49eb authored by jkerdreu's avatar jkerdreu
Browse files

Backport wifi KNX tricks

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7@2387 b32b6428-25c9-4566-ad07-03861ab6144f
parent 47247a1e
Branches
Tags
No related merge requests found
......@@ -33,7 +33,7 @@ class GW(gevent.Greenlet):
atexit.register(self._exit)
self.config()
self.setup()
self.init()
self.refresh()
def config(self):
cfg = tools.load_cfg(PACKAGE_NAME)
......@@ -45,8 +45,8 @@ class GW(gevent.Greenlet):
self.cfg = cfg
def setup(self):
if 'phy_addr' in self.cfg['config']:
addr = self.cfg['config']['phy_addr']
addr = self.cfg['config'].get('phy_addr',None)
if addr:
self.knx = KNXConnector(addr)
else:
self.knx = KNXConnector()
......@@ -67,6 +67,11 @@ class GW(gevent.Greenlet):
l = [k.dev for k in self.devices]
self.engine.add_devices(l)
# schedule a refresh of KNX network. usefull for wifi network
refresh_rate = self.cfg['config'].get('refresh_rate',None)
if refresh_rate:
self.engine.add_timer(self.refresh,int(refresh_rate))
def _run(self):
while 1:
......@@ -84,8 +89,8 @@ class GW(gevent.Greenlet):
if cemi.group_addr in dev.attributes_binding :
dev.parse(cemi)
def init(self):
"""loop throught the device adress to find initial values"""
def refresh(self):
"""loop throught the device adress to find values"""
for dev in self.devices:
for ga in dev.attributes_binding:
self.knx.read(ga)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment