Skip to content

Commit bb3300e

Browse files
Fixes Broadlink commands sequence smartHomeHub#481
1 parent f195390 commit bb3300e

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

custom_components/smartir/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
_LOGGER = logging.getLogger(__name__)
2020

2121
DOMAIN = 'smartir'
22-
VERSION = '1.13.1'
22+
VERSION = '1.13.2'
2323
MANIFEST_URL = (
2424
"https://raw.githubusercontent.com/"
2525
"smartHomeHub/SmartIR/{}/"

custom_components/smartir/controller.py

+28-20
Original file line numberDiff line numberDiff line change
@@ -74,28 +74,36 @@ def check_encoding(self, encoding):
7474

7575
async def send(self, command):
7676
"""Send a command."""
77-
if self._encoding == ENC_HEX:
78-
try:
79-
command = binascii.unhexlify(command)
80-
command = b64encode(command).decode('utf-8')
81-
except:
82-
raise Exception("Error while converting "
83-
"Hex to Base64 encoding")
84-
85-
if self._encoding == ENC_PRONTO:
86-
try:
87-
command = command.replace(' ', '')
88-
command = bytearray.fromhex(command)
89-
command = Helper.pronto2lirc(command)
90-
command = Helper.lirc2broadlink(command)
91-
command = b64encode(command).decode('utf-8')
92-
except:
93-
raise Exception("Error while converting "
94-
"Pronto to Base64 encoding")
77+
commands = []
78+
79+
if not isinstance(command, list):
80+
command = [command]
81+
82+
for _command in command:
83+
if self._encoding == ENC_HEX:
84+
try:
85+
_command = binascii.unhexlify(_command)
86+
_command = b64encode(_command).decode('utf-8')
87+
except:
88+
raise Exception("Error while converting "
89+
"Hex to Base64 encoding")
90+
91+
if self._encoding == ENC_PRONTO:
92+
try:
93+
_command = _command.replace(' ', '')
94+
_command = bytearray.fromhex(_command)
95+
_command = Helper.pronto2lirc(_command)
96+
_command = Helper.lirc2broadlink(_command)
97+
_command = b64encode(_command).decode('utf-8')
98+
except:
99+
raise Exception("Error while converting "
100+
"Pronto to Base64 encoding")
101+
102+
commands.append('b64:' + _command)
95103

96104
service_data = {
97105
ATTR_ENTITY_ID: self._controller_data,
98-
'command': 'b64:' + command
106+
'command': commands
99107
}
100108

101109
await self.hass.services.async_call(
@@ -173,4 +181,4 @@ async def send(self, command):
173181
service_data = {'command': json.loads(command)}
174182

175183
await self.hass.services.async_call(
176-
'esphome', self._controller_data, service_data)
184+
'esphome', self._controller_data, service_data)

custom_components/smartir/manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"requirements": ["aiofiles==0.5.0"],
88
"homeassistant": "0.115.0",
99
"updater": {
10-
"version": "1.13.1",
11-
"releaseNotes": "-- Adds support for the new Broadlink integration (Breaking change!)",
10+
"version": "1.13.2",
11+
"releaseNotes": "-- Fixes Broadlink commands sequence #481",
1212
"files": [
1313
"__init__.py",
1414
"climate.py",

hacs.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "SmartIR",
3-
"homeassistant": "0.115.0b0",
3+
"homeassistant": "0.115.0",
44
"persistent_directory": "codes"
55
}

0 commit comments

Comments
 (0)