Skip to content

Commit

Permalink
Fixes Broadlink commands sequence smartHomeHub#481
Browse files Browse the repository at this point in the history
  • Loading branch information
vassilis-panos committed Sep 19, 2020
1 parent f195390 commit bb3300e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 24 deletions.
2 changes: 1 addition & 1 deletion custom_components/smartir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
_LOGGER = logging.getLogger(__name__)

DOMAIN = 'smartir'
VERSION = '1.13.1'
VERSION = '1.13.2'
MANIFEST_URL = (
"https://raw.githubusercontent.com/"
"smartHomeHub/SmartIR/{}/"
Expand Down
48 changes: 28 additions & 20 deletions custom_components/smartir/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,36 @@ def check_encoding(self, encoding):

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(
Expand Down Expand Up @@ -173,4 +181,4 @@ async def send(self, command):
service_data = {'command': json.loads(command)}

await self.hass.services.async_call(
'esphome', self._controller_data, service_data)
'esphome', self._controller_data, service_data)
4 changes: 2 additions & 2 deletions custom_components/smartir/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "SmartIR",
"homeassistant": "0.115.0b0",
"homeassistant": "0.115.0",
"persistent_directory": "codes"
}

0 comments on commit bb3300e

Please sign in to comment.