Error: from Crypto.Cipher import AES, Broadlink RM3 Pro Plus does not work

Hello,

My Broadlink RM3 Pro Plus works with HASS installed in Raspberry Pi 2. The import “from Crypto.Cipher import AES” is OK. I can call service like “switch.broadlink_send_packet_192_168_100_21” with good result.

However, the hassibian 0.64.[1] has many errors for the above Broadlink RM.
The service calls existing on the web if I installed additional package “pyaes”, but when I call, it causes the bellow errors.

bash-4.4# cat home-assistant.log
2018-03-02 16:03:28 ERROR (MainThread) [homeassistant.components.switch] Error while setting up platform broadlink
Traceback (most recent call last):
File “/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 84, in async_setup
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/lib/python3.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
File “/usr/lib/python3.6/asyncio/futures.py”, line 245, in result
raise self._exception
File “/usr/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/lib/python3.6/site-packages/homeassistant/components/switch/broadlink.py”, line 177, in setup_platform
broadlink_device.auth()
File “/config/deps/lib/python3.6/site-packages/broadlink/init.py”, line 203, in auth
response = self.send_packet(0x65, payload)
File “/config/deps/lib/python3.6/site-packages/broadlink/init.py”, line 258, in send_packet
payload = self.encrypt(payload)
File “/config/deps/lib/python3.6/site-packages/broadlink/init.py”, line 162, in encrypt_pyaes
return “”.join([aes.encrypt(bytes(payload[i:i+16])) for i in range(0, len(payload), 16)])
TypeError: sequence item 0: expected str instance, bytes found
bash-4.4#

If I do not install the additional package “pyaes”, it causes another errors:

bash-4.4# python3
Python 3.6.3 (default, Nov 21 2017, 21:28:39)
[GCC 6.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
from Crypto.Cipher import AES
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/python3.6/site-packages/Crypto/Cipher/init.py”, line 3, in
from Crypto.Cipher._mode_ecb import _create_ecb_cipher
File “/usr/lib/python3.6/site-packages/Crypto/Cipher/_mode_ecb.py”, line 29, in
from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
File “/usr/lib/python3.6/site-packages/Crypto/Util/_raw_api.py”, line 32, in
from Crypto.Util.py3compat import byte_string
ImportError: cannot import name ‘byte_string’

The init.py file for broadlink package:

try:
from Crypto.Cipher import AES
except ImportError as e:
import pyaes

How to make the above try “import AES” does not make the exception error in order to install Broadlink RM3 Pro Plus.

Thank you

After update to hassio 0.64.3, the python3 with “from Crypto.Cipher import AES”
does not cause error exceptions any more. The Broadlink RM3 Pro Plus works OK.

Thank you

what “type” did you use in your config for your rm3 pro plus?

For hass, the “type” of RM3 Pro Plus is not necessary to specify in configuration.yaml. It uses the default “type: rm”

If you use broadlink_cli in command line, “–type 0x279d”