Broadlink/Bestcon RM4C Mini via MQTT

@mjeshurun I’ve updated my tutorial to include using python-broadlink to capture codes. Go back to my first post, to the Teach remote codes header, then click on Click to teach via python-broadlink. Let me know how it goes.

(This would probably also answer the first part of your question in post 15).

1 Like

I really don’t know how to thank you for all your good efforts and help.
You have my deepest gratitude! :pray: :pray: :pray:

I tried the python-broadlink solution you added, but I’m still getting error messages when I try to capture remote codes.
Here is a copy of the messages output when I followed your steps:

pi@raspberrypi:~ $ python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import broadlink
>>> devices = broadlink.discover(timeout=5)
>>> print(devices)
[<broadlink.rm4 object at 0xb66aadf0>]
>>> devices[0].auth()
True
>>> devices[0].enter_learning()
>>> packet = devices[0].check_data()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/dist-packages/broadlink/__init__.py", line 631, in check_data
    check_error(response[0x22:0x24])
  File "/usr/local/lib/python3.7/dist-packages/broadlink/exceptions.py", line 97, in check_error
    raise exception(error_code)
broadlink.exceptions.StorageError: The device storage is full
>>> print(packet.hex())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'packet' is not defined
>>> devices[0].send_data(packet)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'packet' is not defined
>>> 

I don’t know if this is related to the problem, but my RM4 Pro LED turns to color RED after I enter learning mode (It’s not WHITE as in your description). Also, the LED does not turn off after I press the remote button I want to learn.
I’m pretty sure the remote is close enough to the RM4 Pro to capture the code. The distance between the remote and RM4 Pro was 10 cm.

Yes, 10cm should certainly be close enough, unless the batteries in your remote have died!

Hmmm, I’m not sure what’s happening. I’ve never seen a red LED!

It might be worth completely re-setting the Broadlink device, and re-connecting it back to the wifi - just to start from new. Then try the new learning method?

I’ll have a think, but because I can’t replicate the error it’s a little tricky to debug. It’s obviously an issue, as evidenced by the GitHub link above, but not one I currently have!

EDIT: OK, so according to this comment, you will need to remove line 74 in the exceptions.py file within your python-broadlink folder.

You will then need to reinstall python-broadlink:

sudo python3 setup.py install

Then retry all the teaching stuff.

Still doesn’t explain the red LED though, I don’t think…

1 Like

Removed line 74, but it seems the problem still stays the same, as the error message indicates error 0xfffb (which was part of line 74).

pi@raspberrypi:~/python-broadlink $ python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import broadlink
>>> devices = broadlink.discover(timeout=5)
>>> print(devices)
[<broadlink.rm4 object at 0xb66b2cf0>]
>>> devices[0].auth()
True
>>> devices[0].enter_learning()
>>> packet = devices[0].check_data()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/python-broadlink/broadlink/__init__.py", line 631, in check_data
    check_error(response[0x22:0x24])
  File "/home/pi/python-broadlink/broadlink/exceptions.py", line 96, in check_error
    raise exception(error_code)
broadlink.exceptions.UnknownError: Unknown error: 0xfffb

I’ll try to reset the device and start again.

Unfortunately, resetting the device didn’t help. I’m still getting the same error message.

For the sake of documentation, here is a photo of the RM4 Pro with the red LED. Maybe it will help someone understand what’s going on.

When you’ve got time, could you run the following command when inside your python-broadlink folder, and paste the output here?

git log -1

Additionally, check out this post, especially when it gets to learning codes: could you try that method and let me know if it works? You’ve done almost all of it before, except it uses a slightly different learning method. I expect this to fail too, but just want to check!

Also, just to double check: how are you connecting the device to your WiFi? App or python-broadlink? If it’s the app I wonder whether it is somehow still connecting to the cloud, therefore disabling local control?

1 Like

Hi :slight_smile:
Here is the terminal output you requested:

 pi@raspberrypi:~/python-broadlink $ git log -1
commit fe4aa5b991e033d865e956d7a96526998e917e0f (HEAD -> master, tag: 0.14.1, origin/master, origin/HEAD)
Author: Daniel Hjelseth Høyer <mail@dahoiv.net>
Date:   Fri Jul 31 07:11:51 2020 +0200

    0.14.1

I connected my device to Wifi using the Broadlink app, but once the device was added to the Wifi network (and AP mode slow LED flashing stopped) I did not continue to add the device to the app.

I tried using the python-broadlink method to connect the device to the Wifi network, but the command did not do anything and the device stayed in AP mode with blue LED flashing slowly.
This is the command I used (with my network’s name and passcode):

broadlink.setup('myssid', 'mynetworkpass', 3)

Reading around online, it looks like your device only has a blue LED and a red/orange LED, and when it is in learning mode the red/orange LED is on. So it might actually be working as intended! If you have the user guide, it might be worth checking. Don’t forget that my guide is based on the RM4C Mini, which is not the same as yours!

When learning a remote code my white LED (your red/orange LED) remains on for at least 10 seconds after I started pressing the remote button. Make sure to keep pressing the button until the LED turns off! I don’t know whether this affects the broadlink.exceptions.StorageError: The device storage is full issue though.

If I was you, I would contribute to the open issue on the python-broadlink GitHub, explain the steps you’ve taken, and the results you’re getting, and see if anyone else can help!

can I use this command for block internet (cloud) access to the RM? I’ve a simple router and I can not block a single IP, only configure an IP reservation.

No, that command is only used to connect the RM device to your local wifi network.

I have the RM4 Pro user guide. It actually doesn’t mention the LED color options. Just the different blinking variations and what they mean.

Thanks, I’ll read the thread and write about my issue. Hopefully someone will be able to help :slight_smile:

the RM4C will be disconnected from internet forever or only when I configure it?

To be able to locally control your device, you must not let it connect to the Broadlink servers. If it connects, local control will no longer work.

If it’s setup for local control, then there is no reason for it to connect to the internet!

thank you for the answer

my router can’t block a single ip to the internet…sob…:frowning:

But that’s OK, I think. If you get the device connected too your local WiFi as described in either method (app or python-broadlink), it won’t try to phone home afterwards.

The message is really a warning for those using the app to connect the device to the local WiFi - if you go to far with the app (further than instructed), the device will contact the Broadlink servers!

I cant get my rmpro to connect via the python-broadlink (not using the app).
How can this be done?
I put the rmpro in AP mode (4 blinks, pause). so it does not register an IP on my wifi network yet. How can the broadlink discovery find it?

  1. The RM4C Mini is now a wifi access point. Connect your computer to the access point (it will probably have Broadlink in the name). It may take a little bit of time for the access point to appear in your wifi list.

the access point that says “broadlinkprov”? I see it, can connect to it, but what next?

Then continue with the next step:

  1. Once connected, in a terminal on your computer, start the python console by typing python3 and hitting enter.

I am connecting my laptop to the broadlink RMPRO. where do I type python3? do I ssh into my openhab ubuntu ?My OH resides in a ubuntu VM in my esxi server