Merge pull request #183 from MayeulC/refactor

Refactor the device list
This commit is contained in:
Daniel Høyer Iversen 2018-05-15 17:14:42 +02:00 committed by GitHub
commit db4d1a218b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,69 +13,50 @@ import sys
import threading import threading
import codecs import codecs
def gendevice(devtype, host, mac): def gendevice(devtype, host, mac):
if devtype == 0: # SP1 devices = {
return sp1(host=host, mac=mac, devtype=devtype) sp1: [0],
elif devtype == 0x2711: # SP2 sp2: [0x2711, # SP2
return sp2(host=host, mac=mac, devtype=devtype) 0x2719, 0x7919, 0x271a, 0x791a, # Honeywell SP2
elif devtype == 0x2719 or devtype == 0x7919 or devtype == 0x271a or devtype == 0x791a: # Honeywell SP2 0x2720, # SPMini
return sp2(host=host, mac=mac, devtype=devtype) 0x753e, # SP3
elif devtype == 0x2720: # SPMini 0x7D00, # OEM branded SP3
return sp2(host=host, mac=mac, devtype=devtype) 0x947a, 0x9479, # SP3S
elif devtype == 0x753e: # SP3 0x2728, # SPMini2
return sp2(host=host, mac=mac, devtype=devtype) 0x2733, 0x273e, # OEM branded SPMini
elif devtype == 0x7D00: # OEM branded SP3 0x7530, 0x7918, # OEM branded SPMini2
return sp2(host=host, mac=mac, devtype=devtype) 0x2736 # SPMiniPlus
elif devtype == 0x947a or devtype == 0x9479: # SP3S ],
return sp2(host=host, mac=mac, devtype=devtype) rm: [0x2712, # RM2
elif devtype == 0x2728: # SPMini2 0x2737, # RM Mini
return sp2(host=host, mac=mac, devtype=devtype) 0x273d, # RM Pro Phicomm
elif devtype == 0x2733 or devtype == 0x273e: # OEM branded SPMini 0x2783, # RM2 Home Plus
return sp2(host=host, mac=mac, devtype=devtype) 0x277c, # RM2 Home Plus GDT
elif devtype >= 0x7530 and devtype <= 0x7918: # OEM branded SPMini2 0x272a, # RM2 Pro Plus
return sp2(host=host, mac=mac, devtype=devtype) 0x2787, # RM2 Pro Plus2
elif devtype == 0x2736: # SPMiniPlus 0x279d, # RM2 Pro Plus3
return sp2(host=host, mac=mac, devtype=devtype) 0x27a9, # RM2 Pro Plus_300
elif devtype == 0x2712: # RM2 0x278b, # RM2 Pro Plus BL
return rm(host=host, mac=mac, devtype=devtype) 0x2797, # RM2 Pro Plus HYC
elif devtype == 0x2737: # RM Mini 0x27a1, # RM2 Pro Plus R1
return rm(host=host, mac=mac, devtype=devtype) 0x27a6, # RM2 Pro PP
elif devtype == 0x273d: # RM Pro Phicomm 0x278f # RM Mini Shate
return rm(host=host, mac=mac, devtype=devtype) ],
elif devtype == 0x2783: # RM2 Home Plus a1: [0x2714], # A1
return rm(host=host, mac=mac, devtype=devtype) mp1: [0x4EB5, # MP1
elif devtype == 0x277c: # RM2 Home Plus GDT 0x4EF7 # Honyar oem mp1
return rm(host=host, mac=mac, devtype=devtype) ],
elif devtype == 0x272a: # RM2 Pro Plus hysen: [0x4EAD], # Hysen controller
return rm(host=host, mac=mac, devtype=devtype) S1C: [0x2722], # S1 (SmartOne Alarm Kit)
elif devtype == 0x2787: # RM2 Pro Plus2 dooya: [0x4E4D] # Dooya DT360E (DOOYA_CURTAIN_V2)
return rm(host=host, mac=mac, devtype=devtype) }
elif devtype == 0x279d: # RM2 Pro Plus3
return rm(host=host, mac=mac, devtype=devtype) # Look for the class associated to devtype in devices
elif devtype == 0x27a9: # RM2 Pro Plus_300 [deviceClass] = [dev for dev in devices if devtype in devices[dev]] or [None]
return rm(host=host, mac=mac, devtype=devtype) if deviceClass is None:
elif devtype == 0x278b: # RM2 Pro Plus BL
return rm(host=host, mac=mac, devtype=devtype)
elif devtype == 0x2797: # RM2 Pro Plus HYC
return rm(host=host, mac=mac, devtype=devtype)
elif devtype == 0x27a1: # RM2 Pro Plus R1
return rm(host=host, mac=mac, devtype=devtype)
elif devtype == 0x27a6: # RM2 Pro PP
return rm(host=host, mac=mac, devtype=devtype)
elif devtype == 0x278f: # RM Mini Shate
return rm(host=host, mac=mac, devtype=devtype)
elif devtype == 0x2714: # A1
return a1(host=host, mac=mac, devtype=devtype)
elif devtype == 0x4EB5 or devtype == 0x4EF7: # MP1: 0x4eb5, honyar oem mp1: 0x4ef7
return mp1(host=host, mac=mac, devtype=devtype)
elif devtype == 0x4EAD: # Hysen controller
return hysen(host=host, mac=mac, devtype=devtype)
elif devtype == 0x2722: # S1 (SmartOne Alarm Kit)
return S1C(host=host, mac=mac, devtype=devtype)
elif devtype == 0x4E4D: # Dooya DT360E (DOOYA_CURTAIN_V2)
return dooya(host=host, mac=mac, devtype=devtype)
else:
return device(host=host, mac=mac, devtype=devtype) return device(host=host, mac=mac, devtype=devtype)
return deviceClass(host=host, mac=mac, devtype=devtype)
def discover(timeout=None, local_ip_address=None): def discover(timeout=None, local_ip_address=None):
if local_ip_address is None: if local_ip_address is None: