From fbc2ff34a060f0f4c66c8793c83c53b6cd5512de Mon Sep 17 00:00:00 2001 From: aymeric <38462338+Bosseur31@users.noreply.github.com> Date: Mon, 1 Mar 2021 15:50:22 +0100 Subject: [PATCH] Update blaster_db.py Blasters support RM4, RM4c, RM4 Pro and some RM3 blasters. Use rm4 class and get_type function. --- app/db_helpers/blaster_db.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/db_helpers/blaster_db.py b/app/db_helpers/blaster_db.py index 989f80a..cf9feb6 100644 --- a/app/db_helpers/blaster_db.py +++ b/app/db_helpers/blaster_db.py @@ -29,6 +29,7 @@ class Blaster(BaseBlastersModel): ip = TextField() port = IntegerField() devtype = IntegerField() + devicetype = TextField() mac = TextField(unique=True) mac_hex = TextField(unique=True) name = TextField(unique=True, null=True) @@ -39,9 +40,14 @@ def available(self): @property def device(self): - device = broadlink.rm( - host=(self.ip, self.port), mac=dec_hex(self.mac_hex), devtype=self.devtype - ) + if self.devicetype == "rm2": + device = broadlink.rm( + host=(self.ip, self.port), mac=dec_hex(self.mac_hex), devtype=self.devtype + ) + else: + device = broadlink.rm4( + host=(self.ip, self.port), mac=dec_hex(self.mac_hex), devtype=self.devtype + ) try: device.auth() except broadlink.exceptions.NetworkTimeoutError: @@ -163,6 +169,7 @@ def get_new_blasters(timeout=DISCOVERY_TIMEOUT): ip=blaster.host[0], port=blaster.host[1], devtype=blaster.devtype, + devicetype=blaster.get_type().lower(), mac_hex=mac_hex, mac=friendly_mac_from_hex(mac_hex), name=None,