1
0
mirror of https://github.com/mjg59/python-broadlink.git synced 2024-11-13 03:00:11 +01:00

Refactor SUPPORTED_TYPES (#592)

This commit is contained in:
Felipe Martins Diel 2021-05-06 14:52:11 -03:00 committed by GitHub
parent 1ae12e7d1c
commit bc44166702
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,107 +15,147 @@ from .sensor import a1
from .switch import bg1, mp1, sp1, sp2, sp2s, sp3, sp3s, sp4, sp4b
SUPPORTED_TYPES = {
0x0000: (sp1, "SP1", "Broadlink"),
0x2717: (sp2, "NEO", "Ankuoo"),
0x2719: (sp2, "SP2-compatible", "Honeywell"),
0x271A: (sp2, "SP2-compatible", "Honeywell"),
0x2720: (sp2, "SP mini", "Broadlink"),
0x2728: (sp2, "SP2-compatible", "URANT"),
0x273E: (sp2, "SP mini", "Broadlink"),
0x7530: (sp2, "SP2", "Broadlink (OEM)"),
0x7539: (sp2, "SP2-IL", "Broadlink (OEM)"),
0x753E: (sp2, "SP mini 3", "Broadlink"),
0x7540: (sp2, "MP2", "Broadlink"),
0x7544: (sp2, "SP2-CL", "Broadlink"),
0x7546: (sp2, "SP2-UK/BR/IN", "Broadlink (OEM)"),
0x7547: (sp2, "SC1", "Broadlink"),
0x7918: (sp2, "SP2", "Broadlink (OEM)"),
0x7919: (sp2, "SP2-compatible", "Honeywell"),
0x791A: (sp2, "SP2-compatible", "Honeywell"),
0x7D0D: (sp2, "SP mini 3", "Broadlink (OEM)"),
0x2711: (sp2s, "SP2", "Broadlink"),
0x2716: (sp2s, "NEO PRO", "Ankuoo"),
0x271D: (sp2s, "Ego", "Efergy"),
0x2736: (sp2s, "SP mini+", "Broadlink"),
0x2733: (sp3, "SP3", "Broadlink"),
0x7D00: (sp3, "SP3-EU", "Broadlink (OEM)"),
0x9479: (sp3s, "SP3S-US", "Broadlink"),
0x947A: (sp3s, "SP3S-EU", "Broadlink"),
0x7568: (sp4, "SP4L-CN", "Broadlink"),
0x756C: (sp4, "SP4M", "Broadlink"),
0x756F: (sp4, "MCB1", "Broadlink"),
0x7579: (sp4, "SP4L-EU", "Broadlink"),
0x757B: (sp4, "SP4L-AU", "Broadlink"),
0x7583: (sp4, "SP mini 3", "Broadlink"),
0x7587: (sp4, "SP4L-UK", "Broadlink"),
0x7D11: (sp4, "SP mini 3", "Broadlink"),
0xA56A: (sp4, "MCB1", "Broadlink"),
0xA589: (sp4, "SP4L-UK", "Broadlink"),
0xA5D3: (sp4, "SP4L-EU", "Broadlink"),
0x5115: (sp4b, "SCB1E", "Broadlink"),
0x51E2: (sp4b, "AHC/U-01", "BG Electrical"),
0x6111: (sp4b, "MCB1", "Broadlink"),
0x6113: (sp4b, "SCB1E", "Broadlink"),
0x618B: (sp4b, "SP4L-EU", "Broadlink"),
0x6489: (sp4b, "SP4L-AU", "Broadlink"),
0x648B: (sp4b, "SP4M-US", "Broadlink"),
0x6494: (sp4b, "SCB2", "Broadlink"),
0x2737: (rmmini, "RM mini 3", "Broadlink"),
0x278F: (rmmini, "RM mini", "Broadlink"),
0x27C2: (rmmini, "RM mini 3", "Broadlink"),
0x27C7: (rmmini, "RM mini 3", "Broadlink"),
0x27CC: (rmmini, "RM mini 3", "Broadlink"),
0x27CD: (rmmini, "RM mini 3", "Broadlink"),
0x27D0: (rmmini, "RM mini 3", "Broadlink"),
0x27D1: (rmmini, "RM mini 3", "Broadlink"),
0x27D3: (rmmini, "RM mini 3", "Broadlink"),
0x27DE: (rmmini, "RM mini 3", "Broadlink"),
0x2712: (rmpro, "RM pro/pro+", "Broadlink"),
0x272A: (rmpro, "RM pro", "Broadlink"),
0x273D: (rmpro, "RM pro", "Broadlink"),
0x277C: (rmpro, "RM home", "Broadlink"),
0x2783: (rmpro, "RM home", "Broadlink"),
0x2787: (rmpro, "RM pro", "Broadlink"),
0x278B: (rmpro, "RM plus", "Broadlink"),
0x2797: (rmpro, "RM pro+", "Broadlink"),
0x279D: (rmpro, "RM pro+", "Broadlink"),
0x27A1: (rmpro, "RM plus", "Broadlink"),
0x27A6: (rmpro, "RM plus", "Broadlink"),
0x27A9: (rmpro, "RM pro+", "Broadlink"),
0x27C3: (rmpro, "RM pro+", "Broadlink"),
0x5F36: (rmminib, "RM mini 3", "Broadlink"),
0x6507: (rmminib, "RM mini 3", "Broadlink"),
0x6508: (rmminib, "RM mini 3", "Broadlink"),
0x51DA: (rm4mini, "RM4 mini", "Broadlink"),
0x6070: (rm4mini, "RM4C mini", "Broadlink"),
0x610E: (rm4mini, "RM4 mini", "Broadlink"),
0x610F: (rm4mini, "RM4C mini", "Broadlink"),
0x62BC: (rm4mini, "RM4 mini", "Broadlink"),
0x62BE: (rm4mini, "RM4C mini", "Broadlink"),
0x6364: (rm4mini, "RM4S", "Broadlink"),
0x648D: (rm4mini, "RM4 mini", "Broadlink"),
0x6539: (rm4mini, "RM4C mini", "Broadlink"),
0x653A: (rm4mini, "RM4 mini", "Broadlink"),
0x6026: (rm4pro, "RM4 pro", "Broadlink"),
0x6184: (rm4pro, "RM4C pro", "Broadlink"),
0x61A2: (rm4pro, "RM4 pro", "Broadlink"),
0x649B: (rm4pro, "RM4 pro", "Broadlink"),
0x653C: (rm4pro, "RM4 pro", "Broadlink"),
0x2714: (a1, "e-Sensor", "Broadlink"),
0x4EB5: (mp1, "MP1-1K4S", "Broadlink"),
0x4EF7: (mp1, "MP1-1K4S", "Broadlink (OEM)"),
0x4F1B: (mp1, "MP1-1K3S2U", "Broadlink (OEM)"),
0x4F65: (mp1, "MP1-1K3S2U", "Broadlink"),
0x5043: (lb1, "SB800TD", "Broadlink (OEM)"),
0x504E: (lb1, "LB1", "Broadlink"),
0x60C7: (lb1, "LB1", "Broadlink"),
0x60C8: (lb1, "LB1", "Broadlink"),
0x6112: (lb1, "LB1", "Broadlink"),
0xA4F4: (lb2, "LB27 R1", "Broadlink"),
0x2722: (S1C, "S2KIT", "Broadlink"),
0x4EAD: (hysen, "HY02B05H", "Hysen"),
0x4E4D: (dooya, "DT360E-45/20", "Dooya"),
0x51E3: (bg1, "BG800/BG900", "BG Electrical"),
sp1: {
0x0000: ("SP1", "Broadlink"),
},
sp2: {
0x2717: ("NEO", "Ankuoo"),
0x2719: ("SP2-compatible", "Honeywell"),
0x271A: ("SP2-compatible", "Honeywell"),
0x2720: ("SP mini", "Broadlink"),
0x2728: ("SP2-compatible", "URANT"),
0x273E: ("SP mini", "Broadlink"),
0x7530: ("SP2", "Broadlink (OEM)"),
0x7539: ("SP2-IL", "Broadlink (OEM)"),
0x753E: ("SP mini 3", "Broadlink"),
0x7540: ("MP2", "Broadlink"),
0x7544: ("SP2-CL", "Broadlink"),
0x7546: ("SP2-UK/BR/IN", "Broadlink (OEM)"),
0x7547: ("SC1", "Broadlink"),
0x7918: ("SP2", "Broadlink (OEM)"),
0x7919: ("SP2-compatible", "Honeywell"),
0x791A: ("SP2-compatible", "Honeywell"),
0x7D0D: ("SP mini 3", "Broadlink (OEM)"),
},
sp2s: {
0x2711: ("SP2", "Broadlink"),
0x2716: ("NEO PRO", "Ankuoo"),
0x271D: ("Ego", "Efergy"),
0x2736: ("SP mini+", "Broadlink"),
},
sp3: {
0x2733: ("SP3", "Broadlink"),
0x7D00: ("SP3-EU", "Broadlink (OEM)"),
},
sp3s: {
0x9479: ("SP3S-US", "Broadlink"),
0x947A: ("SP3S-EU", "Broadlink"),
},
sp4: {
0x7568: ("SP4L-CN", "Broadlink"),
0x756C: ("SP4M", "Broadlink"),
0x756F: ("MCB1", "Broadlink"),
0x7579: ("SP4L-EU", "Broadlink"),
0x757B: ("SP4L-AU", "Broadlink"),
0x7583: ("SP mini 3", "Broadlink"),
0x7587: ("SP4L-UK", "Broadlink"),
0x7D11: ("SP mini 3", "Broadlink"),
0xA56A: ("MCB1", "Broadlink"),
0xA589: ("SP4L-UK", "Broadlink"),
0xA5D3: ("SP4L-EU", "Broadlink"),
},
sp4b: {
0x5115: ("SCB1E", "Broadlink"),
0x51E2: ("AHC/U-01", "BG Electrical"),
0x6111: ("MCB1", "Broadlink"),
0x6113: ("SCB1E", "Broadlink"),
0x618B: ("SP4L-EU", "Broadlink"),
0x6489: ("SP4L-AU", "Broadlink"),
0x648B: ("SP4M-US", "Broadlink"),
0x6494: ("SCB2", "Broadlink"),
},
rmmini: {
0x2737: ("RM mini 3", "Broadlink"),
0x278F: ("RM mini", "Broadlink"),
0x27C2: ("RM mini 3", "Broadlink"),
0x27C7: ("RM mini 3", "Broadlink"),
0x27CC: ("RM mini 3", "Broadlink"),
0x27CD: ("RM mini 3", "Broadlink"),
0x27D0: ("RM mini 3", "Broadlink"),
0x27D1: ("RM mini 3", "Broadlink"),
0x27D3: ("RM mini 3", "Broadlink"),
0x27DE: ("RM mini 3", "Broadlink"),
},
rmpro: {
0x2712: ("RM pro/pro+", "Broadlink"),
0x272A: ("RM pro", "Broadlink"),
0x273D: ("RM pro", "Broadlink"),
0x277C: ("RM home", "Broadlink"),
0x2783: ("RM home", "Broadlink"),
0x2787: ("RM pro", "Broadlink"),
0x278B: ("RM plus", "Broadlink"),
0x2797: ("RM pro+", "Broadlink"),
0x279D: ("RM pro+", "Broadlink"),
0x27A1: ("RM plus", "Broadlink"),
0x27A6: ("RM plus", "Broadlink"),
0x27A9: ("RM pro+", "Broadlink"),
0x27C3: ("RM pro+", "Broadlink"),
},
rmminib: {
0x5F36: ("RM mini 3", "Broadlink"),
0x6507: ("RM mini 3", "Broadlink"),
0x6508: ("RM mini 3", "Broadlink"),
},
rm4mini: {
0x51DA: ("RM4 mini", "Broadlink"),
0x6070: ("RM4C mini", "Broadlink"),
0x610E: ("RM4 mini", "Broadlink"),
0x610F: ("RM4C mini", "Broadlink"),
0x62BC: ("RM4 mini", "Broadlink"),
0x62BE: ("RM4C mini", "Broadlink"),
0x6364: ("RM4S", "Broadlink"),
0x648D: ("RM4 mini", "Broadlink"),
0x6539: ("RM4C mini", "Broadlink"),
0x653A: ("RM4 mini", "Broadlink"),
},
rm4pro: {
0x6026: ("RM4 pro", "Broadlink"),
0x6184: ("RM4C pro", "Broadlink"),
0x61A2: ("RM4 pro", "Broadlink"),
0x649B: ("RM4 pro", "Broadlink"),
0x653C: ("RM4 pro", "Broadlink"),
},
a1: {
0x2714: ("e-Sensor", "Broadlink"),
},
mp1: {
0x4EB5: ("MP1-1K4S", "Broadlink"),
0x4EF7: ("MP1-1K4S", "Broadlink (OEM)"),
0x4F1B: ("MP1-1K3S2U", "Broadlink (OEM)"),
0x4F65: ("MP1-1K3S2U", "Broadlink"),
},
lb1: {
0x5043: ("SB800TD", "Broadlink (OEM)"),
0x504E: ("LB1", "Broadlink"),
0x60C7: ("LB1", "Broadlink"),
0x60C8: ("LB1", "Broadlink"),
0x6112: ("LB1", "Broadlink"),
},
lb2: {
0xA4F4: ("LB27 R1", "Broadlink"),
},
S1C: {
0x2722: ("S2KIT", "Broadlink"),
},
hysen: {
0x4EAD: ("HY02B05H", "Hysen"),
},
dooya: {
0x4E4D: ("DT360E-45/20", "Dooya"),
},
bg1: {
0x51E3: ("BG800/BG900", "BG Electrical"),
},
}
@ -127,21 +167,24 @@ def gendevice(
is_locked: bool = False,
) -> Device:
"""Generate a device."""
try:
dev_class, model, manufacturer = SUPPORTED_TYPES[dev_type]
for dev_cls, products in SUPPORTED_TYPES.items():
try:
model, manufacturer = products[dev_type]
except KeyError:
return Device(host, mac, dev_type, name=name, is_locked=is_locked)
except KeyError:
continue
return dev_class(
host,
mac,
dev_type,
name=name,
model=model,
manufacturer=manufacturer,
is_locked=is_locked,
)
return dev_cls(
host,
mac,
dev_type,
name=name,
model=model,
manufacturer=manufacturer,
is_locked=is_locked,
)
return Device(host, mac, dev_type, name=name, is_locked=is_locked)
def hello(