Broadlink Manager - Nicer way to Learn and Send IR/RF commands

Hi @gaosori ,
Alternatively you can git clone the project,
run the pip3 install command and then run

python3 broadlinkmanager.py

and it will run on your raspios without any need to use docker.

1 Like

@Tomer_Klein, @jrhbcn, Thanks!!! I did the suggested changes this afternoon and I was able to run the program!!! :slight_smile:

Running Docker-compose with host option for network

But I get the exact same problem as @alexspires. It’s scanning but can’t find any of my two RM4 on the same local network.
Tried the Winblows version (https://sourceforge.net/projects/broadlink-manager/) and that application can’t find them either…

Feels like Logitech Harmony, when they closed the API port in an update :-/

Hi @gaosori ,
Try running it with this setup (Dockerless):

1 Like

EDIT Reread the implementation guide for Broadlink…

Many users are experiencing problems with the new Broadlink RM Mini 3 and the entire RM4 series.
Once connected to the cloud, these devices lose their local capabilities and can no longer be controlled by Home Assistant.

Tried dockerless right now, same result. Got this from stdout:

.
.
192.168.254.200 - - [26/Jun/2020 11:18:47] "GET /autodiscover HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/lib/python3.8/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3.8/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/cbdsadmin/git/broadlinkmanager-docker/broadlinkmanager/broadlinkmanager.py", line 384, in autodiscover
    if device.auth():
  File "/usr/lib/python3.8/site-packages/broadlink/__init__.py", line 225, in auth
    check_error(response[0x22:0x24])
  File "/usr/lib/python3.8/site-packages/broadlink/exceptions.py", line 97, in check_error
    raise exception(error_code)
broadlink.exceptions.AuthenticationError: Authentication failed

``
Thanks @tomer_Klein very clear instructions, easy to follow, and I installed the program in a couple of minutes. Just one comment, in the part B, the command sudo cd /opt does not work, it is just cd /opt
image

The sad part is that I´m having the same issue than @snis and @alexspires , the app stays scanning and never find the 2 remotes that I have in my network (RM mini 3 and RM4 Pro). Any suggestion how to solve that? Any help will be very appreciated :slight_smile:

Just as a reference: the old app (windows version) finds only the mini without issue, but when it finds the RM4 pro, it shows the message ¨Writing compatible device not detected¨, and I cannot connect to the RM4 that is the one with the RF commands that I need.
image

I

2 Likes

Hi Tomer,

Do you know when you release new version BM for Win? I have the same issue with RM 3 mini. Do you check this issue as a bug? 105968747_3275369365820605_1915209052183613751_n

Good Afternoon,

I have followed the link to TechBlog about installing Broadlink Manager on a Raspberry Pi. I was able to find my RM4 Pro(0x61a2). When I try and learn an RF code the webpage spits back that there was an Error while scanning, please try again. Looking at the command prompt, I see there is an issue with sweep_frequency. Any advice on how to proceed would be appreciated.

P.S. I also have issues trying to learn IR codes.


Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/flask/app.py", line 2309, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/lib/python3/dist-packages/flask/app.py", line 2295, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib/python3.7/dist-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1741, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3/dist-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python3.7/dist-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3/dist-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python3/dist-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/broadlinkmanager-docker/broadlinkmanager/broadlinkmanager.py", line 280, in sweep
    dev.sweep_frequency()
AttributeError: 'device' object has no attribute 'sweep_frequency'

I met the same as you. sad

ứng dụng này không thể điều khiển RM mini 3 và RM 4 pro. cả 2 thiết bị mà tôi có. hic hic

"
I also encountered this same application which cannot control RM mini 3 and RM 4 pro. both of the devices that I have. understand like you. sad"

I Figured I had started my Journey in this thread so I may as well post the solution I am using. Keeping in mind my issues was getting the RM4 Pro RF learning and sending. I was working with Felipe Martins Diel (Broadlink RM4 PRO is not able to learn or to send RF Signal · Issue #358 · mjg59/python-broadlink · GitHub) who i believe has a fix however it is going to be a while till we see it production. So in the interim this is how I am using it.

Short Version
Ensure you have the latest HA (I am on 0.112.2) not sure which version brought in the first set of fixes

  • Python-broadlink to add the RM4 to the wifi without cloud integration

    broadlink.setup(‘myssid’, ‘mynetworkpass’, 3)

  • Broadlink_Cli to capture the RF codes

    ./broadlink_cli --rfscanlearn --device “0x6026 [IPADDRESS] [MAC]”

  • Add the device into home assistant configuration.yaml
script:
  name_of_the_script:
    sequence:
      - service: broadlink.send
        data:
          host: [RM4 IP ADDRESS]
          packet: sgAsAhEREhESEQIEhEBEhESERISERIRARIiEQESERISERESEhEAAF3AAAAAAAAA==

The Long Version
Installing python-broadlink
Use a device with wifi (so you can connect to the Production Wifi and RM4 AP)

git clone GitHub - mjg59/python-broadlink: Python module for controlling Broadlink RM2/3 (Pro) remote controls, A1 sensor platforms and SP2/3 smartplugs
cd python-broadlink
sudo python setup.py install

Factory Reset (Ensure it is not cloud joined)

  • Reset hold reset button till flashes
  • Hold reset button to get hot spot paring
  • Join Computer to Broadlink WiFi to connect to the RM4

Setup RM using python-broadlink

  • Configure device for Wifi

    python import broadlink
    broadlink.setup(‘myssid’, ‘mynetworkpass’, 3)

  • Allow device time to reboot and connect to wifi (LED should no longer flash)
  • Test device communications

    devices = broadlink.discover(timeout=5) devices[0].auth() > should return true devices[0].host[0]
    Should return IP of Device

Capture RF sequences
NB Fix is underway for RM4 Pro broadlink.learn however not available in HA yet Broadlink RM4 PRO is not able to learn or to send RF Signal · Issue #358 · mjg59/python-broadlink · GitHub

Use broadlink_cli to capture RF codes

  • Capture RF Sequence

    ./broadlink_cli --rfscanlearn --device “0x6026 [IPADDRESS] [MAC]”

  • Test Sequence from HA: Developer Tools > Services
    • Service: broadlink.send

    host: 192.168.1.13
    packet: sTgaAAcQBxAHDwgIDhAHEAcPCA8HCA4IDgkOCQ7+AAAAA

    • If no action re-capture using broadlink_cli otherwise good to use it for the scripts/switches

Home Assistant Configuration
I am controlling fans so I have a bit more of a complex configuration for fan speed control sending sequence directly

Sending RF Sequences with scripts/automation

script:
  name_of_the_script:
    sequence:
      - service: broadlink.send
        data:
          host: [RM4 IP ADDRESS]
          packet: sgAsAhEREhESEQIEhEBEhESERISERIRARIiEQESERISERESEhEAAF3AAAAAAAAA==

Configuration.yaml Switch

switch:
  - platform: broadlink
    host: [RM4 IP ADDRESS]
    mac: [RM4 MAC ADDRESS]
    type: rm4_pro
    timeout: 15
    switches:
      tv_samsung_power:
        friendly_name: "Samsung TV Power"
        command_on: '[RF SEQUENCE]'
      tv_samsung_volume:
        friendly_name: "Samsung TV Volume"
        command_on: '[RF SEQUENCE]'
        command_off: '[RF SEQUENCE]'
1 Like

Thanks for the instructions!

I got to the point where I’m attempting to capture RF sequences using the broadlink_cli command, but it seems like I don’t have it installed properly or something.

I get the following error instead
File "<stdin>", line 1 ./broadlink_cli --rfscanlearn --device "0x6026 [IP] [MAC]" ^ SyntaxError: invalid syntax

I installed python-broadlink via PIP, but I’m not sure where the files actually are to verify if the cli directory is in there.
I also downloaded the broadlink_cli and broadlink_discovery files to manually copy them if necessary, but again, I’m not sure where they should go.

Would appreciate any help here. Thanks!

@quagmired given it is responding with a syntax error it sound to me like it is recognising the command just not the parameters being passed. So I think the install is ok.

Just to be clear [IP] needs to be your devices IP address and [MAC] needs to be the devices MAC address so the actual command I run is

./broadlink_cli --rfscanlearn --device “0x6026 192.168.1.13 24dfa7b9c05a”

At work at the moment so I can’t confirm the location my files installed to. However, hoping the above might help. Keep in mind wherever i use [CAPITALS] it generally means replace with your values.

can docker version be installed like add-ons?

how can I send rf signals (433 MHz) that are learned with another software? I have them as binary 65 bit code. https://github.com/akirjavainen/A-OK/blob/3c5ec0d6f38775aaa8aa69ff0819711a25360db5/A-OK.ino has the full description of the protocol

thank you for any help

@Tomer_Klein You absolute legend, your timing is impeccable. My RM4 Pro was delivered June 24. I learned the IR codes I wanted first with the HA method, but got stuck when trying the RF codes a week or so later. This is going to make my life so much easier.

At first I tried specifying port 7020 instead of using network host like @GorkyV, the web interface loaded but couldn’t detect my device. Recreated the image with host networking instead, it very quickly found the device and learned an RF code successfully in the web UI. Didn’t seem to have any of the issues described above after I actually RTFM.

While trying this, I had to clear the cache before the device would load; simply refreshing the page after adding host networking didn’t work. Watch out for caching issues if you’re having the same problem :slight_smile:

Is there any possibility of adding more ports to get this working without host networking? I don’t understand Docker well enough to know why, but I thought it was preferable to avoid host networking where possible.

Thanks again for your amazing work Tomer, can’t wait to have the time to build up my RF integrations properly!

Thanks for the reply. Yea I used my device’s actual IP and MAC ID where the placeholders were, like this

./broadlink_cli --rfscanlearn --device “0x6026 192.168.1.98 24dfa7abc123”

I even tried replacing 0x6026 with 0x61a2 since init.py listed that as an RM4 Pro device too, but that didn’t work either.

Also tried updating/reinstalling python-broadlink with

pip install --upgrade https://github.com/mjg59/python-broadlink/archive/master.zip

Still got the same result.

Any ideas? Thanks again!

Not 100% sure what it might be when I look at the broadlink.egg-inf/PKG-INFO the version I appear to be running is

Name: broadlink
Version: 0.13.2
Summary: Python API for controlling Broadlink IR controllers
Home-page: http://github.com/mjg59/python-broadlink
Author: Matthew Garrett
Author-email: [email protected]

Just a thought … to be clear I am not running the ./broadlink_cli --rfscanlearn --device from within python. it is directly from the command line

Thanks again for taking the time to reply.

If it’s not too much trouble, could you walk me through that last part of where exactly to enter ./broadlink_cli --rfscanlearn --device, after I’ve done the following steps?

OK, so my broadlink.egg-inf/PKG-INFO shows the following, so I’m guessing this part is fine.

Metadata-Version: 1.1
Name: broadlink
Version: 0.14.0
Summary: Python API for controlling Broadlink IR controllers
Home-page: http://github.com/mjg59/python-broadlink
Author: Matthew Garrett
Author-email: [email protected]

Then I open Windows PowerShell as administrator, type python to enter Python 3.8.3, then the following commands just to make sure my RM4 Pro is on the network:

>>> import broadlink
>>> devices = broadlink.discover(timeout=5)
>>> devices[0].auth()
True
>>> devices[0].host[0]
192.168.1.98

Where should I go from here? I’ve attempted exiting Python and simply entering the ./broadlink_cli --rfscanlearn --device command while still in PowerShell, but I get the following error instead:

PS C:\> ./broadlink_cli --rfscanlearn --device "0x6026 192.168.1.98 [MAC]"
./broadlink_cli : The term './broadlink_cli' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ ./broadlink_cli --rfscanlearn --device "0x6026 192.168.1.98 [MAC] ...
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (./broadlink_cli:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I tried Windows Command Prompt instead and got similar:

'broadlink_cli' is not recognized as an internal or external command,
operable program or batch file.

So I’m at a loss as to where exactly should the command be entered… Would greatly appreciate any help here, thanks!

Another point I didn’t make … I am running it within the Raspbian command shell. I’ll try installing on my windows 10 box but I think it is likely the utility isn’t windows based. What device are you running HA on?
I did try running all the python stuff on windows 10 but ended up moving over to the Raspberry pi (that I have running HA (docker)). I was finding most examples and people were running using a Linux base and I was having all sorts of issues. Possibly a bit like what you are experiencing. In truth I don’t have a 100% grasp on all of this :slight_smile:, work in progress.

I did try this now on my Windows 10 box and it appears to be positive

Steps that I used on the pi are bellow
Config SSH on PI
Connect via SSH (I use putty)
Install Braodlink

git clone https://github.com/mjg59/python-broadlink.git
cd python-broadlink
sudo python setup.py install

then to run broadlink_cli

$ cd \python-broadlink\cli
$ ./broadlink_cli --rfscanlearn --device "0x6026 192.168.1.13 24dfa7b9c05a"
1 Like