Core: Broadlink broken after 0.64.0

Created on 26 Feb 2018  路  15Comments  路  Source: home-assistant/core

Make sure you are running the latest version of Home Assistant before reporting an issue.

You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:

Home Assistant release (hass --version):
0.64.0

Python release (python3 --version):
3.6

/platform:
Broadlink

Description of problem:

Error while setting up platform broadlink
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/broadlink/__init__.py", line 5, in <module>
    from Crypto.Cipher import AES
  File "/usr/local/lib/python3.6/site-packages/Crypto/Cipher/__init__.py", line 3, in <module>
    from Crypto.Cipher._mode_ecb import _create_ecb_cipher
  File "/usr/local/lib/python3.6/site-packages/Crypto/Cipher/_mode_ecb.py", line 29, in <module>
    from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
  File "/usr/local/lib/python3.6/site-packages/Crypto/Util/_raw_api.py", line 32, in <module>
    from Crypto.Util.py3compat import byte_string
ImportError: cannot import name 'byte_string'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 84, in async_setup
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/switch/broadlink.py", line 74, in setup_platform
    import broadlink
  File "/usr/local/lib/python3.6/site-packages/broadlink/__init__.py", line 7, in <module>
    import pyaes
ModuleNotFoundError: No module named 'pyaes'

Expected:

Problem-relevant configuration.yaml entries and steps to reproduce:

- platform: broadlink
  host: !secret broadlink_ip
  mac: '!secret broadlink_mac'
  switches:
    ziggomediabox:
      friendly_name: 'Ziggo Media Box'
      command_on: 'JgBQAJaYEg8TDRAREQ8TLxAzEBESDhMNEDMSDhMvEBERMhIOEBAQmBIPDzMQEBMwEw0QEREPEw0TDhAQEjETDRARETETDRAREDMSMBMvEDMSAA0FAAAAAAAAAAA='
      command_off: 'JgBQAJaYEg8TDRAREQ8TLxAzEBESDhMNEDMSDhMvEBERMhIOEBAQmBIPDzMQEBMwEw0QEREPEw0TDhAQEjETDRARETETDRAREDMSMBMvEDMSAA0FAAAAAAAAAAA='

Most helpful comment

This looks pretty similar to #2411, if I run the import in a shell I get:

>>> from Crypto.Cipher import AES
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/Crypto/Cipher/__init__.py", line 3, in <module>
    from Crypto.Cipher._mode_ecb import _create_ecb_cipher
  File "/usr/local/lib/python3.6/site-packages/Crypto/Cipher/_mode_ecb.py", line 29, in <module>
    from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
  File "/usr/local/lib/python3.6/site-packages/Crypto/Util/_raw_api.py", line 32, in <module>
    from Crypto.Util.py3compat import byte_string
ImportError: cannot import name 'byte_string'

Doing

pip3 uninstall pycrypto
pip3 uninstall pycryptodome
pip3 install pycryptodome

Lets me import the broadlink module without error

All 15 comments

This looks pretty similar to #2411, if I run the import in a shell I get:

>>> from Crypto.Cipher import AES
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/Crypto/Cipher/__init__.py", line 3, in <module>
    from Crypto.Cipher._mode_ecb import _create_ecb_cipher
  File "/usr/local/lib/python3.6/site-packages/Crypto/Cipher/_mode_ecb.py", line 29, in <module>
    from Crypto.Util._raw_api import (load_pycryptodome_raw_lib,
  File "/usr/local/lib/python3.6/site-packages/Crypto/Util/_raw_api.py", line 32, in <module>
    from Crypto.Util.py3compat import byte_string
ImportError: cannot import name 'byte_string'

Doing

pip3 uninstall pycrypto
pip3 uninstall pycryptodome
pip3 install pycryptodome

Lets me import the broadlink module without error

Same problem for me.
Where is it possibile to send these commands with Hass.io ?

pip3 uninstall pycrypto pip3 uninstall pycryptodome pip3 install pycryptodome

if i try it with putty i have this answer:

-bash: pip3: command not found

After uninstalling pycrpto and pycryptodome when i execute "pip3 install pycryptodome" i get below error.

unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pi p-build-k9mr5eah/pycryptodome/setup.py';f=getattr(tokenize, 'open', open)(__file __);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, ' exec'))" install --record /tmp/pip-w13a6v3k-record/install-record.txt --single-v ersion-externally-managed --compile" failed with error code 1 in /tmp/pip-build- k9mr5eah/pycryptodome/

Looks like there is no gcc on hass.io. How do i install gcc on hass.io. I am running hass.io as a docker container on generic ubuntu x86 machine.

FWIW, the ZHA module has the same issue using the docker build of HASS. I suspect the docker layer that includes the dependancies was not re-run for this release and/or there's an outdated version requirement in the code.

Same issue with my setup. I guess it will be fixed on the next update if not a workaround will be published.

Is there a workaround for docker installations? I use homeassistant/home-assistant (as most docker installations, I think)

I am on docker 2 .. think we have to wait for a fix ont his one. 0.64.1 is coming this evening as I understood

@orens, @dvd77 see this for docker until a code fix is released.

Thanks much, @roblandry! Workaround working for me.

@roblandry and @balloob ! can you help ..

After uninstalling pycrpto and pycryptodome when i execute "pip3 install pycryptodome" i get below error.

unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1


Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;file='/tmp/pi p-build-k9mr5eah/pycryptodome/setup.py';f=getattr(tokenize, 'open', open)(__file __);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, ' exec'))" install --record /tmp/pip-w13a6v3k-record/install-record.txt --single-v ersion-externally-managed --compile" failed with error code 1 in /tmp/pip-build- k9mr5eah/pycryptodome/

Looks like there is no gcc on hass.io. How do i install gcc on hass.io. I am running hass.io as a docker container on generic ubuntu x86 machine.

I got it ..

Install gcc by following commands

apk update
apk fetch build-base
apk add build-base

after this i was able to reinstall pycryptodome

still not working for me... still same error and no result with the fix from @roblandry

my error:

Wed Feb 28 2018 11:46:08 GMT+0100 (CET)

Error while setting up platform broadlink
Traceback (most recent call last):
File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 84, in async_setup
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
raise self._exception
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(self.args, *self.kwargs)
File "/usr/src/app/homeassistant/components/switch/broadlink.py", line 82, in setup_platform
config.get(CONF_MAC).encode().replace(b':', b''))
binascii.Error: Odd-length string

_EDIT:: WORKING!!!

Had to remove the ':' in the mac address !_

I know that this is not the best solution, but a downgrade helped me

curl -d '{"version": "0.63.1"}' http://hassio/homeassistant/update

Hello I had the same prob and here is how I fixed it on my Hass.io docker install on Ubuntu 馃憤

  1. Get into the docker instance with : sudo docker exec -i -t homeassistant /bin/bash
  2. update apk to get gcc with what kvjajoo said :
apk update
apk fetch build-base
apk add build-base
  1. Remove and reinstall pycrypto with :
pip3 uninstall pycrypto
pip3 uninstall pycryptodome
pip3 install pycryptodome
  1. restart your Homeassistant and got my broadlink back
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Konstigt picture Konstigt  路  3Comments

kirichkov picture kirichkov  路  3Comments

neonandu picture neonandu  路  3Comments

flsabourin picture flsabourin  路  3Comments

TheZoker picture TheZoker  路  3Comments