0.67 - Broadlink platform stopped working (MP1, 4 slot smart switch)

It was working an hour ago, updated now, and I get an error on startup.

Config.yaml

switch:
  - platform: broadlink
    host: 192.168.0.123
    mac: '11:22:34:d1:33:44'
    type: mp1
    friendly_name: Broadlink
    slots:
      slot_1: 'Slot 1'
      slot_2: 'Slot 2'
      slot_3: 'Slot 3'
      slot_4: 'Slot 4'

Log Details (ERROR)

Sat Apr 14 2018 09:03:53 GMT+0200

Error while setting up platform broadlink

Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 82, in async_setup
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/switch/broadlink.py", line 173, in setup_platform
    broadlink_device, i, parent_device)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/switch/broadlink.py", line 316, in __init__
    super().__init__(friendly_name, device, None, None)
TypeError: __init__() missing 1 required positional argument: 'command_off'

Seeing the same thing, reverted to previous build resolves for now

Same here, there’s is a Breaking Change issue stated in 0.67 update https://github.com/home-assistant/home-assistant/pull/13642 to change friendly_name to entity_id but it is very confusing, on the examples the use they friendly_name tag only
Anyway, all of my switches and my remote control scripts are broken now, interestingly, my S2 alarm kit (an addon component) is working fine

Hello! Are you using the BroadLink climate custom component? That was my problem. The developer just updated it and now it works great!

1 Like

I am seeing the same thing in my logs related to my switches:

 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 165, in setup_platform
     switches = [BroadlinkSP2Switch(friendly_name, broadlink_device)]
   File "/usr/lib/python3.6/site-packages/homeassistant/components/switch/broadlink.py", line 260, in __init__
     super().__init__(friendly_name, device, None, None)
 TypeError: __init__() missing 1 required positional argument: 'command_off'

Example of one of the switches is:

   - platform: broadlink
     scan_interval: 5
     host: 192.168.1.26
     mac: 'b4:43:0d:d2:03:c3'
     type:  sp2
     friendly_name: 'Office Outdoor Light'

The error I’m seeing “TypeError: init() missing 1 required positional argument: ‘command_off’” suggests that it is failing on the command_off not being defined but it is a subset of the switches array which I am not using. I don’t understand why this is now not working.

I wound up reverting back to 0.66.1 and the issue was resolved.

Problem with broadlink mp1 won’t show up in HA 0.67.

My Broadlink configuration “friendly names” are no longer being recognized after 0.67 and 0.67.1, broke all automations that pointed at the friendly name for RF switches and IR commands, additionally my switches are no longer being grouped correctly. In other words, switches still show up and can be operated, but friendly names are not loading.

I upgraded to version 0.67.1 and when I try to effect a state change on the a broadlink switch, I get the following:

 Traceback (most recent call last):
   File "/usr/lib/python3.6/site-packages/homeassistant/core.py", line 1002, in _event_to_service_call
     await service_handler.func(service_call)
   File "/usr/lib/python3.6/site-packages/homeassistant/components/switch/__init__.py", line 109, in async_handle_switch_service
     await switch.async_turn_on()
   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 219, in turn_on
     if self._sendpacket(self._command_on):
   File "/usr/lib/python3.6/site-packages/homeassistant/components/switch/broadlink.py", line 267, in _sendpacket
     self._device.set_power(packet)
   File "/usr/lib/python3.6/site-packages/broadlink/__init__.py", line 394, in set_power
     if self.check_nightlight():
   File "/usr/lib/python3.6/site-packages/broadlink/__init__.py", line 432, in check_nightlight
     if ord(payload[0x4]) == 2 or ord(payload[0x4]) == 3:
 TypeError: ord() expected string of length 1, but int found

I also see numerous errors when the system tries to update the state of the switch:

 Update for switch.office_light fails
 Traceback (most recent call last):
   File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 204, in async_update_ha_state
     yield from self.async_device_update()
   File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 327, in async_device_update
     yield from self.hass.async_add_job(self.update)
   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 293, in update
     self._update()
   File "/usr/lib/python3.6/site-packages/homeassistant/components/switch/broadlink.py", line 298, in _update
     state = self._device.check_power()
   File "/usr/lib/python3.6/site-packages/broadlink/__init__.py", line 418, in check_power
     if ord(payload[0x4]) == 1 or ord(payload[0x4]) == 3:
 TypeError: ord() expected string of length 1, but int found

The switch is defined as:

   - platform: broadlink
     host: 192.168.1.27
     mac: 'b4:43:0d:d2:03:0e'
     type:  sp2
     friendly_name: 'Office Light'

I will revert to 0.66.1 again until this is resolved. Just an FYI on the state of the issue.

After update to 0.67.1, my broadlink mp1 show up normally.

wasnt there a breaking change regarding the friendly_name an it now not being used. upgrading to 67.1 may not resolve that

The error doesn’t appear to be referring to the friendly name but rather an inappropriate variable type. Plus, all of my broadlink based devices show up appropriately in the listing so it is able to understand the friendly_name.
I don’t really understand what the breaking change was suppose to do. The documentation still lists it and I am following the example code to the letter.
https://www.home-assistant.io/components/switch.broadlink/

Has anyone managed to find a fix for this yet? I set up my Broadlink component while on 0.67, so it has never worked for me so far. Was hoping that 0.67.1 would fix it but still nothing.

I have setup the config according to the Broadlink components page but the switches are not showing up on the States page or in the frontend.

My log:

2018-04-18 23:54:30 WARNING (MainThread) [homeassistant.setup] Setup of config is taking over 10 seconds.
2018-04-18 23:54:53 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 157, in setup_platform
device_config.get(CONF_COMMAND_OFF)
File “/usr/lib/python3.6/site-packages/homeassistant/components/switch/broadlink.py”, line 193, in init
self._command_on = b64decode(command_on) if command_on else None
File “/usr/lib/python3.6/base64.py”, line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

My config:

  - platform: broadlink
    host: 192.168.1.xx
    mac: 'xxxxxxxxx'
    switches:
      wardrobe_aircon:
        friendly_name: "Wardrobe Aircon"
        command_on: 'JgBQAhAMEQwQDBAMEQwQAANAdDYRKBELEQwQDBEoEAwRCxEMEAwRKBAMESgQKRAMECkQKBEoECkQKBEMEAwRKBAMEQsRDBAMEQsRDBAMEQsRDBAMESgQDBEoEAwRDBAMECkQKBEMEAwQDBEMEAwRCxEMEAwRCxEMEAwRCxEMEAwRDBAMECkQKBEoEAwRKBAMESgQKRAABHZ0NhEoEAwRDBAJEykQDBANEAwQDBApEAwRKBApEAwQKRAoESgQKRAoEQwQDBApEAwQDBEMEAkTDRAMEAwQDRAMEAwRDBAoEQwQDBAMEQwQKBEMEAwQDBEMEAwQDBEMEAwQDBEMEAwRCxEMEAwRDBAMEAwRDBAMECkQDBApEAwQKRAMEAAEd3M3ECgRDBAMEQsRKBELEQwQDBELESgRDBAoESgQDBEoECkQKBEoESgQDBELESgRCxEMEAwRDBAMEAwRDBAMEAwRDBAMEAwRDBAMEAwRDBAMEAwRDBAMEAwRKBELESgRCxEMEAwRCxEMEAwRCxEMECkQKBEMEAwQDBEMEAwQDBEMEAwQDBEMEAwQDBEMECgRDBAoEQwQDBELEQwQDBEMEAwQDBEMEAwQDBEMEAwQDBEMEAwQDBEoECkQDBELEQwQDBELEQwQDBELEQwQDBEoECkQDBAMEQwQDBAMEQwQDBAMEQwQDBAMEQwQDBAMEQwQDBELEQwQDBELEQwQDBELESgRKBAMEQwQDBAMEQwQDBAMEQwQDBApEAwQDBEMEAwRCxEMEAwQKRAMEQsRDBAMESgQKRAADQUAAAAAAAAAAA'
        command_off: 'JgBQAhELEAwRDBAMEAwRAANAcjgPKg8NDg4PDg4rDw0ODg4PDg4OKw8NDisPKQ8ODioPKg8qDykPKg8NDw4OKw8NDg4ODw4ODg4ODw4ODg4ODw4ODisPDQ4rDw0ODg8ODioPKg8NDw4ODg4ODw4ODg4ODw4ODg4PDg4ODg4PDg4ODg4PDioPKg8qDw0OKw8NDisPKg4ABHh0NhEoEQsRCxILESgRCxELEQwRCxEoEQsRKBEnEQwRJxInESgRKBEnEQsSCxEoEQsQDBANEQsQDBANEQsQDBANEQsQDBApEQsQDRELEQsSJxELEgsRCxEMEAwRCxEMEQsRCxEMEAwRCxEMEQsQDBEMEQsRCxEMEScRDBEnEQwRKBELEQAEdXU1ESgRCxEMEQsQKRELEQwRCxAMESgRCxApECkQDBApECgQKRApECkPDQ4ODisODg4PDg4ODg4PDg4ODg4PDg4ODg4PDg4ODg8ODg4ODg8ODg4OKw4ODg4PKg4ODyoODw4ODg4ODw4ODg4ODw4ODisOKg8ODg4ODg8ODw0ODhANEAwQDBANEAwQDBEMECkPDRApEAwQDBANEAwQDBANEAwQDBANEAwQDBANEAwRCxANEAwRCxEoESgRCxELEQwRCxELEQwRCxEMEQsRCxEoESgRCxELEQwRCxELEQwRCxELEQwRCxELEQwRCxELEgsRCxELEgsRCxEMEQsRCxEMEScRKBELEQwRCxELEQwRCxELEQwRCxEoEQsRCxEMEQsRCxILESgRJxEMEQsRCxEMEScRKBEADQUAAAAAAAAAAA'

In case it is useful for others having the same issue:

I fixed it by adding “===” to the end of my commands.

1 Like

The custom_component climate broadlink was causing the error in my case after upgrading hass to 0.67.
Updated its broadlink.py file and broadlink is back without errors.

is this working for you? Just got an mp1 today and is not working with 0.89.1

Mine is working fine. What’s your config?