Skip to content

Commit

Permalink
Merge pull request #60 from t0mer/new-devices
Browse files Browse the repository at this point in the history
Adding new devices
  • Loading branch information
t0mer authored Jun 6, 2022
2 parents bcda0b1 + b378c1f commit ea4ce70
Show file tree
Hide file tree
Showing 5 changed files with 205 additions and 95 deletions.
2 changes: 1 addition & 1 deletion broadlinkmanager/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.8.3
5.8.4
202 changes: 109 additions & 93 deletions broadlinkmanager/broadlink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .alarm import S1C
from .climate import hysen
from .cover import dooya
from .hub import s3
from .device import Device, ping, scan
from .light import lb1, lb2
from .remote import rm, rm4, rm4mini, rm4pro, rmmini, rmminib, rmpro
Expand All @@ -19,140 +20,155 @@

SUPPORTED_TYPES = {
sp1: {
0x0000: ("SP1", broadlink),
0x0000: ("SP1", "Broadlink"),
},
sp2: {
0x2717: ("NEO", "Ankuoo"),
0x2719: ("SP2-compatible", "Honeywell"),
0x271A: ("SP2-compatible", "Honeywell"),
0x2720: ("SP mini", broadlink),
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),
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),
0x7D0D: ("SP mini 3", "Broadlink (OEM)"),
},
sp2s: {
0x2711: ("SP2", broadlink),
0x2711: ("SP2", "Broadlink"),
0x2716: ("NEO PRO", "Ankuoo"),
0x271D: ("Ego", "Efergy"),
0x2736: ("SP mini+", broadlink),
0x2736: ("SP mini+", "Broadlink"),
},
sp3: {
0x2733: ("SP3", broadlink),
0x7D00: ("SP3-EU", broadlink_oem),
0x2733: ("SP3", "Broadlink"),
0x7D00: ("SP3-EU", "Broadlink (OEM)"),
},
sp3s: {
0x9479: ("SP3S-US", broadlink),
0x947A: ("SP3S-EU", broadlink),
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),
0xA56B: ("SCB1E", broadlink),
0xA56C: ("SP4L-EU", broadlink),
0xA589: ("SP4L-UK", broadlink),
0xA5D3: ("SP4L-EU", broadlink),
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"),
0xA569: ("SP4L-UK", "Broadlink"),
0xA56A: ("MCB1", "Broadlink"),
0xA56B: ("SCB1E", "Broadlink"),
0xA56C: ("SP4L-EU", "Broadlink"),
0xA589: ("SP4L-UK", "Broadlink"),
0xA5D3: ("SP4L-EU", "Broadlink"),
},
sp4b: {
0x5115: ("SCB1E", broadlink),
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),
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),
0x27DC: ("RM mini 3", broadlink),
0x27DE: ("RM mini 3", broadlink),
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"),
0x27DC: ("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),
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),
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),
0x51DA: ("RM4 mini", "Broadlink"),
0x5209: ("RM4 TV mate", "Broadlink"),
0x520C: ("RM4 mini", "Broadlink"),
0x5212: ("RM4 TV mate", "Broadlink"),
0x5216: ("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),
0x520B: ("RM4 pro", "Broadlink"),
0x5213: ("RM4 pro", "Broadlink"),
0x5218: ("RM4C pro", "Broadlink"),
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),
0x2714: ("e-Sensor", "Broadlink"),
},
mp1: {
0x4EB5: ("MP1-1K4S", broadlink),
0x4EF7: ("MP1-1K4S", broadlink_oem),
0x4F1B: ("MP1-1K3S2U", broadlink_oem),
0x4F65: ("MP1-1K3S2U", broadlink),
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),
0x606E: ("SB500TD",broadlink_oem),
0x60C7: ("LB1", broadlink),
0x60C8: ("LB1", broadlink),
0x6112: ("LB1", broadlink),
0x5043: ("SB800TD", "Broadlink (OEM)"),
0x504E: ("LB1", "Broadlink"),
0x606E: ("SB500TD", "Broadlink (OEM)"),
0x60C7: ("LB1", "Broadlink"),
0x60C8: ("LB1", "Broadlink"),
0x6112: ("LB1", "Broadlink"),
0x644C: ("LB27 R1", "Broadlink"),
0x644E: ("LB26 R1", "Broadlink"),
},
lb2: {
0xA4F4: ("LB27 R1", broadlink),
0xA4F4: ("LB27 R1", "Broadlink"),
0xA5F7: ("LB27 R1", "Broadlink"),
},
S1C: {
0x2722: ("S2KIT", broadlink),
0x2722: ("S2KIT", "Broadlink"),
},
s3: {
0xA59C:("S3", "Broadlink"),
0xA64D:("S3", "Broadlink"),
},
hysen: {
0x4EAD: ("HY02/HY03", "Hysen"),
Expand Down
83 changes: 83 additions & 0 deletions broadlinkmanager/broadlink/hub.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"""Support for hubs."""
import struct
import json

from . import exceptions as e
from .device import Device


class s3(Device):
"""Controls a Broadlink S3."""

TYPE = "S3"
MAX_SUBDEVICES = 8

def get_subdevices(self) -> list:
"""Return the lit of sub devices."""
sub_devices = []
step = 5

for index in range(0, self.MAX_SUBDEVICES, step):
state = {"count": step, "index": index}
packet = self._encode(14, state)
resp = self.send_packet(0x6A, packet)
e.check_error(resp[0x22:0x24])
resp = self._decode(resp)

sub_devices.extend(resp["list"])
if len(sub_devices) == resp["total"]:
break

return sub_devices

def get_state(self, did: str = None) -> dict:
"""Return the power state of the device."""
state = {}
if did is not None:
state["did"] = did

packet = self._encode(1, state)
response = self.send_packet(0x6A, packet)
e.check_error(response[0x22:0x24])
return self._decode(response)

def set_state(
self,
did: str = None,
pwr1: bool = None,
pwr2: bool = None,
pwr3: bool = None,
) -> dict:
"""Set the power state of the device."""
state = {}
if did is not None:
state["did"] = did
if pwr1 is not None:
state["pwr1"] = int(bool(pwr1))
if pwr2 is not None:
state["pwr2"] = int(bool(pwr2))
if pwr3 is not None:
state["pwr3"] = int(bool(pwr3))

packet = self._encode(2, state)
response = self.send_packet(0x6A, packet)
e.check_error(response[0x22:0x24])
return self._decode(response)

def _encode(self, flag: int, state: dict) -> bytes:
"""Encode a JSON packet."""
# flag: 1 for reading, 2 for writing.
packet = bytearray(12)
data = json.dumps(state, separators=(",", ":")).encode()
struct.pack_into("<HHHBBI", packet, 0, 0xA5A5, 0x5A5A, 0, flag, 0x0B, len(data))
packet.extend(data)
checksum = sum(packet, 0xBEAF) & 0xFFFF
packet[0x04:0x06] = checksum.to_bytes(2, "little")
return packet

def _decode(self, response: bytes) -> dict:
"""Decode a JSON packet."""
payload = self.decrypt(response[0x38:])
js_len = struct.unpack_from("<I", payload, 0x08)[0]
state = json.loads(payload[0x0C : 0x0C + js_len])
return state
11 changes: 11 additions & 0 deletions broadlinkmanager/broadlinkmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,17 @@ def getDeviceName(deviceType):
0x4EAD: "HY02/HY03 ( Hysen)",
0x4E4D: "DT360E-45/20 ( Dooya)",
0x51E3: "BG800/BG900 ( BGElectrical)",
0xA569: "SP4L-UK ( Broadlink)",
0x520C: "RM4 mini ( Broadlink)",
0x5212: "RM4 TV (mate Broadlink)",
0x5216: "RM4 mini (Broadlink)",
0x520B: "RM4 pro (Broadlink)",
0x5218: "RM4C pro (Broadlink)",
0x5209: "RM4 TV mate (Broadlink)",
0x5213: "RM4 pro (Broadlink)",
0x644C: "LB27 R1 (Broadlink)",
0x644E: "LB26 R1 (Broadlink)",
0xA5F7: "LB27 R1 (Broadlink)",

}
return name.get(deviceType, "Not Supported")
Expand Down
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Broadlink Manager"
description: "Easely learn and send IR/RF Command"
codenotary: [email protected]
version: "5.8.3"
version: "5.8.4"
slug: "broadlink_manager"
panel_icon: mdi:remote
# panel_admin: false
Expand Down

0 comments on commit ea4ce70

Please sign in to comment.