Kaynağa Gözat

Fixes Broadlink commands sequence #481

Vassilis Panos 6 yıl önce
ebeveyn
işleme
bb3300e40b

+ 1 - 1
custom_components/smartir/__init__.py

@@ -19,7 +19,7 @@ from homeassistant.helpers.typing import ConfigType
 _LOGGER = logging.getLogger(__name__)
 
 DOMAIN = 'smartir'
-VERSION = '1.13.1'
+VERSION = '1.13.2'
 MANIFEST_URL = (
     "https://raw.githubusercontent.com/"
     "smartHomeHub/SmartIR/{}/"

+ 28 - 20
custom_components/smartir/controller.py

@@ -74,28 +74,36 @@ class BroadlinkController(AbstractController):
 
     async def send(self, command):
         """Send a command."""
-        if self._encoding == ENC_HEX:
-            try:
-                command = binascii.unhexlify(command)
-                command = b64encode(command).decode('utf-8')
-            except:
-                raise Exception("Error while converting "
-                                "Hex to Base64 encoding")
-
-        if self._encoding == ENC_PRONTO:
-            try:
-                command = command.replace(' ', '')
-                command = bytearray.fromhex(command)
-                command = Helper.pronto2lirc(command)
-                command = Helper.lirc2broadlink(command)
-                command = b64encode(command).decode('utf-8')
-            except:
-                raise Exception("Error while converting "
-                                "Pronto to Base64 encoding")
+        commands = []
+
+        if not isinstance(command, list): 
+            command = [command]
+
+        for _command in command:
+            if self._encoding == ENC_HEX:
+                try:
+                    _command = binascii.unhexlify(_command)
+                    _command = b64encode(_command).decode('utf-8')
+                except:
+                    raise Exception("Error while converting "
+                                    "Hex to Base64 encoding")
+
+            if self._encoding == ENC_PRONTO:
+                try:
+                    _command = _command.replace(' ', '')
+                    _command = bytearray.fromhex(_command)
+                    _command = Helper.pronto2lirc(_command)
+                    _command = Helper.lirc2broadlink(_command)
+                    _command = b64encode(_command).decode('utf-8')
+                except:
+                    raise Exception("Error while converting "
+                                    "Pronto to Base64 encoding")
+
+            commands.append('b64:' + _command)
 
         service_data = {
             ATTR_ENTITY_ID: self._controller_data,
-            'command':  'b64:' + command
+            'command':  commands
         }
 
         await self.hass.services.async_call(
@@ -173,4 +181,4 @@ class ESPHomeController(AbstractController):
         service_data = {'command':  json.loads(command)}
 
         await self.hass.services.async_call(
-            'esphome', self._controller_data, service_data)
+            'esphome', self._controller_data, service_data)

+ 2 - 2
custom_components/smartir/manifest.json

@@ -7,8 +7,8 @@
   "requirements": ["aiofiles==0.5.0"],
   "homeassistant": "0.115.0",
   "updater": {
-    "version": "1.13.1",
-    "releaseNotes": "-- Adds support for the new Broadlink integration (Breaking change!)",
+    "version": "1.13.2",
+    "releaseNotes": "-- Fixes Broadlink commands sequence #481",
     "files": [
       "__init__.py",
       "climate.py",

+ 1 - 1
hacs.json

@@ -1,5 +1,5 @@
 {
   "name": "SmartIR",
-  "homeassistant": "0.115.0b0",
+  "homeassistant": "0.115.0",
   "persistent_directory": "codes"
 }