Broadlink rm pro + inconsistencies

I’ve got a broadlink set up.
In trying to learn the remote I have to restart homeassistant and call the learn service. Then it sometimes puts it in persistent notifications.
Many times it says not received, I then need to restart and try again. Many times the button is truncated as well or just AAAAAAA requiring another restart. Also adding each button seems to require a switch. Does each button on my remote need a switch?
Is there a better way to add buttons?

Once I get the right code and add it the buttons seem to work reliably, but it seems like there has to be a better way to add the codes and get the buttons rather than switches.

When I set up my RM Pro I found some of the codes ‘ready-made’ on some websites like this one:

There’s also a discussion going on here:

I trigger most of my BroadLink commands via scripts right now - and use them in lovelace like this:
image

Can you show an example how you implement such a script? So far I had added all buttons as an on/off switch, which fills up my config really fast.

I second Flovie @chairstacker can you share a couple of those scripts?

I think the issue might have been the remote. I wonder if the battery was dying, cause the second remote I ‘learned’ went much faster. I call the service. Press the button and got the code.

The only issue now is after restarting the switches don’t show up in home assistant, but I’ll debug that tonight.

On further reflection it also might have something to do with the packet size. The remote I had trouble with was samsung and the packets were more than twice as long as the packets for the emerson tv I had no trouble with.

Ok these are coming a bit fast but I had a brain storm. I found one github issue that said there was a version of the broadlink py init script that was out of date. I had replaced that to see if it works. I think that may have broken the learn command https://github.com/home-assistant/home-assistant/issues/15915

I forgot I reverted it back. Once doing that learn worked, but the send and initialization does not.

Switching back yet again to the one recommended in the issue does not fix it. I get this error:
2018-09-13 09:21:52 ERROR (MainThread) [homeassistant.components.switch] Error while setting up platform broadlink
File “/usr/src/app/homeassistant/components/switch/broadlink.py”, line 157, in setup_platform
File “/usr/src/app/homeassistant/components/switch/broadlink.py”, line 193, in init

Maybe you can uninstall the component and let HA re-install it on a restart, not sure what the correct command is for your setup, though.
Probably simething similar to this:

pip3 -uninstall broadlink 
or
pip -uninstall broadlink

I don’t think I had to change anything when I started using the component.

This is the one of the scripts I use:

soundbar_power_toggle:
  sequence:
    - service: switch.broadlink_send_packet_192_168_7_26
      data:
        packet:
          - "JgCgAJaSEw4TDhMOEw4TLxMvEw4TDhMvEjASMBIwEg8SDxIPEg8SkhMOEw4TDhMOEw4TDhMOEw4TLxMvEy8TDhMvEy8TLxMvEw4TDhMOEy8TAAcclpITDhMOEw4TDhMvEy8TDhMOEy8TLxMvEy8TDhMOEw4TDhOREw4TDhMOEw4TDhMOEw4TDhMvEy8TLxMOEy8TLxMvEy8TDhMOEw4TLxMADQUAAAAAAAAAAA=="

And I call it from a lovelace card with this setup:

      - type: glance
        title: Sound Remote
        show_state: false
        show_name: false
        entities:
          - entity: script.soundbar_power_toggle
            tap_action: call-service
            service: script.soundbar_power_toggle

BTW - this is what I use in my customize.yaml to get the icon into my UIs:

script.soundbar_power_toggle:
  friendly_name: "Soundbar ON/OFF"
  icon: mdi:speaker-wireless

Thanks those scripts look great. As for reinstalling I’m running it on docker so I’m hesitant to do that since the changes will get thrown away when I upgrade. It seems after digging that occasionally it pulls the wrong code in and it dies when they try to base64decode the ir code that isn’t correct. Re-learning the codes it dies on seems to work.

I’ve stop using learn service from HA. I found it too inconsistent. I’ve ended up using e-control app and import the code using the script provided in the docs.

BTW, all my codes never ends with =, do you have to add it in the end of the code?

@hoedha I think you’re right Home Assistant is just very inconsistent with learn. I have the broadlink on a vlan with no internet access so the app is kind of wonky too, but once I get the right code it seems to work correctly.

@chairstacker thanks for those snippets, that made it really easy to set up!

Ok sorry for the spam everyone, but this is the first I’ve dabbled in customization, scripts or lovelace, and this makes it so much easier, there is no need for the switch itself, just the platform.

I’m migrating all of my RF switch to tasmota based sonoff. I find RF switches are not reliable enough for me.

  1. I can’t fire commands to multiple RF switches at one time. Eg, I want to turn off all my 4 RF switches at 5pm, I have to add 2-3 second delay to each command. Otherwise, one or two switches won’t come off.

  2. No state feedback from the RF switches which is very important if you want to be sure that your outdoor lights are on at scheduled time.

So my broadlink rm pro now only control IR commands for TV, STB, and AC…