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

Added leak sensor


git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@2250 b32b6428-25c9-4566-ad07-03861ab6144f
parent 9700e350
Branches
No related tags found
No related merge requests found
......@@ -58,7 +58,8 @@ class AqaraDev(object):
logger.info('Unhandled report %s' % data)
def on_heartbeat(self,data):
logger.info('Unhandled heartbeat %s' % data)
#logger.info('Unhandled heartbeat %s' % data)
self.on_report(data)
class Switch(AqaraDev):
......@@ -148,6 +149,7 @@ class WaterLeak(AqaraDev):
if status and status == 'no_leak':
logger.warning('No leaking')
UDP_MAX_SIZE=65507
class Gateway(AqaraDev):
def setup(self):
......@@ -191,22 +193,24 @@ class Gateway(AqaraDev):
return binascii.hexlify(cipher.encrypt(self.token)).decode("utf-8")
def connect(self):
""" prepare the unicast socket"""
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.sock.settimeout(0.5)
def send(self,pkt):
"""send a the unicast datagram to the lumi GW"""
if not self.ip:
logger.warning("GW IP not found yet, please wait")
return
try:
#print(pkt)
self.sock.sendto(pkt,(self.ip,GW_PORT))
ans = self.sock.recv(65507)
ans = self.sock.recv(UDP_MAX_SIZE)
return ans
except Exception as e:
logger.warning(e)
def send_cmd(self,cmd,sid,data={}):
""" craft the datagram pkt and send to the lumi gw"""
if not self.token :
logger.warning("No token yet, please wait")
return
......@@ -354,7 +358,6 @@ class Gateway(AqaraDev):
self.ready = True
self.discover()
def on_report(self,data):
rgb = data.get('rgb',None)
if rgb:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment