Broadlink Component Issue

Morning All,

I upgraded from 063.3 to 065.6 and all my RF switches stopped working (using a Broadlink Pro).

So I thought, okay I’ll downgrade back to 0.63.3. Still dead.

I have since upgraded to 0.66.0. The current error I have is this:

2018-03-31 11:06:50 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 82, 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/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 158, in setup_platform
    device_config.get(CONF_COMMAND_OFF)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/switch/broadlink.py", line 194, in __init__
    self._command_off = b64decode(command_off) if command_off else None
  File "/usr/lib/python3.6/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

Things I’ve tried:

  • Downgrading back to 63.3.
  • Using a 5 day old Snapshot, issue still prevailed (which was also 63.3).
  • Resetting the broadlink.
  • Resettting my router.
  • Testing the broadlink through an android box I used to use for Home Automation before using HA (works fine).
  • Running my switches.yaml through yamllint.
  • A fresh install of HA.

Can anyone dumb down this error for me so I can do some more googling?

Read somewhere it has to do with pycryto needing to be replaced with pycrytodome.

However pip3 isn’t available on Hassio installations. Any way to execute the below on Hassio through SSH?

pip3 uninstall pycrypto
pip3 uninstall pycryptodome
pip3 install pycryptodome

I had a very similar problem when setting up my Broadlink originally. I started with 0.65.5. When I originally set it up, I copied the example script with the Phillips tv codes and the switches showed up fine (they didn’t function since I didn’t have a Phillips TV). When I changed the codes to what I pulled from the Broadlink_learn_packet service, the switches would not show up and I got the same errors as you are reporting.

I tired messing with the pycrypto and stuff that you are listing as well and had no luck.

I did get it working though. This is what I did and it worked (still not sure why):

I read on another post to take out the : from your MAC address so I did that but it still didn’t get my switches to show up. I have since left it without the : though.

I added “==“ onto the end of each one of my commands and now they all show up and all work.

I’m not sure why but everything is working now.

Hope this helps.

3 Likes

I think the reasoning behind that is that they have to be divisible by 4. Unfortunately they’ve worked for months and have the additional == (I read them in hex and converted to base64 so they were automatically padded with == where needed).

Thanks for the input as if someone else comes by the issue may read this and it may help them.

Edit: I got it working did another complete new re-install and it worked. No idea what’s changed though so not much help for anyone else sorry.

1 Like

omg. this error was killing me!

found the problem. thank you jesus.