Broadlink Switch doesn't work

Hello. I’m trying to configure my Broadlink RM Mini with Home Assistant. I’ve tried different ways to learn signal from my remote (TV OK):

  1. Copying from EControl -as guide says-
  2. Using service from Home Assistant to Lear signal.
    The problem is that signal is different every time I press power button and as a script it doesn’t work and making switch in
    switch:
    - platform: broadlink
    host: 192.168.1.8
    mac: ‘xx:xx:xx:xx:xx:xx’
    timeout: 15
    switches:
    condizionatore:
    friendly_name: “Condizionatore”
    command_on: ‘AAAAA’
    command_off: ‘AAAA=’
    tv:
    friendly_name: “TV”
    command_on: ‘AAAA’
    command_off: ‘AAAA’

give me this error in Log:
Error while setting up platform broadlink
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 128, in _async_setup_platform
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/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/switch/broadlink.py”, line 157, in setup_platform
device_config.get(CONF_COMMAND_OFF)
File “/usr/local/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/local/lib/python3.6/base64.py”, line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

I hope someone could help you.
Thanks in advance

post the code with </> so we can help

I’ve modified some minutes after using </>. Bug maybe it doesn’t work. Now is it correct? The most important thing is the log. I think

Post your config here with </> or else cannot read whether is correct or wrong.

here is the guide for broadlink switch

I set preformatted test.

I’m using broadlink switch in HA and it works normally. So there might be something with your config. If you show your config for the broadlink switch then I can check. When you post your config here please use </> so that I can see if it is correct.

switch:
  - platform: broadlink
    host: 192.168.1.8
    mac: 'xx:xx:xx:xx:xx:xx'
    timeout: 15
    switches:
      # Will work on most Phillips TVs:
      condizionatore:
        friendly_name: "Condizionatore"
        command_on: 'JgDKAI2REDgPFBA4DzgQFBAUDzgQFBAUDzgQFBAUDzgQOA8UEDgPFQ8UEBQQOA84EDcQOA84EDgPOA84EBQQFA8VDxUPFBAUEDgPFBAUEDgPFBAUEBQQNxAUEDgPNxAVDzYSOA84EauQjw84EBQPOBA4DxQQFBA4DxUPFBA4DxUSERA4EjUQFA84EBQQFA8VDzgQOA84DzgQOA84EjUQOBISDxQRExAUEBQPFRI1EhISEhI1EhISEhISDzgSEg84EjUQFBI2EjUPOBAADQUAAAAAAAAAAAAAAAAAA'
        command_off: 'JgAaABweOR4bHhwdHB4dHRw6HhsdHR0dOTocAA0FAAAAAAAAAAAAAAAAAAA='
      tv:
        friendly_name: "TV"
        command_on: 'JgCQAAABKJQTExITEhMSExIUEhMSOBITEjcTNxM3EzYSOBI4EhMSOBITEjgSExITEjgSExITEhQROBIUETgSOBITEjcTOBE4EgAFJAABKEsSAAxdAAEoSxMADFwAAShKEwAMXAABKUoTAAxcAAEoSxIADF0AAShLEQAMXgABKEoSAAxdAAEoSxIADF0AAShLEgANBQAAAAAAAAAA'
        command_off: 'JgBoAAABKJUQFRAVEBYQFRAVEBYPOhAVEDoQOhA5EDoQOhA5EBYQORAWDzoQFg8WEDkQFhAVEBUQOhAVEDoQORAWEDkQOhA6EAAFJgABJkwRAAxeAAEoSxEADF0AASlKEgAMXQABKEsSAA0F='

I know that there is #philipsblabla, but it’s there because I copied code frome guide e change variables

The setting is correct and you need to put type:
Where did you put the switch: , check the ip of your broadlink as well.
Once setup complete, go to configuration>general>check config

platform: broadlink
host: 192.168.1.8
mac: 'xx:xx:xx:xx:xx:xx'
timeout: 15
type: rm
switches:
  kitchen_aircon:
    friendly_name: "Kitchen aircon"
    command_on: 'JgBAAGoAAUESMxESEBIQEhA0EBIREREREREREREREREREhERERESEBIyEhARMxIQEhASMhIQEhASMhIyETMSEBEADQUAAAAAAAAAAA=='
    command_off: 'JgBAAGYAAUYPNQ8TDxMPEw81DxMPEw8TDzYONg8TDxMPEw8TDxMPEw8TDxMPFA4TDxMQNA8UDjYREQ8TDxMPNQ8ADQUAAAAAAAAAAA=='

ip is correct. I fixed it in my router’s configuration. I’ve tryied adding " type: rm " but it doesn’t work!
Setting:
platform: broadlink
host: 192.168.1.8
mac: ‘78:0f:77:5a:e1:75’
timeout: 15
type: rm
switches:
tv:
friendly_name: “TV”
command_on: ‘JgBYAAABJ5YRFBEUERUQFREUERQROREVEDkRORE5ETgRORE5ERQROREUETkRFBEVEDkRFREUERQROREUETkROREUETkROBE5EQAFJgABKEsRAAxhAAEnSxIADQU’
command_off: ‘JgBYAAABJ5YRFBEUERUQFREUERQROREVEDkRORE5ETgRORE5ERQROREUETkRFBEVEDkRFREUERQROREUETkROREUETkROBE5EQAFJgABKEsRAAxhAAEnSxIADQU’

ERROR from LOG:
Error while setting up platform broadlink

Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 128, in _async_setup_platform
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/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/switch/broadlink.py”, line 157, in setup_platform
device_config.get(CONF_COMMAND_OFF)
File “/usr/local/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/local/lib/python3.6/base64.py”, line 87, in b64decode
return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

EDIT: I don’t understand why I have problems with </>

The problem with the formatting is that you really need a blank line before and after the code that you are selecting then the </> button will work every time.

To your error the error is binascii.Error: Incorrect padding that means that your base64 string is not divisible by 4 so add enough AA chars to the end of the string to make it divisible by 4 then add == to the end of the string…

e.g.

nexaremote1top: 
  friendly_name: "Nexa1Top"
  command_on:  'sg40AA4AAYAOJScNDiUOJQ4lDiUOJQ4lDiUnDA4lJwwOJSgMDiUnDA4lJwwOJScMDiUOJQ4lJwwAAAAA=='
  command_off: 'sgo0AA4lDiUnDA4lJwwOJScMDiUnDA4lJw0OJScMDiUOJQ4lJw0OAAGADiUnDA4lDiUOJQ4lDiUAAAAA=='
2 Likes

Really Thank You!! Now it’s working! I’m creating scripts for these because of it isn’t a switch!